From 95db208162e97112dafee75f00393feb8fb89be3 Mon Sep 17 00:00:00 2001 From: Council Date: Sat, 25 Apr 2026 00:35:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(Task1):=20barcode=20canvas=E6=98=BE?= =?UTF-8?q?=E5=BC=8F=E5=AE=BD=E9=AB=98=20+=20=E6=94=B9=E5=96=84renderBarco?= =?UTF-8?q?de=E8=AF=8A=E6=96=AD=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - canvas 加 width=300 height=80 属性(部分浏览器需显式尺寸才能渲染) - renderBarcode 加诊断:JsBarcode未加载/canvas找不到/shortCode为空/渲染异常 - ticket_card.html (PHP模板) + ticket_card.js (静态JS) 同步修复 --- .../app/plugins/vr_ticket/view/goods/ticket_card.html | 10 ++++++---- .../public/plugins/vr_ticket/static/js/ticket_card.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/shopxo/app/plugins/vr_ticket/view/goods/ticket_card.html b/shopxo/app/plugins/vr_ticket/view/goods/ticket_card.html index e972a28..86a23ec 100644 --- a/shopxo/app/plugins/vr_ticket/view/goods/ticket_card.html +++ b/shopxo/app/plugins/vr_ticket/view/goods/ticket_card.html @@ -436,7 +436,7 @@ var VrTicketWallet = (function() { '
' + '
核销码
' + '
' + escapeHtml(ticket.short_code) + '
' + - '' + + '' + '
' + '
' + '
状态
' + @@ -487,7 +487,7 @@ var VrTicketWallet = (function() { '
' + '
核销码
' + '
' + escapeHtml(ticket.short_code) + '
' + - '' + + '' + '
' + verifiedBadge + '
' + @@ -605,7 +605,9 @@ var VrTicketWallet = (function() { function renderBarcode(shortCode) { try { var canvas = document.getElementById('vrBarcodeCanvas'); - if (!canvas || !shortCode) return; + if (!canvas) { console.warn('[Barcode] canvas not found'); return; } + if (!shortCode) { console.warn('[Barcode] shortCode empty'); return; } + if (typeof JsBarcode === 'undefined') { console.warn('[Barcode] JsBarcode not loaded'); return; } JsBarcode(canvas, shortCode, { format: 'CODE128', width: 2, @@ -615,7 +617,7 @@ var VrTicketWallet = (function() { margin: 5 }); } catch (e) { - console.warn('Barcode render failed:', e); + console.error('[Barcode] render error:', e.message, '| shortCode:', shortCode); } } diff --git a/shopxo/public/plugins/vr_ticket/static/js/ticket_card.js b/shopxo/public/plugins/vr_ticket/static/js/ticket_card.js index d58b479..0b1e28d 100644 --- a/shopxo/public/plugins/vr_ticket/static/js/ticket_card.js +++ b/shopxo/public/plugins/vr_ticket/static/js/ticket_card.js @@ -172,7 +172,7 @@ var VrTicketWallet = (function() { '
' + '
核销码
' + '
' + escapeHtml(ticket.short_code) + '
' + - '' + + '' + '
' + '
' + '
状态
' + @@ -223,7 +223,7 @@ var VrTicketWallet = (function() { '
' + '
核销码
' + '
' + escapeHtml(ticket.short_code) + '
' + - '' + + '' + '
' + verifiedBadge + '
' + @@ -334,7 +334,9 @@ var VrTicketWallet = (function() { function renderBarcode(shortCode) { try { var canvas = document.getElementById('vrBarcodeCanvas'); - if (!canvas || !shortCode) return; + if (!canvas) { console.warn('[Barcode] canvas not found'); return; } + if (!shortCode) { console.warn('[Barcode] shortCode empty'); return; } + if (typeof JsBarcode === 'undefined') { console.warn('[Barcode] JsBarcode not loaded'); return; } JsBarcode(canvas, shortCode, { format: 'CODE128', width: 2, @@ -344,7 +346,7 @@ var VrTicketWallet = (function() { margin: 5 }); } catch (e) { - console.warn('Barcode render failed:', e); + console.error('[Barcode] render error:', e.message, '| shortCode:', shortCode); } }