注册流程
This commit is contained in:
73
pages/login/index.js
Normal file
73
pages/login/index.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import Toast from '../../components/toast/index';
|
||||
Page({
|
||||
data: {
|
||||
body:{
|
||||
userName:'',
|
||||
password:'',
|
||||
code:''
|
||||
}
|
||||
},
|
||||
// 输入框输入时
|
||||
inputChange(event) {
|
||||
let key = event.currentTarget.dataset.type;
|
||||
this.data.body[key] = event.detail.value;
|
||||
},
|
||||
toast(option) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector: '#t-toast',
|
||||
...option,
|
||||
});
|
||||
},
|
||||
|
||||
clickRegister() {
|
||||
wx.redirectTo({
|
||||
url:"/pages/register/index"
|
||||
})
|
||||
},
|
||||
|
||||
longin(){
|
||||
if (!this.data.body.userName) {
|
||||
this.toast({
|
||||
message: '用户名不能为空!',
|
||||
theme: 'fail',
|
||||
placement: 'bottom',
|
||||
direction: 'column'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.data.body.password) {
|
||||
this.toast({
|
||||
message: '请输入密码!',
|
||||
theme: 'fail',
|
||||
placement: 'bottom',
|
||||
direction: 'column'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.data.body.code) {
|
||||
this.toast({
|
||||
message: '请输入验证码!',
|
||||
theme: 'fail',
|
||||
placement: 'bottom',
|
||||
direction: 'column'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.data.body.code != '1') {
|
||||
this.toast({
|
||||
message: '验证码不匹配!',
|
||||
theme: 'fail',
|
||||
placement: 'bottom',
|
||||
direction: 'column'
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log('登录成功');
|
||||
wx.setStorageSync('userInfo',this.data.body);
|
||||
wx.setStorageSync('userToken','123456');
|
||||
wx.redirectTo({url:'/pages/myself/index'});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user