覆盖11.20的代码

This commit is contained in:
wwz
2025-03-12 13:43:14 +08:00
parent cab9f836af
commit 50c5b4ca81
7 changed files with 197 additions and 118 deletions

View File

@@ -59,36 +59,42 @@
console.log(formInfo.shopInfo)
if (res) {
formInfo.url = res;
nextTick(() => {
const barcodeText = '1234567890';
const query = uni.createSelectorQuery();
query.select('#barcodeCanvas')
.fields({ node: true, size: true })
.exec((res) => {
if (res[0]) {
const canvas = res[0].node;
const ctx = canvas.getContext('2d');
const dpr = uni.getSystemInfoSync().pixelRatio;
canvas.width = res[0].width * dpr;
canvas.height = res[0].height * dpr;
ctx.scale(dpr, dpr);
JsBarcode(canvas, barcodeText, {
width: 2,
height: 100,
displayValue: true,
fontOptions: 'bold',
font: 'monospace',
textAlign: 'center',
textPosition: 'bottom',
textMargin: 2,
fontSize: 20,
background: '#ffffff',
lineColor: '#000000'
});
}
});
});
try {
nextTick(() => {
const query = uni.createSelectorQuery();
query.select('#barcodeCanvas')
.fields({
node: true,
size: true
})
.exec((res) => {
if (res[0]) {
const canvas = res[0].node;
const ctx = canvas.getContext('2d');
const dpr = uni.getSystemInfoSync().pixelRatio;
canvas.width = res[0].width * dpr;
canvas.height = res[0].height * dpr;
ctx.scale(dpr, dpr);
JsBarcode(canvas, formInfo.url, {
width: 2,
height: 100,
displayValue: true,
fontOptions: 'bold',
font: 'monospace',
textAlign: 'center',
textPosition: 'bottom',
textMargin: 2,
fontSize: 20,
background: '#ffffff',
lineColor: '#000000'
});
}
});
});
} catch (error) {
//TODO handle the exception
}
}
})
</script>