wx.login({ provider: 'weixin', success: loginRes => { if (loginRes.errMsg === 'login:ok') { let code = loginRes.code let formdata = { jsCode: code, grantType: 'authorization_code' }; _this.api.get('/user/v1/code2Session', formdata).then(res => { console.log(res) wx.getUserInfo({ success: (wxRes) => { console.log("wxRes", wxRes) var pc = new WXBizDataCrypt(appId, res.data.session_key) var data = pc.decryptData(wxRes.encryptedData, wxRes.iv) console.log("data", data) let formdata = { nickname: wxRes.userInfo.nickName, gender: wxRes.userInfo.gender, headimg: wxRes.userInfo.avatarUrl, openid: data.openId, unionid: data.unionId || "", regdevicenumber: "", regplatform: "3", type: "5", }; // 用户登录 console.log("微信登录参数", formdata) _this.api.post('/user/v1/thirdlogin', formdata).then(res => { debugger if (res.status != "200") { console.log("登录失败") return false; } else { console.log("登录成功") // #ifdef APP-PLUS let client = plus.push.getClientInfo() if (client.clientid) { let putClientData = { clientId: client.clientid, userId: res.data.uid, name: res.data.nickname, url: res.data.headimg, urlType: 'dch' } putClientId(putClientData) } // #endif // 保存登录信息 let loginMethod = 2 // 微信登录方式 let loginType = 2 // 微信类型 let dataType = 1 // 用户登录信息记录 saveLoginInfo(loginMethod, loginType, dataType, res.data) debugger _this.$store.commit('login', res.data); _this.OpenId = res.data.openid uni.setStorageSync('openid', res.data.openid); if (_this.typePage) { uni.navigateBack() } else { uni.reLaunch({ url: '../../pages/dch_personal/dch_personal' }) } return true; } }).catch(fail => { return false; }); } }) }).catch(fail => { return false; }); } }, fail: () => { uni.showToast({title:"微信登录授权失败",icon:"none"}); }
发布小程序体验版本只有开启微信授权才能登录?未开启开发调试:发布小程序体验版本,请求接口是https请求,进入小程序能够获取接口数据。但是无法授权登录 开启开发调试:完全没问题 准备发布体验版本给用户,能够不开启开发调试进行授权登录吗?
2020-12-02