You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
434 lines
11 KiB
434 lines
11 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
<title>合格证信息查看</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
background-color: #f5f5f5;
|
|
color: #333;
|
|
-webkit-overflow-scrolling: touch;
|
|
overflow-x: hidden;
|
|
position: relative;
|
|
touch-action: manipulation;
|
|
}
|
|
|
|
html, body {
|
|
height: 100%;
|
|
overflow: hidden;
|
|
overscroll-behavior: none;
|
|
}
|
|
|
|
.container {
|
|
max-width: 480px;
|
|
margin: 0 auto;
|
|
background-color: white;
|
|
height: 100%;
|
|
overflow-y: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
position: relative;
|
|
}
|
|
|
|
.header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 16px;
|
|
background-color: #28a745;
|
|
color: white;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.back-btn {
|
|
background: none;
|
|
border: none;
|
|
color: white;
|
|
font-size: 24px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.certificate {
|
|
margin: 16px;
|
|
padding: 16px;
|
|
background-color: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.promise-badge {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background-color: #e6f7ee;
|
|
color: #28a745;
|
|
padding: 8px 12px;
|
|
border-radius: 4px;
|
|
margin-bottom: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.promise-badge span {
|
|
width: 20px;
|
|
height: 20px;
|
|
background-color: #28a745;
|
|
color: white;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.promise-text {
|
|
margin-bottom: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.promise-item {
|
|
margin-top: 8px;
|
|
padding-left: 20px;
|
|
}
|
|
|
|
.info-item {
|
|
padding: 10px 0;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
display: flex;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.info-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.label {
|
|
font-weight: 500;
|
|
min-width: 80px;
|
|
color: #666;
|
|
}
|
|
|
|
.value {
|
|
flex: 1;
|
|
color: #333;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 40px 20px;
|
|
color: #999;
|
|
}
|
|
|
|
.signature-display img {
|
|
max-width: 200px;
|
|
max-height: 100px;
|
|
border: 1px solid #e0e0e0;
|
|
border-radius: 4px;
|
|
padding: 8px;
|
|
background-color: white;
|
|
}
|
|
|
|
/* 二维码展示样式 */
|
|
#qrCodeDisplay {
|
|
margin: 20px 16px;
|
|
padding: 16px;
|
|
background-color: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
text-align: center;
|
|
}
|
|
|
|
#qrCodeDisplay h3 {
|
|
color: #28a745;
|
|
margin-bottom: 15px;
|
|
font-size: 18px;
|
|
}
|
|
|
|
#qrCodeImage {
|
|
max-width: 250px;
|
|
max-height: 250px;
|
|
margin-bottom: 15px;
|
|
background-color: white;
|
|
padding: 10px;
|
|
border-radius: 8px;
|
|
border: 1px solid #e0e0e0;
|
|
}
|
|
|
|
#qrCodeDisplay div {
|
|
color: #666;
|
|
font-size: 14px;
|
|
text-align: center;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.footer {
|
|
text-align: center;
|
|
padding: 16px;
|
|
font-size: 14px;
|
|
color: #999;
|
|
border-top: 1px solid #f0f0f0;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.container {
|
|
max-width: 100%;
|
|
}
|
|
|
|
.certificate {
|
|
margin: 12px;
|
|
padding: 12px;
|
|
}
|
|
|
|
.header {
|
|
padding: 12px;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 16px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<button class="back-btn" onclick="window.history.back()"><</button>
|
|
<h1>合格证信息查看</h1>
|
|
<div style="width: 24px;"></div>
|
|
</div>
|
|
|
|
<div class="certificate">
|
|
<div class="promise-badge">
|
|
<span>✓</span> 承诺达标合格证
|
|
</div>
|
|
|
|
<div class="promise-text">
|
|
我承诺销售的食用农产品:
|
|
<div class="promise-item">✓ 不使用禁用农药兽药、停用兽药和非法添加物</div>
|
|
<div class="promise-item">✓ 常规农药兽药残留不超标</div>
|
|
<div class="promise-item">✓ 对承诺的真实性负责</div>
|
|
</div>
|
|
|
|
<div id="certificateInfo">
|
|
<div class="empty-state">
|
|
<p>加载中...</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
技术支持:四川又鸟蛋贸易有限公司
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 从URL参数中获取sessionId
|
|
function getSessionIdFromUrl() {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
return urlParams.get('sessionId');
|
|
}
|
|
|
|
// 加载合格证信息
|
|
function loadCertificate() {
|
|
const sessionId = getSessionIdFromUrl();
|
|
|
|
if (!sessionId) {
|
|
displayError('无效的访问链接');
|
|
return;
|
|
}
|
|
|
|
// 从服务器获取对应会话的合格证信息
|
|
fetch(`/getLatestCertificate?sessionId=${encodeURIComponent(sessionId)}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success && data.certificate) {
|
|
displayCertificate(data.certificate);
|
|
} else {
|
|
displayError('未找到对应信息');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('获取合格证信息失败:', error);
|
|
displayError('加载失败,请重试');
|
|
});
|
|
}
|
|
|
|
// 显示合格证信息
|
|
function displayCertificate(certificate) {
|
|
const container = document.getElementById('certificateInfo');
|
|
let html = '';
|
|
|
|
html += `
|
|
<div class="info-item">
|
|
<span class="label">主体名称:</span>
|
|
<span class="value">${certificate.subjectName || ''}</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="label">产品名称:</span>
|
|
<span class="value">${certificate.productName || ''}</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="label">产品重量:</span>
|
|
<span class="value">${certificate.weight || ''}</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="label">承诺依据:</span>
|
|
<span class="value">${certificate.basis || ''}</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="label">产地:</span>
|
|
<span class="value">${certificate.origin || ''}</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="label">联系方式:</span>
|
|
<span class="value">${hidePhoneNumber(certificate.contact) || ''}</span>
|
|
</div>
|
|
<div class="info-item">
|
|
<span class="label">开具日期:</span>
|
|
<span class="value">${formatDate(certificate.date) || ''}</span>
|
|
</div>
|
|
`;
|
|
|
|
if (certificate.signature) {
|
|
html += `
|
|
<div class="info-item">
|
|
<span class="label">签名:</span>
|
|
<div class="signature-display">
|
|
<img src="${certificate.signature}" alt="签名">
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
container.innerHTML = html;
|
|
|
|
// 显示二维码
|
|
displayQRCode();
|
|
}
|
|
|
|
// 显示二维码
|
|
function displayQRCode() {
|
|
const sessionId = getSessionIdFromUrl();
|
|
if (!sessionId) return;
|
|
|
|
// 检查是否已有二维码容器,如有则先移除
|
|
const existingContainer = document.getElementById('qrCodeDisplay');
|
|
if (existingContainer) {
|
|
existingContainer.remove();
|
|
}
|
|
|
|
// 生成查看页面的URL,包含会话ID
|
|
const viewUrl = `http://8.137.125.67:3008/view.html?sessionId=${encodeURIComponent(sessionId)}`;
|
|
|
|
// 创建二维码容器
|
|
const qrContainer = document.createElement('div');
|
|
qrContainer.id = 'qrCodeDisplay';
|
|
qrContainer.style.cssText = `
|
|
margin: 10px 0;
|
|
padding: 10px;
|
|
background-color: #f8f9fa;
|
|
border-radius: 6px;
|
|
text-align: center;
|
|
`;
|
|
|
|
// 创建二维码标题
|
|
const qrTitle = document.createElement('h3');
|
|
qrTitle.style.cssText = `
|
|
color: #28a745;
|
|
margin-bottom: 8px;
|
|
font-size: 14px;
|
|
`;
|
|
qrTitle.innerHTML = '📋 合格证二维码';
|
|
|
|
// 创建二维码图片
|
|
const qrImage = document.createElement('img');
|
|
qrImage.id = 'qrCodeImage';
|
|
qrImage.style.cssText = `
|
|
max-width: 140px;
|
|
max-height: 140px;
|
|
margin-bottom: 8px;
|
|
background-color: white;
|
|
padding: 6px;
|
|
border-radius: 4px;
|
|
border: 1px solid #e0e0e0;
|
|
`;
|
|
|
|
// 创建提示文字
|
|
const qrText = document.createElement('div');
|
|
qrText.style.cssText = `
|
|
color: #666;
|
|
font-size: 11px;
|
|
text-align: center;
|
|
line-height: 1.3;
|
|
`;
|
|
qrText.innerHTML = '<p style="margin-bottom: 2px;">扫描查看完整信息</p><p>长按保存二维码</p>';
|
|
|
|
// 使用Google Charts API生成二维码
|
|
const qrCodeUrl = `https://api.qrserver.com/v1/create-qr-code/?size=140x140&data=${encodeURIComponent(viewUrl)}`;
|
|
qrImage.src = qrCodeUrl;
|
|
|
|
// 组装容器
|
|
qrContainer.appendChild(qrTitle);
|
|
qrContainer.appendChild(qrImage);
|
|
qrContainer.appendChild(qrText);
|
|
|
|
// 找到合适的位置插入二维码容器
|
|
// 在certificate元素内插入
|
|
const certificateElement = document.querySelector('.certificate');
|
|
if (certificateElement) {
|
|
certificateElement.appendChild(qrContainer);
|
|
} else {
|
|
// 如果没有certificate元素,就在container末尾插入
|
|
const container = document.querySelector('.container');
|
|
if (container) {
|
|
container.appendChild(qrContainer);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 显示错误信息
|
|
function displayError(message) {
|
|
const container = document.getElementById('certificateInfo');
|
|
container.innerHTML = `
|
|
<div class="empty-state">
|
|
<p>${message}</p>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
// 格式化日期
|
|
function formatDate(dateValue) {
|
|
if (!dateValue) return '';
|
|
if (typeof dateValue === 'string' && dateValue.includes('T')) {
|
|
return dateValue.split('T')[0];
|
|
}
|
|
return dateValue;
|
|
}
|
|
|
|
// 隐藏电话号码中间四位
|
|
function hidePhoneNumber(phone) {
|
|
if (!phone || phone.length !== 11) return phone;
|
|
return phone.substring(0, 3) + '****' + phone.substring(7);
|
|
}
|
|
|
|
// 页面加载时加载信息
|
|
window.onload = function() {
|
|
loadCertificate();
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|