// index.js // 获取应用实例 const app = getApp() Page({ data: { ischecked: true }, onLoad() { }, backGame(){ wx.navigateTo({ url: '' }) }, checkFun(){ this.setData({ ischecked: !this.data.ischecked }) }, login(){ if(!this.data.ischecked){ wx.showToast({ title: '请勾选协议', icon: 'none', duration: 2000 }) return; } wx.login({ success (res) { console.log(res) if (res.code) { //发起网络请求 // wx.request({ // url: 'https://example.com/onLogin', // data: { // code: res.code // } // }) } else { console.log('登录失败!' + res.errMsg) } } }) }, // 授权手机号 getPhoneNumber(e) { console.log(e); let that = this if (e.detail.errMsg == "getPhoneNumber:ok") { // console.log(e) const { iv, encryptedData } = e.detail; // that.$u.api.bindMini({ // encrypted: encryptedData, // iv // }).then((res) => { // 绑定手机号 // console.log(res); // let userinfo = that.vuex_userInfo // userinfo.phone = res.data // that.$u.vuex("vuex_userInfo", userinfo); // uni.setStorageSync('userInfo', userinfo) // that.islogin = true // }) } else { uni.showToast({ icon: "none", title: "请授权手机号" }) } } })