From 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 18:09:58 +0800
Subject: [PATCH] 上报转运调试
---
node_modules/uview-plus/components/u-qrcode/qrcode.js | 84 ++++++++---------------------------------
1 files changed, 17 insertions(+), 67 deletions(-)
diff --git a/node_modules/uview-plus/components/u-qrcode/qrcode.js b/node_modules/uview-plus/components/u-qrcode/qrcode.js
index 4cdac0a..b420833 100644
--- a/node_modules/uview-plus/components/u-qrcode/qrcode.js
+++ b/node_modules/uview-plus/components/u-qrcode/qrcode.js
@@ -18,6 +18,7 @@
return [c0, c1];
// 3 bytes
} else {
+
c0 = 224 + (code >> 12);
c1 = 128 + (code >> 6 & 63);
c2 = 128 + (code & 63);
@@ -1031,14 +1032,13 @@
image: '',
imageSize: 30,
canvasId: opt.canvasId,
- nvueContext: opt.nvueContext,
- context: opt.context,
+ ctx: opt.ctx,
+ isNvue: opt.isNvue,
+ vuectx: opt.vuectx,
usingComponents: opt.usingComponents,
showLoading: opt.showLoading,
loadingText: opt.loadingText,
};
-
- let canvas = null;
if (typeof opt === 'string') { // 鍙紪鐮丄SCII瀛楃涓�
opt = {
@@ -1087,21 +1087,6 @@
return options.foreground;
}
- let getCanvas = async (id) => {
- return new Promise((resolve, reject)=>{
- try {
- const query = uni.createSelectorQuery().in(this.options.context);
- query.select(`#${id}`)
- .fields({ node: true, size: true })
- .exec((res) => {
- resolve(res[0].node)
- })
- }
- catch (e) {
- console.error("createCanvasContextFail",e)
- }
- })
- }
// 鍒涘缓canvas
let createCanvas = async function (options) {
let isApp = false;
@@ -1116,28 +1101,7 @@
});
}
var ctx = '';
- if (options.nvueContext) {
- ctx = options.nvueContext;
- }
- else {
- // 鑾峰彇canvas node鑺傜偣
- canvas = await getCanvas(options.canvasId);
- // #ifdef MP
- // 涓嶆竻妤氭槸灏忕▼搴忕殑bug杩樻槸浠�涔堝師鍥狅紝canvas鐨刵ode鑺傜偣瀹介珮鍜岃缃殑瀹介珮涓嶄竴鑷� 閲嶆柊璁剧疆涓�
- canvas.width = options.size;
- canvas.height = options.size;
- // #endif
- // #ifdef APP
- ctx = uni.createCanvasContext(options.canvasId, options.context);
- // #endif
- // #ifndef APP
- ctx = canvas.getContext('2d');
- // #endif
-
- }
- // 璁剧疆缁勪欢涓璬ata閲岄潰鐨刢tx
- options.context.ctx = ctx;
- options.context.canvas = canvas;
+ ctx = options.ctx;
var count = qrCodeAlg.getModuleCount();
var ratioSize = options.size;
@@ -1156,7 +1120,7 @@
count: count,
options: options
});
- if (options.nvueContext) {
+ if (options.isNvue) {
ctx.setFillStyle(qrCodeAlg.modules[row][col] ? foreground : options.background);
} else {
ctx.fillStyle = qrCodeAlg.modules[row][col] ? foreground : options.background;
@@ -1168,26 +1132,10 @@
var x = Number(((ratioSize - ratioImgSize) / 2).toFixed(2));
var y = Number(((ratioSize - ratioImgSize) / 2).toFixed(2));
drawRoundedRect(ctx, x, y, ratioImgSize, ratioImgSize, 2, 6, true, true)
- if (options.nvueContext) {
- ctx.drawImage(options.image, x, y, ratioImgSize, ratioImgSize);
- }
- else {
- // #ifdef H5 || APP
- const img = new Image();
- // #endif
-
- // #ifndef H5 || APP
- const img = canvas.createImage();
- // #endif
-
- img.onload = () => {
- ctx.drawImage(img, x, y, ratioImgSize, ratioImgSize);
- };
- img.src = options.image;
- }
+ options.vuectx.drawImage(options.image, x, y, ratioImgSize, ratioImgSize);
// 鐢诲渾瑙掔煩褰�
function drawRoundedRect(ctxi, x, y, width, height, r, lineWidth, fill, stroke) {
- if (options.nvueContext || isApp) {
+ if (options.isNvue || isApp) {
ctxi.setLineWidth(lineWidth);
ctxi.setFillStyle(options.background);
ctxi.setStrokeStyle(options.background);
@@ -1222,11 +1170,11 @@
}
setTimeout(() => {
// canvas2 缁樺埗鏄嚜鍔ㄧ殑涓嶉渶瑕佹墜鍔ㄧ粯鍒�
- if(options.nvueContext || isApp){
+ if(options.isNvue || isApp){
ctx.draw(true, () => {
// 淇濆瓨鍒颁复鏃跺尯鍩�
setTimeout(() => {
- if (options.nvueContext) {
+ if (options.isNvue) {
ctx.toTempFilePath(
0,
0,
@@ -1251,6 +1199,7 @@
canvasId: options.canvasId,
quality: Number(1),
success: function (res) {
+ // console.log('缁樺埗鎴愬姛', res)
if (options.cbResult) {
// 鐢变簬瀹樻柟杩樻病鏈夌粺涓�姝ゆ帴鍙g殑杈撳嚭瀛楁锛屾墍浠ュ厛鍒ゅ畾涓� 鏀粯瀹濅负 res.apFilePath
if (!empty(res.tempFilePath)) {
@@ -1263,6 +1212,7 @@
}
},
fail: function (res) {
+ console.log('缁樺埗澶辫触', res)
if (options.cbResult) {
options.cbResult(res)
}
@@ -1270,7 +1220,7 @@
complete: function () {
uni.hideLoading();
},
- }, options.context);
+ }, options.vuectx);
}
}, options.text.length + 100);
});
@@ -1279,7 +1229,7 @@
options.cbResult("")
}
- }, options.usingComponents ? 0 : 150);
+ }, options.usingComponents ? 100 : 200);
}
createCanvas(this.options);
// 绌哄垽瀹�
@@ -1302,10 +1252,10 @@
};
QRCode.prototype.clear = function (fn) {
var ctx = '';
- if (options.nvueContext) {
- ctx = options.nvueContext;
+ if (options.isNvue) {
+ ctx = options.ctx;
} else {
- uni.createCanvasContext(this.options.canvasId, this.options.context)
+ uni.createCanvasContext(this.options.canvasId, this.options.vuectx)
}
ctx.clearRect(0, 0, this.options.size, this.options.size)
ctx.draw(false, () => {
--
Gitblit v1.9.3