const util = require('../../utils/util.js'); const app = getApp() Page({ data: { imgUrls: [ "../../images/home/banner_1.png", "../../images/home/banner_2.png", "../../images/home/banner_3.png", ], routers: [ { name: '填写日报', url: '../report/edit', img: '../../images/home/edit.png' }, { name: '审核日报', url: '', img: '../../images/home/check.png' }, { name: '我的信息', url: '', img: '../../images/home/my.png' }, { name: '暂无更多', url: '', img: '../../images/home/more.png' } ], disabled: false, //按钮是否禁用 click: true, }, onLoad: function () { }, // 获取输入的值 getValue_username: function (e) { this.setData({ username: e.detail.value }) }, getValue_password: function (e) { this.setData({ password: e.detail.value }) }, // 登录 formSubmitHandle: function (e) { if (this.data.username == "") { wx.showToast({ title: '账号不能为空', icon: 'none', duration: 1000 }) return false; } else if (this.data.password == "") { wx.showToast({ title: '密码不能为空', icon: 'none', duration: 1000 }) return false; } else { if (this.data.click) { var that = this; that.setData({ click: false }); wx.login({ success: res => { wx.request({ url: app.globalData.serverUrl + "/user/loginAdmin", method: "POST", data: { username: that.data.username, password: that.data.password, }, header: { "Content-Type": "application/x-www-form-urlencoded" }, success: function (res) { if (res.data.code == "ok") { wx.showToast({ title: '登录成功', icon: 'success', duration: 2000 }) wx.setStorageSync('userInfo', res.data.data); setTimeout(function () { wx.reLaunch({ url: '../cloud/cloud' }) }, 200) } else { that.setData({ click: true }) wx.showToast({ title: res.data.msg, icon: 'none', duration: 2000 }) } }, fail: function (res) { that.setData({ click: true }) wx.showToast({ title: '登录失败!', icon: 'none', duration: 2000 }) } }) } }) } else { wx.showToast({ title: '登录中,请勿重复点击', icon: 'none', duration: 1000 }) } } } })