收藏
回答

关于painter 画出海报保存不了,不报错也没进入回调,有大佬么?

已经生成海报但是不能保存,

//保存的  
onImgOK(e) {
    console.log(e)
    this.imagePath = e.detail.path;
    console.log(e.detail.path)
    this.setData({
      image: this.imagePath
    })
    if (this.isSave) {
      this.saveImage(this.imagePath);
    }
  },
  saveImage(imagePath = '') {
    console.log(111, '刚进来',)
    console.log(imagePath)
    console.log(222, '判断条件', this.isSave)
    if (!this.isSave) {
      this.isSave = true;
      console.log(333, this.data.template)
      this.setData({
        paintPallette: this.data.template,
      });
    } else if (imagePath) {
      console.log(imagePath)
      this.isSave = false;
      wx.saveImageToPhotosAlbum({
        filePath: imagePath,
      });
    }
  },



    <painter 
    customStyle='margin-left: 80rpx;height: 1000rpx;'
    customActionStyle="{{customActionStyle}}"
    dancePalette="{{template}}"
    palette="{{paintPallette}}"
    bind:imgOK="onImgOK" 
    bind:touchEnd="touchEnd" 
    action="{{action}}" 
    />


 saveImgToLocal() {
      console.log(444444)
      const that = this;
      setTimeout(() => {
        console.log('that.canvasWidthInPx', that.canvasWidthInPx)
        console.log('that.canvasHeightInPx', that.canvasHeightInPx)
        wx.canvasToTempFilePath({
          canvasId: 'photo',
          destWidth: that.canvasWidthInPx,
          destHeight: that.canvasHeightInPx,
          success: function (res) {
            that.getImageInfo(res.tempFilePath);
            console.log('6666-请求成功', res)
          },
          fail: function (error) {
            console.log('77777-请求失败', error)
            console.error(`canvasToTempFilePath failed, ${JSON.stringify(error)}`);
            that.triggerEvent('imgErr', {
              error: error
            });
          },
        }, this);
      }, 300);
    },
回答关注问题邀请回答
收藏

3 个回答

  • Cjiang
    Cjiang
    2020-07-31

    你好,可以参考一下,其他开发者写的文章:

    https://developers.weixin.qq.com/community/develop/article/doc/000ac686c5c5506f18b87ee825b013

    2020-07-31
    有用
    回复
  • 阴阳屯科技
    阴阳屯科技
    2020-07-30

    都没有发起权限

    2020-07-30
    有用
    回复 1
    • hreat
      hreat
      2020-07-30
      不是权限是使用权限是已经授权了的,在painter中调用,canvasToTempFilePath,成功回调没有进入,失败回调也没有
      2020-07-30
      回复
  • hreat
    hreat
    2020-07-30

    成功回调没有执行,失败的也没有,结束回调也没有进入

    2020-07-30
    有用
    回复
登录 后发表内容
问题标签