From 2cef83855c6a3508ba033a5e942c8dba53ba417a Mon Sep 17 00:00:00 2001 From: Default User Date: Fri, 30 Jan 2026 16:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=AF=BC=E5=87=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=8A=9F=E8=83=BD=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E7=94=9F=E6=88=90=EF=BC=8C=E5=88=9B=E5=BB=BA?= =?UTF-8?q?view.html=E9=A1=B5=E9=9D=A2=E7=94=A8=E4=BA=8E=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=AE=8C=E6=95=B4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- certificate.html | 137 ++++++++++++++++++++- view.html | 308 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 444 insertions(+), 1 deletion(-) create mode 100644 view.html diff --git a/certificate.html b/certificate.html index 05a5479..597626d 100644 --- a/certificate.html +++ b/certificate.html @@ -429,7 +429,8 @@ - + +
@@ -727,6 +728,136 @@ clearSignature(); } + // 检查提交状态 + function checkSubmissionStatus() { + const sessionId = getSessionId(); + const hasSubmitted = localStorage.getItem('certificateSubmitted_' + sessionId); + + if (hasSubmitted) { + // 已提交过,显示提示 + if (confirm('您已填写过信息,需要导出当前信息吗?')) { + // 触发导出信息按钮的点击事件 + document.getElementById('exportBtn').click(); + } + } else { + // 未提交过,打开填写弹窗 + openModal(); + } + } + + // 导出信息函数 + function exportCertificate() { + const sessionId = getSessionId(); + + // 获取当前合格证信息 + fetch(`/getLatestCertificate?sessionId=${encodeURIComponent(sessionId)}`) + .then(response => response.json()) + .then(data => { + if (data.success && data.certificate) { + // 生成查看页面的URL,包含会话ID + const viewUrl = `http://8.137.125.67:3008/view.html?sessionId=${encodeURIComponent(sessionId)}`; + + // 生成二维码 + generateQRCode(viewUrl); + } else { + alert('没有找到可导出的信息'); + } + }) + .catch(error => { + console.error('获取信息失败:', error); + alert('获取信息失败,请重试'); + }); + } + + // 生成二维码并显示 + function generateQRCode(url) { + // 创建二维码容器 + const qrContainer = document.createElement('div'); + qrContainer.id = 'qrCodeContainer'; + qrContainer.style.cssText = ` + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + z-index: 2000; + padding: 20px; + `; + + // 创建二维码图片 + const qrImage = document.createElement('img'); + qrImage.id = 'qrCodeImage'; + qrImage.style.cssText = ` + max-width: 300px; + max-height: 300px; + margin-bottom: 20px; + background-color: white; + padding: 10px; + border-radius: 8px; + `; + + // 创建提示文字 + const qrText = document.createElement('div'); + qrText.style.cssText = ` + color: white; + font-size: 16px; + text-align: center; + margin-bottom: 20px; + max-width: 90%; + `; + qrText.innerHTML = '扫描二维码查看完整信息
长按保存二维码'; + + // 创建关闭按钮 + const closeBtn = document.createElement('button'); + closeBtn.textContent = '关闭'; + closeBtn.style.cssText = ` + padding: 10px 20px; + background-color: #28a745; + color: white; + border: none; + border-radius: 4px; + font-size: 16px; + cursor: pointer; + `; + closeBtn.onclick = function() { + document.body.removeChild(qrContainer); + }; + + // 构建二维码数据URL + const canvas = document.createElement('canvas'); + canvas.width = 300; + canvas.height = 300; + const ctx = canvas.getContext('2d'); + + // 清空画布 + ctx.fillStyle = '#FFFFFF'; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + // 生成二维码(简单实现,实际项目中可使用qrcode库) + // 这里使用一个占位符,后续将使用实际的二维码生成逻辑 + ctx.fillStyle = '#000000'; + ctx.font = '20px Arial'; + ctx.textAlign = 'center'; + ctx.fillText('二维码生成中...', canvas.width/2, canvas.height/2); + + // 使用Google Charts API生成二维码 + const qrCodeUrl = `https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${encodeURIComponent(url)}`; + qrImage.src = qrCodeUrl; + + // 组装容器 + qrContainer.appendChild(qrImage); + qrContainer.appendChild(qrText); + qrContainer.appendChild(closeBtn); + + // 添加到页面 + document.body.appendChild(qrContainer); + } + // 表单提交处理 document.getElementById('certificateForm').addEventListener('submit', function(e) { e.preventDefault(); @@ -763,6 +894,10 @@ .then(response => response.json()) .then(data => { if (data.success) { + // 标记为已提交 + const sessionId = getSessionId(); + localStorage.setItem('certificateSubmitted_' + sessionId, 'true'); + // 显示结果 displayCertificate(data.certificate); diff --git a/view.html b/view.html new file mode 100644 index 0000000..b91dc52 --- /dev/null +++ b/view.html @@ -0,0 +1,308 @@ + + + + + + 合格证信息查看 + + + +
+
+ +

合格证信息查看

+
+
+ +
+
+ 承诺达标合格证 +
+ +
+ 我承诺销售的食用农产品: +
✓ 不使用禁用农药兽药、停用兽药和非法添加物
+
✓ 常规农药兽药残留不超标
+
✓ 对承诺的真实性负责
+
+ +
+
+

加载中...

+
+
+
+ + +
+ + + +