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 @@
+
+
+
+
+
+
合格证信息查看
+
+
+
+
+
+
+
+
+ ✓ 承诺达标合格证
+
+
+
+ 我承诺销售的食用农产品:
+
✓ 不使用禁用农药兽药、停用兽药和非法添加物
+
✓ 常规农药兽药残留不超标
+
✓ 对承诺的真实性负责
+
+
+
+
+
+
+
+
+
+
+