This commit is contained in:
王子琦
2026-01-09 15:48:50 +08:00
commit ea34c396dd
106 changed files with 60207 additions and 0 deletions

258
reg_front/index.html Normal file
View File

@@ -0,0 +1,258 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>信息登记</title>
<style>
:root {
color-scheme: light dark;
--bg: #f5f5f5;
--card: #ffffff;
--text: #222222;
--primary: #2b7cff;
--muted: #666666;
--success: #16a34a;
--danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0f172a;
--card: #111827;
--text: #e5e7eb;
--muted: #9ca3af;
--success: #22c55e;
--danger: #f87171;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
background: var(--bg);
color: var(--text);
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;
}
.card {
width: min(520px, 92vw);
background: var(--card);
border-radius: 18px;
padding: 28px 24px;
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}
h1 {
margin: 0 0 10px;
font-size: 24px;
}
p {
margin: 0 0 22px;
color: var(--muted);
font-size: 14px;
}
label {
display: block;
font-weight: 600;
margin-bottom: 6px;
}
input {
width: 100%;
padding: 12px 14px;
border: 1px solid #d1d5db;
border-radius: 10px;
font-size: 16px;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
background: transparent;
color: inherit;
}
input:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(43, 124, 255, 0.2);
}
.field {
margin-bottom: 18px;
}
button {
width: 100%;
padding: 14px 16px;
border: none;
border-radius: 12px;
background: var(--primary);
color: #fff;
font-size: 16px;
font-weight: 700;
letter-spacing: 0.5px;
cursor: pointer;
transition: transform 0.08s ease, box-shadow 0.2s ease;
box-shadow: 0 12px 24px rgba(43, 124, 255, 0.25);
}
button:active {
transform: scale(0.99);
box-shadow: 0 8px 18px rgba(43, 124, 255, 0.22);
}
button[disabled] {
opacity: 0.75;
cursor: not-allowed;
box-shadow: none;
}
.success {
text-align: center;
padding: 10px 4px 0;
}
.success-icon {
width: 72px;
height: 72px;
margin: 6px auto 14px;
border-radius: 999px;
background: rgba(22, 163, 74, 0.14);
border: 1px solid rgba(22, 163, 74, 0.25);
display: grid;
place-items: center;
color: var(--success);
}
.success-title {
font-size: 20px;
font-weight: 800;
margin: 0 0 6px;
}
.success-desc {
margin: 0 0 18px;
color: var(--muted);
font-size: 14px;
}
.success-btn {
background: var(--success);
box-shadow: 0 12px 24px rgba(22, 163, 74, 0.22);
}
.toast {
position: fixed;
left: 50%;
bottom: 36px;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.82);
color: #fff;
padding: 12px 16px;
border-radius: 999px;
font-size: 14px;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s ease;
}
.toast.error {
background: rgba(220, 38, 38, 0.92);
}
.toast.show {
opacity: 1;
}
</style>
</head>
<body>
<div class="card">
<h1>信息登记</h1>
<p>请填写您的姓名和联系电话,点击“确定”提交。</p>
<div id="success" class="success" hidden>
<div class="success-icon" aria-hidden="true">
<svg width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M20 6 9 17l-5-5"></path>
</svg>
</div>
<div class="success-title">提交成功</div>
<div class="success-desc">我们已收到您的信息。</div>
<button id="success-again" style="display: none" class="success-btn" type="button">继续登记</button>
</div>
<form id="reg-form" novalidate>
<div class="field">
<label for="name">姓名</label>
<input id="name" name="name" type="text" placeholder="请输入姓名" required>
</div>
<div class="field">
<label for="phone">联系电话</label>
<input id="phone" name="phone" type="tel" placeholder="请输入手机号" inputmode="numeric" pattern="^\\d{6,}$" required>
</div>
<button type="submit">确定</button>
</form>
</div>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<script>
const form = document.getElementById('reg-form');
const toast = document.getElementById('toast');
const success = document.getElementById('success');
const successAgain = document.getElementById('success-again');
const submitButton = form.querySelector('button[type="submit"]');
function showToast(message, variant = 'default') {
toast.textContent = message;
toast.classList.toggle('error', variant === 'error');
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 1800);
}
function showSuccess() {
form.hidden = true;
success.hidden = false;
successAgain.focus();
}
function resetToForm() {
success.hidden = true;
form.hidden = false;
form.reset();
form.name.focus();
}
successAgain.addEventListener('click', resetToForm);
form.addEventListener('submit', async (event) => {
event.preventDefault();
const name = form.name.value.trim();
const phone = form.phone.value.trim();
if (!name) {
showToast('请填写姓名', 'error');
return;
}
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) {
showToast('请填写有效联系电话', 'error');
return;
}
submitButton.disabled = true;
const originalButtonText = submitButton.textContent;
submitButton.textContent = '提交中...';
try {
// 调用后端接口提交数据
const response = await fetch('http://118.195.205.71:8888/api/registrations', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
customerName: name,
contact: phone
})
});
if (response.ok) {
showToast('提交成功');
showSuccess();
} else {
showToast('提交失败,请重试', 'error');
}
} catch {
showToast('网络错误,请检查连接', 'error');
} finally {
submitButton.disabled = false;
submitButton.textContent = originalButtonText;
}
});
</script>
</body>
</html>