我正在尝试做一个用户首先需要注册的煎茶触摸应用程序。之后,会弹出一个警报,提示您已注册,当用户按下“确定”按钮时,注册表单 (register.js) 将转到登录表单 (login.js)。
这是我的 register.js:
Ext.define('demo.view.Register',{
extend:'Ext.form.Panel',
xtype:'register',
requires:[
'Ext.form.FieldSet',
'Ext.field.Email',
'demo.view.Login'
],
config:{
title:'Register',
iconCls:'user',
url:'doRegister.php',
items:[
{
xtype:'fieldset',
title:'Registration!!!',
items:[
{
xtype:'textfield',
name:'username',
label:'Name'
},
{
xtype:'passwordfield',
name:'password',
label:'Password'
},
{
xtype:'emailfield',
name:'email',
label:'Email'
},
{
xtype:'textfield',
name:'first_name',
label:'First Name'
},
{
xtype:'textfield',
name:'last_name',
label:'Last Name'
}
]
},
{
xtype:'button',
text:'Share',
ui:'confirm',
handler: function() {
// This looks up the items stack above, getting a reference to the first form it see
var form = this.up('register');
// Sends an AJAX request with the form data to the url specified above (contact.php).
// The success callback is called if we get a non-error response from the server
form.submit({
success: function() {
Ext.Msg.alert('Status', 'Resgistered Successful!', function(btn, text){
if (btn == 'ok'){
var redirect = 'login.js';
window.location = redirect;
}
});
}
});
}
}
]
}
});
这是我的 login.js:
Ext.define('demo.view.Login',{
extend:'Ext.form.Panel',
xtype:'login',
requires:[
'Ext.form.FieldSet',
'Ext.field.Email'
],
config:{
title:'Login',
iconCls:'user',
url:'doLogin.php',
items:[
{
xtype:'fieldset',
title:'Please Login',
items:[
{
xtype:'textfield',
name:'username',
label:'username'
},
{
xtype:'passwordfield',
name:'password',
label:'password'
}
]
},
{
xtype:'button',
text:'Login',
ui:'confirm',
handler: function() {
// This looks up the items stack above, getting a reference to the first form it see
var form = this.up('share');
// Sends an AJAX request with the form data to the url specified above (contact.php).
// The success callback is called if we get a non-error response from the server
form.submit({
method:'POST',
waitTitle:'Connecting',
waitMsg:'Sending data...',
success: function() {
Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
if (btn == 'ok'){
var redirect = 'Share.js';
window.location = redirect;
}
});
}
});
}
}
]
}
});