小程序开发版本可以解析unionid,发布后不能解析unionid?
发布于 5 年前 作者 guiying31 5694 次浏览 来自 官方Issues

我用的官方代码,但是一直获取不到unionid,代码如下:

// 登录

login: function(that) {

wx.login({

success: res => {

wx.request({

url: ‘https://api.weixin.qq.com/sns/jscode2session’,

data: {

appid: ‘(本程序)’,

secret: ‘(本程序)’,

js_code: res.code,

grant_type: ‘authorization_code’

},

success: function(response) {

wx.getUserInfo({

withCredentials: true,

success: re => {

that.globalData.userInfo = re.userInfo;

wx.request({

url: that.serverUrl + ‘login/EncryptedUnionId’,

data: {

encryptedData: re.encryptedData,

iv: re.iv,

sessionKey: response.data.session_key

},

header: {

‘content-type’: ‘application/json’

},

success: function® {

//把unionid存到本地

}

});

}

});

}

});

}

});

},

1 回复

这个接口不能在小程序端访问,所以线上版本访问不了。打开调试模式和不检验安全域名的的时候能访问。

回到顶部