GPA查找系统
This commit is contained in:
198
src/main/resources/static/register.html
Normal file
198
src/main/resources/static/register.html
Normal file
@@ -0,0 +1,198 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>学生绩点管理系统 - 注册</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<style>
|
||||
.register-container {
|
||||
max-width: 400px;
|
||||
margin: 100px auto;
|
||||
padding: 30px;
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.register-form .form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.register-form .form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.register-form .form-group input {
|
||||
width: 100%;
|
||||
padding: 12px 15px;
|
||||
border: 2px solid #ddd;
|
||||
border-radius: 6px;
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.register-form .form-group input:focus {
|
||||
border-color: #667eea;
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
||||
}
|
||||
|
||||
.register-form .btn {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
font-size: 16px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.login-link {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.login-link a {
|
||||
color: #667eea;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.login-link a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: #ff6b6b;
|
||||
background-color: #ffeaea;
|
||||
border: 1px solid #ff6b6b;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 20px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.success-message {
|
||||
color: #28a745;
|
||||
background-color: #d4edda;
|
||||
border: 1px solid #28a745;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 20px;
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="register-container">
|
||||
<h1 style="text-align: center; margin-bottom: 30px;">学生绩点管理系统</h1>
|
||||
<h2 style="text-align: center; margin-bottom: 30px; color: #555;">用户注册</h2>
|
||||
|
||||
<div id="error-message" class="error-message"></div>
|
||||
<div id="success-message" class="success-message"></div>
|
||||
|
||||
<form id="register-form" class="register-form">
|
||||
<div class="form-group">
|
||||
<label for="username">用户名:</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">密码:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="confirm-password">确认密码:</label>
|
||||
<input type="password" id="confirm-password" name="confirm-password" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success">
|
||||
<span class="icon">✅</span> 注册
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="login-link">
|
||||
已有账户?<a href="#" onclick="showLoginForm()">立即登录</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('register-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const confirmPassword = document.getElementById('confirm-password').value;
|
||||
|
||||
// 简单验证
|
||||
if (password !== confirmPassword) {
|
||||
showError('两次输入的密码不一致');
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
showError('密码长度至少为6位');
|
||||
return;
|
||||
}
|
||||
|
||||
const registerData = {
|
||||
username: username,
|
||||
password: password
|
||||
};
|
||||
|
||||
fetch('/api/register', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(registerData)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.json().then(err => {
|
||||
throw new Error(err.error);
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
showSuccess(data.message);
|
||||
|
||||
// 2秒后跳转到登录页面
|
||||
setTimeout(() => {
|
||||
window.location.href = '/login.html';
|
||||
}, 2000);
|
||||
})
|
||||
.catch(error => {
|
||||
showError(error.message);
|
||||
});
|
||||
});
|
||||
|
||||
function showError(message) {
|
||||
document.getElementById('error-message').textContent = message;
|
||||
document.getElementById('error-message').style.display = 'block';
|
||||
document.getElementById('success-message').style.display = 'none';
|
||||
|
||||
// 3秒后隐藏错误信息
|
||||
setTimeout(() => {
|
||||
document.getElementById('error-message').style.display = 'none';
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function showSuccess(message) {
|
||||
document.getElementById('success-message').textContent = message;
|
||||
document.getElementById('success-message').style.display = 'block';
|
||||
document.getElementById('error-message').style.display = 'none';
|
||||
}
|
||||
|
||||
function showLoginForm() {
|
||||
window.location.href = '/login.html';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user