canvas绘制微信头像 显示暂时无法查看,已经配置过downloadFile合法域名,求指导?
发布于 7 年前 作者 shaofang 9716 次浏览 来自 官方Issues

点击保存生成canvas图片,

https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83eo1px0jwJnKwEfVXiciaOpNgUlcAcxokyIpYF1JkMb0lmMJIKRRiaiaibXAlhufwPbiacLiaa9BLe21NsOfw/132

代码如下:直接使用getImageInfo,直接使用downloadFile和两者结合使用均出现下图情况。如果不把头像单独存到服务器中应该怎么处理呢?

uni.downloadFile({
                   url: userImg,
                   success: (ress) => {
                       userImgPath = ress.tempFilePath
                       uni.getImageInfo({
                           src: userImgPath,
                           success: res => {
                               console.log('用户头像', res)
                               ctx.save();
                               _this.roundRect(ctx, 234, 420 * scaleH, 44, 44, 22, '#f7f7f7', '#f7f7f7')
                               ctx.drawImage(res.path, 234, 420 * scaleH, 44, 44)
                               ctx.restore();
                               ctx.draw(true)
                           },
                           fail: () => {
                               _this.canvasFlag = false;
                               uni.showToast({
                                   title: '头像生成失败',
                                   duration: 2000,
                                   icon: 'none'
                               });
                           }
                       })
                   },
                   fail: () => {
                   }
               })
2 回复

request建议也配一下。然后绘制那里打个断点,排查下问题。异步了还是没拿到,要不要提前把头像下下来,保存在store里

可以把图片转成base64字节显示

回到顶部