import userApi from '../../api/user'; Page({ data: { isAgree: true }, handleAgreeChange(e) { this.setData({ isAgree: e.detail.value.length > 0 }) }, onLogin() { if (!this.data.isAgree) { wx.showToast({ title: '请先同意用户协议和隐私政策', icon: 'none' }) return } }, getPhoneNumber(event){ console.log(event); wx.login({ success: (res) => { // 实现登录逻辑 console.log('登录成功', res) this.sendLogin(res.code,event.detail.code); } }) }, sendLogin(wxcode,phonecode){ userApi.loginWithCode(wxcode,phonecode).then((data)=>{ wx.setStorage({ key:"accessToken", data:data.access_token }) }) } })