E企盈营销工具技术服务商 热线:4006-838-530

微信小程序两种重新获取授权的解决方法

E企盈直播平台营销卖货系统

第一种:在onLoad里面直接获取授权,拒绝时跳出弹框,提醒用户是否确定拒绝,如果点击获取授权,则调出微信自身的系统页面,获取个人信息,  wx.login({      success: function (res) {        var JSCODE = res.code        wx.getUserInfo({          lang: ‘zh_CN’,          success: function (res) {            console.log(res);            var userInfo = res.userInfo;            var cardNikeName = userInfo.nickName;            var avatarUrl = userInfo.avatarUrl;            var area = userInfo.province;            var encryptedData = res.encryptedData;            var iv = res.iv;            app.globalData.userInfo = res.userInfo;            wx.setStorageSync(“userInfo”, res.userInfo)            var value = wx.getStorageSync(‘channel’)            console.log(value)            wx.request({              url: ‘https://laohuangli.intbull.com/little/little.jsp’,              data: {                cmd: ‘login’,                channel: value,                app_id: “wxd1949f3130a58e73”,                code: JSCODE,                encrypted_data: encryptedData,                iv: iv,              },              header: {                ‘content-type’: ‘application/json’              },              success: function (res) {                app.globalData.open_id = res.data.open_id;                console.log(res.data.open_id)                wx.setStorageSync(“open_id”, res.data.open_id)              }            })          },          fail: function () {            wx.showModal({              title: ‘警告’,              content: ‘您点击了拒绝授权,将无法正常显示个人信息,点击确定重新获取授权。’,              success: function (res) {                if (res.confirm) {                  wx.openSetting({                    success: (res) => {                      if (res.authSetting[“scope.userInfo”]) {////如果用户重新同意了授权登录                        wx.getUserInfo({                          success: function (res) {                            var userInfo = res.userInfo;                            that.setData({                              nickName: userInfo.nickName,                              avatarUrl: userInfo.avatarUrl,                            })                          }                        })                      }                    }                  })                }              }            })          }        })      }    })第二种:跳出弹框被拒绝,做一个按钮,点击还能跳出弹框 wx.getUserInfo({      success: function (res) {        console.log(res)      },      fail: function () {      }    })在点击函数中调用,就可重复出现弹框小程序

赞(0) 打赏
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » 微信小程序两种重新获取授权的解决方法
分享到: 更多 (0)
E企盈小程序直播营销卖货系统
E企盈直播平台营销卖货系统

评论 抢沙发

E企盈小程序开发

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏