微信授权问题?
发布于 7 年前 作者 yong91 4391 次浏览 来自 官方Issues

 大佬问一个问题,我们的小程序上线了,为什么我们管理员可以授权成功,为什么别的用户不能成功呢 

4 回复

这个我好像看见过   你们授权登录是需要所有的用户信息吗?  比如头像、地址、性别

如果是空会怎么样

好问题,大家一起来猜吧


         //页面跳转
         _getGo() {
           wx.redirectTo({
             url: '../evaluate/evaluate'
           })
         },
         _login() {//授权登录
           wx.login({
             success: res => {
               console.log(res)
               // 获取code
               const code = res.code;
               console.log(code)
               wx.request({
                 url: 'https://www.samewarm.com/Sandy/v2.0/userOpenIdHuiYiShi/fo',
                 data: {
                   code
                 },
                 method: 'get',
                 success: res => {
                   console.log(res.data.Value)
                   const str = res.data.Status;
                   const names = res.data.Value.WeChat; //判断用户是否认证
 
                   if (str == true) {
                     if (names == "Initialize") { //新用户没有登录过
                       const openId = res.data.Value.OpenId; //获取的openid
                       const SessionKey = res.data.Value.SessionKey; //获取的SessionKey
                       const UnionId = res.data.Value.UnionId; //获取的UnionId
 
                       this.setData({ //更新状态
                         openId,
                         SessionKey,
                         UnionId
                       })
 
                       wx.setStorageSync('key', { //缓存数据
                         SessionKey1: this.data.SessionKey,
                         openId1: this.data.openId,
                         UnionId1: this.data.UnionId
                       })
 
                       const sfz = this.data.isHide //如果是新用户就显示授权页面
                       this.setData({
                         isHide: true
                       })
 
                     } else { //老用户 //把这些缓存上UserId Token
                       console.log("123")
                       this._getGo()
                       /*缓存token和userId**/
                       wx.setStorageSync('UTR', { /*缓存token和userId**/
                         UserId: res.data.Value.UserId,
                         Token: res.data.Value.Token,
                         RefreshToken: res.data.Value.RefreshToken
                       })
                       this.setData({
                         isHide: false
                       })
                     }
                   
 
     
 

嗯?! 抱歉走错了,我以为是微信开放社区呢,没想到是幼儿园

回到顶部