收藏
回答

帮忙看下,wx.canvasToTempFilePath没有反应

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug canvas 工具 7.0.4 2.7.2


pyq:function(){
    var that =this
    wx.showLoading({
      title: '请稍后...',
    })
    wx.request({
      url: app.url +'addScan',
      daya:{
        page:"pages/detail/detail",
        one:that.data.detail.id,
        two:that.data.toptjm
      },
      success:function(res){
        console.log(res.data)
        wx.hideLoading()
        var context = wx.createCanvasContext('mycanvas', this)
        context.drawImage(res.data, 50, 20, 200, 200)
        context.setFillStyle('#676050')
        context.setFontSize(18)
        context.setTextAlign('center')
        context.fillText("优趣商城",150,260)
        context.setFontSize(14)
        context.fillText(that.data.detail.name, 150, 300)
        context.setFontSize(12)
        context.fillText("立即扫码选购", 150, 380)
        context.draw(true, wx.canvasToTempFilePath({
          canvasId: 'mycanvas',
          success: function (res) {
            console.log(res);
            // wx.saveImageToPhotosAlbum({
            //   filePath: res.tempFilePath,
            //   success(result) {
            //     console.log(result)
            //     wx.showToast({
            //       title: '图片保存成功',
            //       icon: 'success',
            //       duration: 2000
            //     })
            //   }
            // })
            that.setData({
              scans: 1
            })
          }
        }));
 
         
         
 
      }
    })
  },



回答关注问题邀请回答
收藏

2 个回答

  • June
    June
    2019-07-02

    wx.canvasToTempFilePath最好也加个200的延时,绘制多内容在性能低的安卓机下,因为draw是个异步的,经常失败


    2019-07-02
    有用
    回复 1
    • F
      F
      2019-07-03

      好的,谢谢

      2019-07-03
      回复
  • 亮子🌞
    亮子🌞
    2019-07-01

    ctx.draw(false, function() {


    console.log('绘制完成');


    在这里再去调用

    wx.canvasToTempFilePath


    });


    2019-07-01
    有用
    回复 1
    • F
      F
      2019-07-02

      好的,谢谢

      2019-07-02
      回复
登录 后发表内容