184 lines
6.1 KiB
HTML
184 lines
6.1 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns:th="http://www.thymeleaf.org">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>注册</title>
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
||
<style>
|
||
:root {
|
||
--primary-color: #0f172a;
|
||
--bg-body: #ffffff;
|
||
--input-bg: #f1f5f9;
|
||
--text-muted: #94a3b8;
|
||
}
|
||
body {
|
||
background: var(--bg-body);
|
||
min-height: 100vh;
|
||
padding: 40px;
|
||
font-family: -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
|
||
color: var(--primary-color);
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
}
|
||
|
||
.header { margin-bottom: 40px; }
|
||
.title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
|
||
.subtitle { color: #64748b; font-size: 14px; }
|
||
|
||
/* 现代输入框容器 - 保持与登录页一致的设计语言 */
|
||
.input-group-modern {
|
||
background: var(--input-bg);
|
||
border-radius: 16px;
|
||
padding: 4px 16px;
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 16px; /* 注册页项多,间距稍小一点 */
|
||
border: 1px solid transparent;
|
||
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
||
}
|
||
|
||
.input-group-modern:focus-within {
|
||
background: #fff;
|
||
border-color: var(--primary-color);
|
||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
|
||
transform: translateY(-1px);
|
||
}
|
||
|
||
.input-icon {
|
||
font-size: 20px;
|
||
color: var(--text-muted);
|
||
margin-right: 12px;
|
||
transition: color 0.3s;
|
||
}
|
||
|
||
.input-group-modern:focus-within .input-icon {
|
||
color: var(--primary-color);
|
||
}
|
||
|
||
.modern-input {
|
||
border: none;
|
||
background: transparent;
|
||
width: 100%;
|
||
padding: 12px 0;
|
||
font-size: 15px;
|
||
outline: none;
|
||
color: var(--primary-color);
|
||
font-weight: 500;
|
||
}
|
||
.modern-input::placeholder { color: #cbd5e1; font-weight: 400; }
|
||
|
||
.btn-modern {
|
||
width: 100%;
|
||
background: var(--primary-color);
|
||
color: white;
|
||
padding: 18px;
|
||
border-radius: 16px;
|
||
font-weight: 600;
|
||
font-size: 16px;
|
||
border: none;
|
||
margin-top: 24px;
|
||
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
|
||
transition: transform 0.2s, box-shadow 0.2s;
|
||
}
|
||
.btn-modern:active { transform: scale(0.98); box-shadow: none; }
|
||
.btn-modern:disabled { opacity: 0.7; cursor: not-allowed; }
|
||
|
||
.link-area { text-align: center; margin-top: 24px; }
|
||
.link-area a {
|
||
color: #64748b; text-decoration: none; font-size: 14px;
|
||
font-weight: 500; display: inline-flex; align-items: center;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="header">
|
||
<div class="title">创建账号</div>
|
||
<div class="subtitle">填写以下信息完成注册</div>
|
||
</div>
|
||
|
||
<form id="regForm">
|
||
<!-- 用户名 -->
|
||
<div class="input-group-modern">
|
||
<i class="bi bi-person-fill input-icon"></i>
|
||
<input type="text" class="modern-input" id="username" placeholder="用户名 (必填)" required>
|
||
</div>
|
||
|
||
<!-- 密码 -->
|
||
<div class="input-group-modern">
|
||
<i class="bi bi-shield-lock-fill input-icon"></i>
|
||
<input type="password" class="modern-input" id="password" placeholder="密码 (必填)" required>
|
||
</div>
|
||
|
||
<!-- 昵称 -->
|
||
<div class="input-group-modern">
|
||
<i class="bi bi-emoji-smile-fill input-icon"></i>
|
||
<input type="text" class="modern-input" id="name" placeholder="昵称 (选填)">
|
||
</div>
|
||
|
||
<!-- 手机号 -->
|
||
<div class="input-group-modern">
|
||
<i class="bi bi-phone-fill input-icon"></i>
|
||
<input type="tel" class="modern-input" id="phone" placeholder="手机号 (选填)">
|
||
</div>
|
||
|
||
<!-- 邮箱 -->
|
||
<div class="input-group-modern">
|
||
<i class="bi bi-envelope-fill input-icon"></i>
|
||
<input type="email" class="modern-input" id="email" placeholder="电子邮箱 (选填)">
|
||
</div>
|
||
|
||
<button type="submit" class="btn-modern">立即注册</button>
|
||
</form>
|
||
|
||
<div class="link-area">
|
||
<a href="/login.html">已有账号? <span style="color: #3b82f6; margin-left: 4px;">去登录</span></a>
|
||
</div>
|
||
|
||
<script>
|
||
document.getElementById('regForm').onsubmit = async (e) => {
|
||
e.preventDefault();
|
||
|
||
const btn = document.querySelector('.btn-modern');
|
||
const originalText = btn.textContent;
|
||
|
||
btn.disabled = true;
|
||
btn.textContent = '注册中...';
|
||
|
||
const data = {
|
||
username: document.getElementById('username').value,
|
||
password: document.getElementById('password').value,
|
||
name: document.getElementById('name').value,
|
||
phone: document.getElementById('phone').value,
|
||
email: document.getElementById('email').value
|
||
};
|
||
|
||
try {
|
||
const res = await fetch('/register', {
|
||
method: 'POST',
|
||
headers: {'Content-Type': 'application/json'},
|
||
body: JSON.stringify(data)
|
||
});
|
||
|
||
const json = await res.json();
|
||
|
||
if(json.code === 200) {
|
||
// 可以加一个简单的toast提示,这里直接跳转
|
||
window.location.href = '/login.html';
|
||
} else {
|
||
alert(json.message || '注册失败');
|
||
btn.disabled = false;
|
||
btn.textContent = originalText;
|
||
}
|
||
} catch(error) {
|
||
console.error('Error:', error);
|
||
alert('网络请求失败');
|
||
btn.disabled = false;
|
||
btn.textContent = originalText;
|
||
}
|
||
};
|
||
</script>
|
||
</body>
|
||
</html> |