weapp-qrcode icon indicating copy to clipboard operation
weapp-qrcode copied to clipboard

微信小程序快速生成二维码,支持回调函数返回二维码临时文件

Results 8 weapp-qrcode issues
Sort by recently updated
recently updated
newest added

对微信小程序canvas新旧api做了兼容处理, 可以插入网络或本地图片,不是作为背景,而是二维码的中间。

1、exportImage的方法我改成了这个,这样保存图片的时候才能够保存成功,如果canvas封装成组件的话,canvasToTempFilePath要传入当前canvas的实例 QRCode.prototype.exportImage = function (callback) { if (callback && typeof callback === 'function') { wx.canvasToTempFilePath({ x: 0, y: 0, width: this._htOption.width, height: this._htOption.height, destWidth: this._htOption.width, destHeight: this._htOption.height, canvasId: this.canvasId, success:...

老哥,希望弄个ts 的声明文件

onload中 var qrcode = new QRCode('canvas', { usingIn: this, text: "https://github.com/tomfriwel/weapp-qrcode", width: 150, height: 150, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.H, callback: function(res) { console.log(res) // 未打印 }, success: res...

qrcode = new QRCode('canvas', { text: "https://github.com/tomfriwel/weapp-qrcode", image: '/images/bg.jpg', padding: 12, width: qrcode_w, height: qrcode_w, colorDark: "#1CA4FC", colorLight: "white", correctLevel: QRCode.CorrectLevel.H, callback: (res) => { // 生成二维码的临时文件 console.log(res.path) } });

在 组件中 调用 canvasToTempFilePath 时,也需要传入初始化时的 this 属性。 否则会报错:{errMsg: "canvasToTempFilePath: fail canvas is empty"}

根据示例给的参数,在微信模拟器和真机调试都可以正常显示,发布为体验版本绘制二维码坐标位置全乱了,扫一扫都不能检查出是个二维码。

![image](https://user-images.githubusercontent.com/17783119/70046429-03a2ca00-1601-11ea-9c4b-fd4915b9cb96.png)