yingye / weapp-qrcode

weapp.qrcode.js 在 微信小程序 中,快速生成二维码
MIT License
1.63k stars 982 forks source link

怎么将生成的二维码保存为本地图片。 #47

Closed Ucself closed 4 years ago

Ucself commented 5 years ago

Description

[问题简单描述]

Environment

Reproduce

问题复现步骤: 怎么将生成的二维码保存为本地图片。 期望的表现:

[在这里描述期望的表现]

怎么将生成的二维码保存为本地图片。

[在这里描述观察到的表现]

怎么将生成的二维码保存为本地图片。

![复现步骤的屏幕截图和动态 GIF 图](图片的 url)

Relevant Code / Logs

// TODO(you): code or logs here to reproduce the problem
Noizx commented 5 years ago

相关讨论 #40

ibobjoy commented 4 years ago
    drawQrcode({
      width: 300-40, height: 300-40,
      x: 20, y: 20,
      canvasId: 'canvas',
      background: '#ffffff',
      foreground: '#000000',
      text: "sample text",
      callback(e) {
        console.log('e: ', e)
        //callback 回调不准确 #18
        setTimeout(() => {
          wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 300,
            height: 300,
            canvasId: 'canvas',
            fileType: 'png',
            success(res) {
              console.log('图片的临时路径为:', res.tempFilePath)
              let tempFilePath = res.tempFilePath
              that.setData({
                qrImgsrc: tempFilePath,
                shareTips: "长按图片,直接分享给微信好友",
                qrLoaded:true
              })
            }
          })
        }, 500)

      }
    })