收藏
回答

canvas绘制微信头像 显示暂时无法查看,已经配置过downloadFile合法域名,求指导?

点击保存生成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: () => {
                   }
               })


最后一次编辑于  2019-10-19
回答关注问题邀请回答
收藏

2 个回答

  • 小满
    小满
    2019-10-19

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

    2019-10-19
    有用 1
    回复 1
    • now
      now
      2019-10-22
      谢谢,稍后我试试
      2019-10-22
      回复
  • 七分
    七分
    2019-10-19

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

    2019-10-19
    有用 1
    回复 3
登录 后发表内容
问题标签