统一样式

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
+191 -316
View File
@@ -3,335 +3,210 @@
<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>
<script src="https://unpkg.com/html5-qrcode"></script>
<style>
:root {
--primary-color: #1a73e8;
--bg-color: #f8fafc;
--card-bg: #ffffff;
--text-main: #1e293b;
--text-muted: #64748b;
--border-color: #e2e8f0;
</head>
<body>
<main class="page-shell">
<section class="page-header">
<div class="hero-card">
<span class="eyebrow">Certificate Search</span>
<h1>荣誉证书智能核验平台</h1>
<p>支持按证书编号、持有人姓名与发证日期进行检索,也可以直接扫码快速定位证书记录。</p>
<div class="hero-meta">
<span class="meta-chip">数据范围:2024 年 10 月至今</span>
<span class="meta-chip">查询方式:文本检索 / 二维码扫描</span>
</div>
</div>
<aside class="stat-card">
<div>
<div class="stat-label">Module</div>
<div class="stat-value">CERT</div>
</div>
<p></p>
</aside>
</section>
<section class="panel-card">
<div class="panel-title-row">
<div>
<h2 class="panel-title">检索条件</h2>
<div class="panel-subtitle">输入编号或姓名后即可开始查询</div>
</div>
</div>
<div class="search-grid">
<div class="form-group">
<label class="form-label" for="searchTerm">编号 / 姓名</label>
<div class="input-with-action">
<input type="text" id="searchTerm" class="tech-input" placeholder="输入编号或姓名,或点击右侧扫码">
<button type="button" class="icon-action" id="startScanBtn" title="扫码查询" aria-label="扫码查询">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7V5a2 2 0 0 1 2-2h2"></path><path d="M17 3h2a2 2 0 0 1 2 2v2"></path><path d="M21 17v2a2 2 0 0 1-2 2h-2"></path><path d="M7 21H5a2 2 0 0 1-2-2v-2"></path><rect x="7" y="7" width="10" height="10"></rect></svg>
</button>
</div>
</div>
<div class="form-group">
<label class="form-label" for="dateStart">开始日期</label>
<input type="date" id="dateStart" class="tech-input">
</div>
<div class="form-group">
<label class="form-label" for="dateEnd">结束日期</label>
<input type="date" id="dateEnd" class="tech-input">
</div>
<button id="searchBtn" class="tech-button">执行查询</button>
</div>
</section>
<section class="panel-card results-card">
<div class="panel-title-row">
<div>
<h2 class="panel-title">查询结果</h2>
<div class="panel-subtitle">点击“查看详情”进入证书详情页</div>
</div>
</div>
<div id="resultsArea" class="results-shell">
<div class="empty-state">请输入查询条件,或使用扫码功能快速检索证书。</div>
</div>
</section>
</main>
<div id="scanner-overlay" class="scanner-overlay">
<div class="scanner-frame">
<div id="reader"></div>
<div class="scanner-line"></div>
</div>
<div class="scanner-text">请将二维码置于识别框内</div>
<button class="tech-button secondary" id="stopScanBtn" type="button">退出扫描</button>
</div>
<footer class="page-footer">
<p>© 2026 BI Intelligent Query Interface</p>
</footer>
<script>
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
const html5QrCode = new Html5Qrcode("reader");
const scannerOverlay = document.getElementById('scanner-overlay');
document.getElementById('startScanBtn').addEventListener('click', async () => {
scannerOverlay.style.display = 'flex';
const config = {
fps: 15,
qrbox: { width: 300, height: 180 },
aspectRatio: 1.0
};
try {
await html5QrCode.start(
{ facingMode: "environment" },
config,
(decodedText) => {
document.getElementById('searchTerm').value = decodedText;
closeScanner();
handleSearch();
},
() => {}
);
} catch (err) {
alert("无法启动摄像头,请检查 HTTPS 权限或设备连接。");
scannerOverlay.style.display = 'none';
}
});
async function closeScanner() {
if (html5QrCode.isScanning) {
await html5QrCode.stop();
}
scannerOverlay.style.display = 'none';
}
* { box-sizing: border-box; }
body {
background: var(--bg-color);
font-family: system-ui, -apple-system, sans-serif;
margin: 0; padding: 10px;
color: var(--text-main);
line-height: 1.5;
}
document.getElementById('stopScanBtn').addEventListener('click', closeScanner);
.container {
max-width: 1000px;
margin: 20px auto;
background: var(--card-bg);
padding: 24px;
border-radius: 16px;
box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
async function handleSearch() {
const term = document.getElementById('searchTerm').value.trim();
const start = document.getElementById('dateStart').value;
const end = document.getElementById('dateEnd').value;
const display = document.getElementById('resultsArea');
h1 {
text-align: center;
color: var(--primary-color);
font-size: clamp(20px, 5vw, 26px);
margin-bottom: 30px;
}
if (!term) {
alert("请输入证书编号或持有人姓名。");
return;
}
.search-section {
background: var(--bg-color);
padding: 20px;
border-radius: 12px;
margin-bottom: 24px;
border: 1px solid var(--border-color);
}
display.innerHTML = '<div class="loading-state">正在连接证书数据库并执行检索...</div>';
.search-grid {
display: grid;
grid-template-columns: 1fr;
gap: 16px;
}
try {
let query = sbClient.from('certificates').select('*');
query = query.or(`cert_number.ilike.%${term}%,holder_name.ilike.%${term}%`);
@media (min-width: 768px) {
.search-grid {
grid-template-columns: 2fr 1fr 1fr auto;
align-items: end;
if (start) query = query.gte('issue_date', start);
if (end) query = query.lte('issue_date', end);
const { data, error } = await query.order('issue_date', { ascending: false });
if (error) throw error;
renderResults(data);
} catch (err) {
display.innerHTML = `<div class="error-state">检索失败:${err.message}</div>`;
}
}
.form-group { display: flex; flex-direction: column; }
.form-group label {
font-size: 13px;
color: var(--text-muted);
margin-bottom: 6px;
font-weight: 600;
}
function renderResults(data) {
const display = document.getElementById('resultsArea');
if (!data || data.length === 0) {
display.innerHTML = '<div class="empty-state">未找到匹配的证书记录。</div>';
return;
}
/* 搜索框容器:容纳扫码图标 */
.input-with-icon {
position: relative;
display: flex;
align-items: center;
}
.form-control {
padding: 10px 45px 10px 14px; /* 右侧留出空间给图标 */
border: 1px solid var(--border-color);
border-radius: 8px;
font-size: 15px;
width: 100%;
height: 42px;
}
.scan-trigger {
position: absolute;
right: 10px;
cursor: pointer;
color: var(--primary-color);
padding: 5px;
display: flex;
align-items: center;
transition: transform 0.2s;
}
.scan-trigger:hover { transform: scale(1.1); }
.btn-search {
height: 42px;
padding: 0 30px;
background: var(--primary-color);
color: #fff;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
transition: 0.2s;
}
/* 扫码弹出层 */
#scanner-overlay {
display: none;
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.85);
z-index: 9999;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20px;
}
#reader {
width: 100%;
max-width: 400px;
border-radius: 12px;
overflow: hidden;
background: #000;
}
.scanner-controls {
margin-top: 20px;
display: flex;
gap: 15px;
}
.btn-cancel {
padding: 10px 24px;
background: #ef4444;
color: white;
border: none;
border-radius: 6px;
cursor: pointer;
}
/* 表格样式 */
.table-wrapper { overflow-x: auto; margin-top: 10px; }
.result-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.result-table th {
text-align: left; padding: 14px;
background: #f1f5f9; color: var(--text-muted);
font-size: 13px; border-bottom: 2px solid var(--border-color);
}
.result-table td { padding: 14px; border-bottom: 1px solid var(--bg-color); font-size: 14px; }
@media (max-width: 640px) { .hide-on-mobile { display: none; } }
.btn-link { color: var(--primary-color); text-decoration: none; cursor: pointer; font-weight: 600; }
.loading, .no-result { text-align: center; padding: 40px; color: var(--text-muted); }
</style>
</head>
<body>
<div class="container">
<h1>证书查询系统</h1>
<p>说明:可以输入编号或姓名进行查询,也可以点击右侧图标扫码查询;查询范围2024年10月至今</p>
<div class="search-section">
<div class="search-grid">
<div class="form-group">
<label>编号 / 姓名</label>
<div class="input-with-icon">
<input type="text" id="searchTerm" class="form-control" placeholder="输入或扫码查询">
<div class="scan-trigger" id="startScanBtn" title="请扫描条形码">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7V5a2 2 0 0 1 2-2h2"></path><path d="M17 3h2a2 2 0 0 1 2 2v2"></path><path d="M21 17v2a2 2 0 0 1-2 2h-2"></path><path d="M7 21H5a2 2 0 0 1-2-2v-2"></path><rect x="7" y="7" width="10" height="10"></rect></svg>
</div>
</div>
</div>
<div class="form-group">
<label>颁发起</label>
<input type="date" id="dateStart" class="form-control">
</div>
<div class="form-group">
<label>颁发止</label>
<input type="date" id="dateEnd" class="form-control">
</div>
<button id="searchBtn" class="btn-search">查询</button>
</div>
</div>
<div id="resultsArea">
<div class="no-result">请输入信息或点击右侧图标扫码</div>
</div>
</div>
<div id="scanner-overlay">
<div id="reader"></div>
<div class="scanner-controls">
<button class="btn-cancel" id="stopScanBtn">退出扫描</button>
</div>
</div>
<footer class="footer">
<p>© 2026 BI All rights reserved</p>
</footer>
<script>
// Supabase 配置
const SUPABASE_URL = 'https://chixssrphfgxvqqigkzo.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNoaXhzc3JwaGZneHZxcWlna3pvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ2OTE0OTEsImV4cCI6MjA5MDI2NzQ5MX0.Az_Ew2J2zdOMcSV0UNAjBS-LPqGpqhsaN4IyZ5R7iqU';
const sbClient = supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
// 初始化扫码器
const html5QrCode = new Html5Qrcode("reader");
const scannerOverlay = document.getElementById('scanner-overlay');
// --- 扫码逻辑 ---
document.getElementById('startScanBtn').addEventListener('click', async () => {
scannerOverlay.style.display = 'flex';
// 扫码配置:qrbox 设为长方形有助于识别条形码
const config = {
fps: 15,
qrbox: { width: 300, height: 180 },
aspectRatio: 1.0
};
try {
await html5QrCode.start(
{ facingMode: "environment" }, // 使用后置摄像头
config,
(decodedText) => {
// 识别成功
document.getElementById('searchTerm').value = decodedText;
closeScanner();
handleSearch(); // 自动执行查询
},
(errorMessage) => { /* 扫描中不抛出错误 */ }
);
} catch (err) {
alert("无法启动摄像头,请检查 HTTPS 权限或设备连接");
scannerOverlay.style.display = 'none';
}
});
async function closeScanner() {
if (html5QrCode.isScanning) {
await html5QrCode.stop();
}
scannerOverlay.style.display = 'none';
}
document.getElementById('stopScanBtn').addEventListener('click', closeScanner);
// --- 查询逻辑 ---
async function handleSearch() {
const term = document.getElementById('searchTerm').value.trim();
const start = document.getElementById('dateStart').value;
const end = document.getElementById('dateEnd').value;
const display = document.getElementById('resultsArea');
if (!term) {
alert("请输入证书编号或持有人姓名");
return;
}
display.innerHTML = '<div class="loading">正在检索数据库...</div>';
try {
let query = sbClient.from('certificates').select('*');
query = query.or(`cert_number.ilike.%${term}%,holder_name.ilike.%${term}%`);
if (start) query = query.gte('issue_date', start);
if (end) query = query.lte('issue_date', end);
const { data, error } = await query.order('issue_date', { ascending: false });
if (error) throw error;
renderResults(data);
} catch (err) {
display.innerHTML = `<div style="color:#dc2626; text-align:center;">检索失败: ${err.message}</div>`;
}
}
function renderResults(data) {
const display = document.getElementById('resultsArea');
if (!data || data.length === 0) {
display.innerHTML = '<div class="no-result">未找到匹配的证书</div>';
return;
}
let html = `
<div class="table-wrapper">
<table class="result-table">
<thead>
<tr>
<th>证书编号</th>
<th>持有人</th>
<th>荣誉标题</th>
<th>颁发日期</th>
<th>操作</th>
</tr>
</thead>
<tbody>
`;
data.forEach(item => {
html += `
<tr>
<td><strong>${item.cert_number}</strong></td>
<td>${item.holder_name}</td>
<td>${item.honor_title}</td>
<td>${item.issue_date || '-'}</td>
<td><a class="btn-link" onclick="goToDetail('${item.id}')">详情</a></td>
</tr>
let html = `
<div class="table-wrapper">
<table class="result-table">
<thead>
<tr>
<th>证书编号</th>
<th>持有人</th>
<th>荣誉标题</th>
<th>颁发日期</th>
<th>操作</th>
</tr>
</thead>
<tbody>
`;
data.forEach(item => {
html += `
<tr>
<td class="table-highlight">${item.cert_number || '-'}</td>
<td>${item.holder_name || '-'}</td>
<td>${item.honor_title || '-'}</td>
<td>${item.issue_date || '-'}</td>
<td><button class="tech-link-button secondary" type="button" onclick="goToDetail('${item.id}')">查看详情</button></td>
</tr>
`;
});
html += '</tbody></table></div>';
display.innerHTML = html;
}
function goToDetail(id) {
window.location.href = `certificate.html?id=${id}`;
}
document.getElementById('searchBtn').addEventListener('click', handleSearch);
document.getElementById('searchTerm').addEventListener('keypress', e => {
if (e.key === 'Enter') handleSearch();
});
html += '</tbody></table></div>';
display.innerHTML = html;
}
function goToDetail(id) {
window.location.href = `certificate.html?id=${id}`;
}
document.getElementById('searchBtn').addEventListener('click', handleSearch);
document.getElementById('searchTerm').addEventListener('keypress', e => {
if (e.key === 'Enter') handleSearch();
});
</script>
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
</script>
<script src="https://cdn.jsdmirror.cn/gh/bishshi/wechat-detect@main/wechat-detect.js"></script>
</body>
</html>
</html>