wx.uploadFile下载userInfo.avatarUrl 头像问题
发布于 5 年前 作者 lixiulan 3315 次浏览 来自 问答

下载好的临时路径是wxfile://tmp_2d65ddebb26cdbc80352a867d9f73d93.jpg 打开为404 ,我在真机上作为画板绘制到图上,分享到朋友圈时展示不了,在模拟器为http://tmp/wx28a21610c62fc4bb.o6zAJs0ejnG_Ss2uuV-Fy-kH1J6I.GlWOkVwzQS1c7cdf40bf15d7233d75e3f9da8d6c849e.jpeg  可以打开,并成功展示头像,难道临时路径在真机上不能进行绘板吗?

6 回复

因为返回的是 http 的链接?

oMaoyu  请问你们解决这个问题了吗?

已经解决了,设置

https://wx.qlogo.cn

就可以

我也遇到了这个问题,关闭调试就拿不到头像信息,很奇怪

app.getUserInfo(function (userInfo) {

that.setData({

userInfo: userInfo,

})

wx.downloadFile({

url: that.data.userInfo[‘avatarUrl’],

success: function (res) {

wx.getImageInfo({

src: res.tempFilePath,

success: function (res1) {

userImage = res1.path

console.log(userImage)

}

})

// userImage = res.tempFilePath

}

})

})

本来一开始是用downloadFile拿临时路径进行绘图

ctx.drawImage(userImage, 0.7 * windowWidth / 2, 0.7 * windowWidth * 0.535, 0.3 * windowWidth, 0.3 * windowWidth)

但在电脑上都能拿到并画上头像,在真机上无法进行,远程调试到是可以,脱离远程又没有办法拿取头像。

downloadFile临时路径以及getImageInfo都尝试过

回到顶部