sitm
2019-08-02
加粗
标红
插入代码
插入链接
插入图片
上传视频
请 登录 后发表内容
关闭
新增或编辑超链接
链接地址
关闭
插入视频
视频链接
// 首次登录,授权 获取unionid firstLogin: function(source) { console.log(4) var source = source wx.clearStorage('mdd_token') // 获取用户信息 wx.getSetting({ success: res => { // wx.showLoading({ // title: '正在授权···' // }) console.log(5) var that = this if (res.authSetting['scope.userInfo']) { // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 wx.showLoading({ title: '获取信息中···' }) wx.getUserInfo({ success: res => { console.log(6) console.log(res) var resData = res // 可以将 res 发送给后台解码出 unionId wx.showLoading({ title: '微信登录···' }) wx.login({ success: res => { console.log(7) console.log(res) // 发送 res.code 到后台换取 openId, sessionKey, unionId var code = res.code console.log(code) var iv = resData.iv var encryptedData = resData.encryptedData wx.showLoading({ title: '用户登录中····' }) // that.test(code, iv, encryptedData, source) that.loginWechat(code, iv, encryptedData, source) } }) // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 if (this.userInfoReadyCallback) { console.log(14) this.userInfoReadyCallback(res) } } }) } else { wx.showToast({ title: '取消授权', icon:"none" }) console.log('没有授权权限') } }, fail: res => { wx.showToast({ title: '授权失败', icon: "none" }) console.log('没有授权') } }) },
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。待楼主反馈
2019-08-02
赞
回复
关闭
请选择投诉理由
广告内容
违法违规
恶意灌水内容
其他