| | |
| | | image: '', |
| | | imageSize: 30, |
| | | canvasId: opt.canvasId, |
| | | nvueContext: opt.nvueContext, |
| | | context: opt.context, |
| | | usingComponents: opt.usingComponents, |
| | | showLoading: opt.showLoading, |
| | |
| | | mask: true |
| | | }); |
| | | } |
| | | var ctx = uni.createCanvasContext(options.canvasId, options.context); |
| | | var ctx = ''; |
| | | if (options.nvueContext) { |
| | | ctx = options.nvueContext; |
| | | } else { |
| | | ctx = uni.createCanvasContext(options.canvasId, options.context); |
| | | } |
| | | var count = qrCodeAlg.getModuleCount(); |
| | | var ratioSize = options.size; |
| | | var ratioImgSize = options.imageSize; |
| | |
| | | ctx.draw(true, () => { |
| | | // 保存到临时区域 |
| | | setTimeout(() => { |
| | | uni.canvasToTempFilePath({ |
| | | width: options.width, |
| | | height: options.height, |
| | | destWidth: options.width, |
| | | destHeight: options.height, |
| | | canvasId: options.canvasId, |
| | | quality: Number(1), |
| | | success: function (res) { |
| | | if (options.cbResult) { |
| | | // 由于官方还没有统一此接口的输出字段,所以先判定下 支付宝为 res.apFilePath |
| | | if (!empty(res.tempFilePath)) { |
| | | options.cbResult(res.tempFilePath) |
| | | } else if (!empty(res.apFilePath)) { |
| | | options.cbResult(res.apFilePath) |
| | | } else { |
| | | if (options.nvueContext) { |
| | | ctx.toTempFilePath( |
| | | 0, |
| | | 0, |
| | | options.width, |
| | | options.height, |
| | | options.width, |
| | | options.height, |
| | | "", |
| | | 1, |
| | | function(res) { |
| | | if (options.cbResult) { |
| | | options.cbResult(res.tempFilePath) |
| | | } |
| | | } |
| | | }, |
| | | fail: function (res) { |
| | | if (options.cbResult) { |
| | | options.cbResult(res) |
| | | } |
| | | }, |
| | | complete: function () { |
| | | uni.hideLoading(); |
| | | }, |
| | | }, options.context); |
| | | ); |
| | | } else { |
| | | uni.canvasToTempFilePath({ |
| | | width: options.width, |
| | | height: options.height, |
| | | destWidth: options.width, |
| | | destHeight: options.height, |
| | | canvasId: options.canvasId, |
| | | quality: Number(1), |
| | | success: function (res) { |
| | | if (options.cbResult) { |
| | | // 由于官方还没有统一此接口的输出字段,所以先判定下 支付宝为 res.apFilePath |
| | | if (!empty(res.tempFilePath)) { |
| | | options.cbResult(res.tempFilePath) |
| | | } else if (!empty(res.apFilePath)) { |
| | | options.cbResult(res.apFilePath) |
| | | } else { |
| | | options.cbResult(res.tempFilePath) |
| | | } |
| | | } |
| | | }, |
| | | fail: function (res) { |
| | | if (options.cbResult) { |
| | | options.cbResult(res) |
| | | } |
| | | }, |
| | | complete: function () { |
| | | uni.hideLoading(); |
| | | }, |
| | | }, options.context); |
| | | } |
| | | }, options.text.length + 100); |
| | | }); |
| | | }, options.usingComponents ? 0 : 150); |
| | |
| | | } |
| | | }; |
| | | QRCode.prototype.clear = function (fn) { |
| | | var ctx = uni.createCanvasContext(this.options.canvasId, this.options.context) |
| | | var ctx = ''; |
| | | if (options.nvueContext) { |
| | | ctx = options.nvueContext; |
| | | } else { |
| | | uni.createCanvasContext(this.options.canvasId, this.options.context) |
| | | } |
| | | ctx.clearRect(0, 0, this.options.size, this.options.size) |
| | | ctx.draw(false, () => { |
| | | if (fn) { |