// pages/login/index.js import { api } from '../../utils/api.js' Page({ /** * 页面的初始数据 */ data: { checked:false, openData:null }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.init() }, init(){ const openId = wx.getStorageSync("openId") const sessionKey = wx.getStorageSync('seesionKey') const tmp = {openId: openId,sessionKey: sessionKey} this.setData({openData:tmp}) }, read(){ if (this.data.checked === false){ wx.showModal({ content: '请先勾选我已经阅读并同意《植趣用户协议》和《植趣隐私政策》', }) } }, getPhoneNumber(e){ if (e.detail.errMsg != 'getPhoneNumber:ok') { return } const data = {code:e.detail.code, ...this.data.openData} api("/auth/getPhone", 'GET', data).then(res => { wx.hideLoading() if (res.code === 200) { wx.setStorageSync('user', res.data.user) wx.setStorageSync('token', res.data.token) wx.navigateBack() } else { wx.showToast({ icon: 'error', title: res.msg }) } }) }, change(e){ const tmp = this.data.checked === false console.log(tmp); this.setData({checked:tmp}) } })