//index.js //获取应用实例 const app = getApp() Page({ data: { username: '', password: '' }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onShow: function () { // 生命周期函数--监听页面显示 wx.hideTabBar({}) }, onLoad: function () { }, // 获取输入账号 usernameInput: function (e) { this.setData({ username: e.detail.value }) }, // 获取输入密码 passwordInput: function (e) { this.setData({ password: e.detail.value }) }, // 登录处理 login: function () { wx.request({ url: 'http://10.0.100.100:8000/student/login', method:"POST", data:this.data, header: { 'content-type': 'application/json' , }, success:(res)=>{ wx.setStorage({ key: 'data', data: res.data.data }) if (res.data.errcode =="1000"){ wx.showToast({ title: '登录成功', icon: 'success', duration:500, success :function (){ setTimeout(function(){ wx.redirectTo({ url: '../mine/mine/mine', }) },500) } }) }else{ wx.showToast({ title: '登录失败', duration:500, }) } } }) } // wx.switchTab({ // url: '../mine/mine/mine' // }) // wx.request({ // url: app.globalData.globalReqUrl +'/login/login', // 仅为示例,并非真实的接口地址 // method: 'post', // data: { // username: that.data.username, // password: that.data.password // }, // header: { // 'content-type': 'application/x-www-form-urlencoded' // 默认值 // }, // success(res) { // if (res.data.code == "OK") { // var unitName = res.data.data.User.unitName; // var unitId = res.data.data.User.unitId; // wx.setStorageSync('unitId', unitId); // wx.setStorageSync('unitName', unitName); // wx.switchTab({ // url: '../mine/mine' // }) // } else { // wx.showToast({ // title: res.data.message, // icon: 'none', // duration: 2000 // }) // } // } // }) })