getUserInfo获取不到用户信息。返回的都是微信用户?
发布于 6 年前 作者 xuefang 912 次浏览 来自 问答
wx.getSetting({
				success(res) {
					if (res.authSetting['scope.userInfo']) {
						// 已经授权,可以直接调用 getUserInfo 获取头像昵称
						wx.getUserInfo({
							success: function(res) {
								console.log(res.userInfo)
	
							}
						})
					} 
				}
			})
返回的都是微信用户
avatarUrl"https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132"
city""
country""
gender0
language""
nickName"微信用户"
province: (...)

2 回复

我的也是 而且我还不会弹出 授权页面

<open-data style="width: 40px;height: 40px;padding-top: 20px;type="userAvatarUrl"></open-data>

<open-data type="userNickName"></open-data>

用上面的标签显示的内容就是正确的。

周知:小程序将暂缓调整公告 “小程序登录、用户信息相关接口调整说明” 中关于 4月13日 后发布的小程序将回收 wx.getUserInfo 接口可获取用户个人信息能力。回收时间近期内会确定并通知,建议开发者提前适配 wx.getUserInfo 接口回收场景。


补充说明:

1、建议开发者尽快使用 wx.getUserProfile 来获取用户信息,2.10.4 以下基础库不支持使用 wx.getUserProfile 获取用户信息,采用 wx.getUserInfo 原有获取流程不受影响,兼容方式参考示例代码:https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html

2、正式版小程序在 wx.getUserInfo 回收前可正常使用,回收后将返回匿名信息

3、wx.getSetting 获取的 scope.userInfo 按照调用 wx.getUserInfo 返回,返回匿名数据 scope.userInfo 也为 true

4、wx.getUserProfile返回的iv、encryptedData 解密获取不到 unionId,请使用 wx.login 获取 unionId

5、wx.getUserProfile 基础库2.16.0以下,无法获取 iv 和 encryptedData,近期会灰度覆盖到 2.10.4


小程序登录、用户信息相关接口调整说明:https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801

回到顶部