校园跑步打开小程序
看效果图
const app = getApp()
let username=''
let password=''
Page({
data: {
username: '',
password: '',
clientHeight:'',
list:''
},
onLoad(){
var that=this
wx.getSystemInfo({
success: function (res) {
console.log(res.windowHeight)
that.setData({
clientHeight:res.windowHeight
});
}
})
},
content(e){
username=e.detail.value
},
password(e){
password=e.detail.value
},
bindGetPhoneNumber(){
console.log(username,password)
let flag = false
if(username=='')
{
wx.showToast({
icon:'none',
title: '账号不能为空',
})
}else if(password==''){
wx.showToast({
icon:'none',
title: '密码不能为空',
})
}else{
wx.cloud.database().collection('admin_teacher')
.get({
success:(res)=>{
console.log(res.data)
this.setData({
list:res.data
})
for (let i = 0; i <this.data.list.length; i++) {
if (username === this.data.list[i].username) {
flag=true;
if (password == this.data.list[i].password) {
wx.showToast({
title: '登陆成功!!',
icon: 'success',
duration: 2500
})
flag=true;
wx.setStorageSync('admin', username)
wx.navigateTo({
url: '../admin_me/admin_me',
})
break;
}else{
wx.showToast({
icon:'error',
title: '密码错误',
})
}
}
};
if(flag==false)
{
wx.showToast({
title: '该用户不存在',
icon: 'error',
duration: 2500
})
}
}
})
}
},
bindMultiPickerChange: function (e) {
this.setData({
multiIndex: e.detail.value
})
console.log('携带数值',this.data.multiArray[e.detail.value])
var classes=this.data.multiArray[e.detail.value]
this.setData({
classes:classes
})
},
})
<view class="main">
<view class="login">
<view class="kuang shadow">
<view class="hint">教师管理</view>
<open-data class="avatar-open" type="userAvatarUrl"></open-data>
<view class="form-group">
<view class="title">账号:</view>
<input placeholder="教师账号" maxlength="30" bindinput="content" placeholder-class="phc" model:value="{{username}}"></input>
</view>
<view class="form-group">
<view class="title">密码:</view>
<input placeholder="教师密码" maxlength="30" bindinput="password" type="password" placeholder-class="phc" model:value="{{password}}"></input>
</view>
<button class="btn" bindtap="bindGetPhoneNumber">点击登录</button>
<view bindtap="url" data-url="../me/me" class="return">管理员登录</view>
</view>
</view>
<view class="bottom">
</view>
</view>
|