// pages/authorizedLogin/authorizedLogin.js var http = require('../../utils/http') Page({ /** * 页面的初始数据 */ data: { principal: '', credentials: '', }, /** * 输入框的值 */ getInputVal: function(e) { const type = e.currentTarget.dataset.type if (type == 'account') { this.setData({ principal: e.detail.value }) } else if (type == 'password') { this.setData({ credentials: e.detail.value }) } }, /** * 登录 */ login() { if(!this.data.principal.trim()){ wx.showToast({ title: '请输入账号', icon: 'none' }) return }if(!this.data.credentials.trim()){ wx.showToast({ title: '请输入密码', icon: 'none' }) return } wx.login({ success: (res) => { var params = { url: "/login", method: "post", data: { appType: 1, credentials: this.data.credentials, loginType: 0, principal: this.data.principal + ':' + res.code }, callBack: result => { http.loginSuccess(result) wx.switchTab({ url: '/pages/index/index' }) }, } http.request(params) }, }) }, /** * 去注册 */ toRegitser: function() { console.log('去注册') wx.navigateTo({ url: "/pages/register/register" }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })