72 lines
1.3 KiB
JavaScript
72 lines
1.3 KiB
JavaScript
Page({
|
|
data:{
|
|
username:'',
|
|
password:''
|
|
},
|
|
getAuthCode: () => {
|
|
my.getAuthCode({
|
|
scopes: 'auth_user',
|
|
success: ({ authCode }) => {
|
|
console.log(`authCode:`, authCode);
|
|
my.alert({
|
|
content: authCode,
|
|
});
|
|
},
|
|
});
|
|
},
|
|
data: {},
|
|
onShareAppMessage() {
|
|
return {
|
|
title: 'view page',
|
|
path: 'page/component/view/view',
|
|
};
|
|
},
|
|
onSubmit() {
|
|
my.alert({ content: '登陆成功' });
|
|
},
|
|
usernameInput(e){
|
|
this.setData({
|
|
username:e.detail.value
|
|
})
|
|
},
|
|
passwordInput(e){
|
|
this.setData({
|
|
password:e.detail.value
|
|
})
|
|
},
|
|
onLogin(){
|
|
if(!this.data.username&&!this.data.password){
|
|
my.alert({
|
|
title:'账号或密码不能为空'
|
|
})
|
|
return
|
|
}
|
|
my.demo.callFunction({
|
|
name:'select',
|
|
data:{
|
|
username:this.data.username,
|
|
password:this.data.password
|
|
},
|
|
success:res=>{
|
|
if(res.result.data.length!=0){
|
|
console.log(res);
|
|
my.alert({
|
|
title:'登录成功'
|
|
})
|
|
my.switchTab({
|
|
url:'/pages/shouye/shouye'
|
|
})
|
|
}else{
|
|
my.alert({
|
|
title:'账号或密码错误'
|
|
})
|
|
}
|
|
},
|
|
fail:err=>{
|
|
}
|
|
})
|
|
}
|
|
});
|
|
|
|
|