You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.6 KiB
82 lines
1.6 KiB
// pages/adlogin/adlogin.js
|
|
Page({
|
|
data: {
|
|
account:'',
|
|
password:''
|
|
},
|
|
|
|
//获取输入的账号
|
|
getAccount(evt) {
|
|
//console.log('账号', evt.detail.value)
|
|
this.setData({
|
|
account: evt.detail.value
|
|
})
|
|
},
|
|
|
|
//获取管理员输入的密码
|
|
getPassword(event) {
|
|
// console.log('密码', event.detail.value)
|
|
this.setData({
|
|
password: event.detail.value
|
|
})
|
|
},
|
|
|
|
//点击管理员登陆
|
|
guanliyuanlogin() {
|
|
|
|
let account = this.data.account
|
|
let password = this.data.password
|
|
console.log('管理员账号', account, '管理员密码', password)
|
|
if (account.length < 4) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '账号至少4位',
|
|
})
|
|
return
|
|
}
|
|
if (password.length < 4) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '密码至少4位',
|
|
})
|
|
return
|
|
}
|
|
|
|
|
|
//管理员登陆
|
|
wx.cloud.database().collection('user').where({
|
|
account: account
|
|
}).get({
|
|
success(res) {
|
|
console.log("获取数据成功", res)
|
|
let manager = res.data[0]
|
|
console.log("manager", manager)
|
|
if (password == manager.password) {
|
|
console.log('登陆成功')
|
|
wx.showToast({
|
|
title: '登陆成功',
|
|
})
|
|
// wx.navigateTo({
|
|
// url: '../home/home?name=' + user.name,
|
|
// })
|
|
wx.navigateTo({
|
|
url: '/pages/me1/me1',
|
|
})
|
|
//保存管理员登陆状态
|
|
wx.setStorageSync('manager', manager)
|
|
} else {
|
|
console.log('登陆失败')
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '账号或密码不正确',
|
|
})
|
|
}
|
|
},
|
|
fail(res) {
|
|
console.log("获取数据失败", res)
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
}) |