校园跑步打开小程序

看效果图

校园跑步打开小程序_小程序

校园跑步打开小程序_ico_02

校园跑步打开小程序_json_03

校园跑步打开小程序_微信小程序_04

//index.js
//获取应用实例
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 //表示账户是否存在,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>