const app = getApp(); const request = require('../../utils/request.js'); import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast'; Page({ data: { phone: '' }, onLoad: function (options) { // if(!wx.getStorageSync('userId')){ // wx.showModal({ // title: '提示', // content: '请扫描二维码进入小程序', // showCancel: false, // success: (res) => { // if (res.confirm) { // wx.navigateTo({ // url: '/pages/login/login', // }) // } // } // }) // return false; // } // let userId = app.globalData.userId; }, onuserChange(e) { this.setData({ user: e.detail }) }, onpwdChange(e) { this.setData({ pwd: e.detail }) }, async register() { this.setData({ usererr: this.data.user ? '' : '账号不能为空', pwderr: this.data.pwd ? '' : '密码不能为空' }) if (this.data.user && this.data.pwd) { let options = { url: 'resource/miniapp/user/register', // data:params, data: { 'loginName': this.data.user, 'password': this.data.pwd, 'accountId': '' }, method: 'POST' } let res = await request.query(options); console.log(res) if (res.data.code === 200) { wx.showModal({ title: '提示', content: '注册成功', showCancel: false, success: (res) => { if (res.confirm) { wx.navigateTo({ url: '/pages/login/login?user=' + this.data.user + '&&pwd=' + this.data.pwd, }) } } }) } else if (res.data.msg === '客户信息有误,请联系管理员!') { wx.showModal({ title: '提示', content: '请扫描二维码进入小程序', showCancel: false, success: (res) => { if (res.confirm) { wx.scanCode({ success: (res) => {}, fail: (res) => { console.log(res) } }) } } }) } else { Toast.fail(res.data.msg); } } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, login() { wx.navigateTo({ url: '/pages/login/login', }) } })