77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
import Toast from '../../components/toast/index';
|
|
Page({
|
|
data: {
|
|
body:{
|
|
userName:'',
|
|
password:'',
|
|
code:''
|
|
}
|
|
},
|
|
onShow() {
|
|
wx.hideHomeButton();
|
|
},
|
|
// 输入框输入时
|
|
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'});
|
|
|
|
}
|
|
|
|
});
|