刚试了一下新的wx.getUserProfile APi,还行。
<button bind:tap="onGetUserInfo">登陆</button>
onGetUserInfo() {
wx.getUserProfile({
lang: "zh_CN",
// 这里的desc为必填项,如果你没填,那么会直接去执行fail
desc: "获取登陆授权",
success: function (res) {
console.log(res)
},
fail: function (error) {
console.log(error)
}
})
},
onLoad: function (options) {
wx.getUserInfo({
lang: "zh_CN",
success: function (res) {
console.log(res)
},
fail: function (error) {
console.log(error)
}
})
}
userInfo:
avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132"
city: ""
country: ""
gender: 0
language: ""
nickName: "微信用户"
province: ""
感觉getUserInfo已经没用了,获取不到用户名,头像。我在文档里找了一下,现在有这样一句话:回收wx.getUserInfo接口可获取用户个人信息能力,即wx.getUserInfo接口的返回参数不变,但开发者获取的userInfo为匿名信息。所以,getUserInfo这条路应该已经堵死了。
3. 文档地址:https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801?idescene=6。