wx.getUserInfo({
success: res => {
this.globalData.userInfo = res.userInfo
this.globalData.nickname = res.userInfo.nickName
//获取用户头像
var userInfo = res.userInfo
var avatarUrl = userInfo.avatarUrl; //获取微信用户头像存放的Url
wx.getImageInfo({
src: avatarUrl,
success: function (res) { //访问存放微信用户头像的Url
that.globalData.userimg = res.path
}
})
console.log(that.globalData.userimg)
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
发现微信开发工具和手机 通过getUserInfo 获取的头像的路径不一样 开发工具获取的是对的 但是手机测试的时候不对 开发工具获取的可以显示但是手机获取的不能显示
开发工具获取的https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJ2GuAvvKecNTC3ia8icrVFs9mSkfSdysuOdt3SrqELZmk60Sk6UrdYAQk8iayG2GemULRKBJuia9WR5A/132
手机测试获取的
https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132
手机测试打开调试,按照楼上所说位置打印信息,看看用不头像是否获取出来