getUserInfo的openId和unionId值为undefined
发布于 6 年前 作者 fsu 10916 次浏览 来自 问答

wx.login({

success: function () {

wx.getUserInfo({

success: function (res) {

console.log("==============wxlogin userInfo=" + res.userInfo);

wx.request({

url: https://xxxxxx.com/xxxx,

method: ‘GET’,

data: {

openid: res.userInfo.openId,

nickname: res.userInfo.nickName,

gender: res.userInfo.gender,

city: res.userInfo.city,

province: res.userInfo.province,

country: res.userInfo.country,

avatarurl: res.userInfo.avatarUrl,

unionid: res.userInfo.unionId

},

header: {

‘Accept’: ‘application/json’

},

success: function (res) {

console.log(res);

}

});

}

});

2 回复

获取openId和unionId的值需要登录成功返回一个code,而你写的回调函数啥也没接收,好好看看文档

回到顶部