统一样式

This commit is contained in:
2026-04-26 10:28:58 +08:00
Unverified
parent ef001c7460
commit c54e5209af
7 changed files with 1813 additions and 1024 deletions
+137 -173
View File
@@ -3,160 +3,84 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>荣誉证书核验 - 详细信息</title>
<title>证书核验详情</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&family=Orbitron:wght@500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../css/tech-query.css">
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
<style>
:root { --primary: #1a73e8; }
body {
margin: 0; padding: 0; background: #f0f2f5;
display: flex; flex-direction: column; align-items: center;
min-height: 100vh;
font-family: system-ui, -apple-system, sans-serif;
}
/* 顶部工具栏 */
.toolbar {
width: 100%; padding: 15px; background: white;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
position: sticky; top: 0; z-index: 100;
display: flex; justify-content: center; gap: 15px;
}
.btn {
padding: 8px 20px; border-radius: 6px; cursor: pointer;
font-weight: 500; text-decoration: none; font-size: 14px; border: none;
}
.btn-print { background: var(--primary); color: white; }
.btn-back { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
/* 主体内容 */
.main-content {
width: 100%; max-width: 850px;
display: flex; flex-direction: column; padding: 20px;
}
/* 证书预览区域 */
#cert-viewport {
width: 100%; background: white;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
margin-bottom: 40px;
display: flex; justify-content: center;
cursor: pointer;
position: relative;
min-height: 400px;
align-items: center;
}
#cert-img { width: 100%; height: auto; display: none; }
/* 点击加载提示 */
.click-hint {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
color: #64748b;
font-size: 16px;
}
.click-hint-icon {
font-size: 48px;
margin-bottom: 10px;
color: var(--primary);
}
/* 详细信息表卡片 */
.info-card {
width: 100%; background: white; border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
overflow: hidden; margin-bottom: 40px;
}
.info-header {
background: #f8fafc; padding: 15px 20px;
border-bottom: 1px solid #edf2f7; font-weight: 600;
display: flex; justify-content: space-between;
}
.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td {
padding: 16px 20px; text-align: left; border-bottom: 1px solid #f1f5f9;
font-size: 14px;
}
.info-table th { color: #64748b; width: 25%; font-weight: 500; background: #fafbfc; }
.info-table td { color: #1e293b; }
.status-tag { padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.status-valid { background: #dcfce7; color: #166534; }
/* --- 核心修改:打印分页样式 --- */
@media print {
body { background: white; }
.toolbar, .footer { display: none !important; }
.main-content { padding: 0; max-width: none; width: 100%; }
/* 第一页:证书 */
#cert-viewport {
box-shadow: none;
margin: 0;
width: 100%;
page-break-after: always; /* 旧版浏览器兼容 */
break-after: page; /* 现代浏览器:强制在此元素后分页 */
}
/* 第二页:详情表 */
.info-card {
box-shadow: none;
border: 1px solid #e2e8f0;
margin: 0;
break-before: page; /* 确保详情表从新页面开始 */
}
.info-table th { background: #f8fafc !important; -webkit-print-color-adjust: exact; }
@page {
size: A4 portrait;
margin: 10mm; /* 设置页边距 */
}
}
.footer { padding: 40px 0; text-align: center; color: #94a3b8; font-size: 13px; }
</style>
</head>
<body>
<div class="toolbar">
<a href="javascript:history.back()" class="btn btn-back">返回查询</a>
<button class="btn btn-print" onclick="window.print()">打印证书及明细</button>
</div>
<div class="main-content">
<div id="cert-viewport" onclick="loadCertificateImage()">
<img id="cert-img" alt="荣誉证书原件">
<div class="click-hint" id="click-hint">
<div class="click-hint-icon">🖼️</div>
<div>点击查看证书图片</div>
<main class="detail-shell">
<div class="top-actions">
<a href="javascript:history.back()" class="tech-link-button secondary">返回查询</a>
<div class="top-actions-group">
<button type="button" class="tech-button secondary" onclick="loadCertificateImage()">加载证书图片</button>
<button type="button" class="tech-button" onclick="printCertificate()">打印证书与明细</button>
</div>
</div>
<div class="info-card" id="info-card" style="display: none;">
<div class="info-header">
<span>证书明细</span>
<span id="display-status"></span>
</div>
<table class="info-table">
<tr><th>证书编号</th><td id="d-cert-number">-</td></tr>
<tr><th>持有人姓名</th><td id="d-holder-name">-</td></tr>
<tr><th>荣誉名称</th><td id="d-honor-title">-</td></tr>
<tr><th>颁发日期</th><td id="d-issue-date">-</td></tr>
<tr><th>颁发机构</th><td id="d-issuer">-</td></tr>
<tr><th>详细描述</th><td id="d-desc">-</td></tr>
<tr><th>系统备注</th><td id="d-remarks">-</td></tr>
<tr><th>核验时间</th><td id="d-verify-time">-</td></tr>
</table>
</div>
</div>
<section class="detail-grid">
<section class="preview-panel">
<div class="section-kicker">Certificate Preview</div>
<h1 class="section-heading">证书原件预览</h1>
<p class="section-copy">点击下方预览区域或使用顶部按钮,即可加载对应证书原件图片。</p>
<div id="cert-viewport" class="certificate-stage" onclick="loadCertificateImage()">
<img id="cert-img" alt="证书原件">
<div class="certificate-hint" id="click-hint">
<span class="hint-orb"></span>
<strong>点击加载证书图片</strong>
<span>原件图片将从当前证书编号对应的 `img/*.svg` 文件中读取。</span>
</div>
</div>
</section>
<footer class="footer">
<p>© 2026 BI</p>
<aside class="summary-panel">
<div class="section-kicker">Verify Status</div>
<h2 class="section-heading">核验摘要</h2>
<p class="section-copy">证书基础信息与系统核验状态会在这里同步展示。</p>
<div class="summary-stack">
<div class="summary-tile">
<span class="summary-label">证书编号</span>
<div class="summary-value emphasis" id="summary-cert-number">-</div>
</div>
<div class="summary-tile">
<span class="summary-label">持有人</span>
<div class="summary-value" id="summary-holder-name">-</div>
</div>
<div class="summary-tile">
<span class="summary-label">核验状态</span>
<div id="display-status"><span class="status-pill pending">待核验</span></div>
</div>
<div class="summary-tile">
<span class="summary-label">最近核验时间</span>
<div class="summary-value" id="summary-verify-time">-</div>
</div>
</div>
</aside>
</section>
<section class="detail-panel" id="info-card" style="display: none; margin-top: 18px;">
<div class="section-kicker">Certificate Detail</div>
<h2 class="section-heading">证书明细信息</h2>
<p class="section-copy">以下信息由证书数据库实时读取,用于核验与归档展示。</p>
<div class="info-table-shell">
<table class="info-table">
<tr><th>证书编号</th><td id="d-cert-number">-</td></tr>
<tr><th>持有人姓名</th><td id="d-holder-name">-</td></tr>
<tr><th>荣誉名称</th><td id="d-honor-title">-</td></tr>
<tr><th>颁发日期</th><td id="d-issue-date">-</td></tr>
<tr><th>颁发机构</th><td id="d-issuer">-</td></tr>
<tr><th>详细描述</th><td id="d-desc">-</td></tr>
<tr><th>系统备注</th><td id="d-remarks">-</td></tr>
<tr><th>核验时间</th><td id="d-verify-time">-</td></tr>
</table>
</div>
</section>
</main>
<footer class="page-footer">
<p>© 2026 BI Intelligent Query Interface</p>
</footer>
<script>
@@ -175,56 +99,55 @@
.eq('id', id)
.single();
if (error || !data) throw error;
if (error || !data) throw error || new Error('未找到证书信息');
// 填充数据
const verifyTime = new Date().toLocaleString('zh-CN');
document.getElementById('info-card').style.display = 'block';
document.getElementById('d-cert-number').innerText = data.cert_number;
document.getElementById('d-holder-name').innerText = data.holder_name;
document.getElementById('d-honor-title').innerText = data.honor_title;
document.getElementById('d-cert-number').innerText = data.cert_number || '-';
document.getElementById('d-holder-name').innerText = data.holder_name || '-';
document.getElementById('d-honor-title').innerText = data.honor_title || '-';
document.getElementById('d-issue-date').innerText = data.issue_date || '-';
document.getElementById('d-issuer').innerText = data.issuer || '官方授权机构';
document.getElementById('d-desc').innerText = data.description || '官方荣誉认证';
document.getElementById('d-remarks').innerText = data.remarks || '无';
document.getElementById('d-verify-time').innerText = new Date().toLocaleString();
document.getElementById('d-verify-time').innerText = verifyTime;
document.getElementById('summary-cert-number').innerText = data.cert_number || '-';
document.getElementById('summary-holder-name').innerText = data.holder_name || '-';
document.getElementById('summary-verify-time').innerText = verifyTime;
if (data.status === 'valid') {
document.getElementById('display-status').innerHTML = '<span class="status-tag status-valid">有效</span>';
document.getElementById('display-status').innerHTML = '<span class="status-pill done">有效</span>';
} else if (data.status === 'invalid') {
document.getElementById('display-status').innerHTML = '<span class="status-pill pending">无效</span>';
} else {
document.getElementById('display-status').innerHTML = '<span class="status-pill pending">待核验</span>';
}
if (data.status === 'invalid') {
document.getElementById('display-status').innerHTML = '<span class="status-tag">无效</span>';
}
// 图片改为点击加载,初始不加载
window.currentCertNumber = data.cert_number;
} catch (e) {
console.error("加载失败:", e);
alert("证书信息检索失败");
console.error('加载失败:', e);
alert('证书信息检索失败。');
}
}
// 点击加载证书图片
function loadCertificateImage() {
const certNumber = window.currentCertNumber;
if (!certNumber) return;
const img = document.getElementById('cert-img');
const hint = document.getElementById('click-hint');
// 如果图片已加载,直接显示
if (img.src && img.complete) {
img.style.display = 'block';
if (hint) hint.style.display = 'none';
return;
}
// 加载中提示
if (hint) {
hint.innerHTML = '<div class="click-hint-icon"></div><div>图片加载中...</div>';
hint.innerHTML = '<span class="hint-orb"></span><strong>图片加载中</strong><span>正在读取证书原件,请稍候。</span>';
}
img.src = `img/${certNumber}.svg`;
img.onload = () => {
img.style.display = 'block';
@@ -232,14 +155,55 @@
};
img.onerror = () => {
if (hint) {
hint.innerHTML = '<div class="click-hint-icon"></div><div>图片加载失败</div>';
hint.innerHTML = '<span class="hint-orb">!</span><strong>图片加载失败</strong><span>未找到对应证书图片文件,请检查 `img` 目录资源。</span>';
}
};
}
loadData();
async function ensureCertificateImageLoaded() {
const certNumber = window.currentCertNumber;
const img = document.getElementById('cert-img');
const hint = document.getElementById('click-hint');
if (!certNumber) {
throw new Error('未找到证书编号');
}
if (img.src && img.complete && img.naturalWidth > 0) {
img.style.display = 'block';
if (hint) hint.style.display = 'none';
return;
}
if (hint) {
hint.innerHTML = '<span class="hint-orb">载</span><strong>图片加载中</strong><span>正在为打印准备证书原件,请稍候。</span>';
}
await new Promise((resolve, reject) => {
img.onload = () => {
img.style.display = 'block';
if (hint) hint.style.display = 'none';
resolve();
};
img.onerror = () => {
reject(new Error('证书图片加载失败'));
};
img.src = `img/${certNumber}.svg`;
});
}
async function printCertificate() {
try {
await ensureCertificateImageLoaded();
window.print();
} catch (error) {
console.error('打印前加载证书失败:', error);
alert('证书原件加载失败,无法打印。');
}
}
loadData();
</script>
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
</body>
</html>
</html>