|
|
|
|
@ -0,0 +1,53 @@
|
|
|
|
|
<!-- login.html -->
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="zh-CN">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
|
<title>登录 - 校园失物招领平台</title>
|
|
|
|
|
<style>
|
|
|
|
|
body { font-family: "Microsoft YaHei"; background: #f0f2f5; display: flex; justify-content: center; align-items: center; height: 100vh; }
|
|
|
|
|
.card { background: white; padding: 30px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); width: 350px; }
|
|
|
|
|
input { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; }
|
|
|
|
|
button { width: 100%; padding: 10px; background: #1890ff; color: white; border: none; border-radius: 4px; cursor: pointer; }
|
|
|
|
|
.admin-login { margin-top: 20px; text-align: center; color: #999; font-size: 14px; }
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="card">
|
|
|
|
|
<h2 style="text-align:center; margin-bottom:20px;">校园失物招领平台</h2>
|
|
|
|
|
<input type="text" id="studentId" placeholder="请输入学号(如:2023123456)" />
|
|
|
|
|
<button onclick="login('user')">学生/教职工登录</button>
|
|
|
|
|
|
|
|
|
|
<div class="admin-login">
|
|
|
|
|
<p>管理员测试账号:<br>学号:admin001<br>密码:123456</p>
|
|
|
|
|
<input type="password" id="adminPwd" placeholder="管理员密码" />
|
|
|
|
|
<button onclick="login('admin')" style="background:#52c41a;">管理员登录</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
function login(role) {
|
|
|
|
|
const studentId = document.getElementById('studentId').value.trim();
|
|
|
|
|
if (!studentId) {
|
|
|
|
|
alert('请输入学号!');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (role === 'admin') {
|
|
|
|
|
const pwd = document.getElementById('adminPwd').value;
|
|
|
|
|
if (studentId !== 'admin001' || pwd !== '123456') {
|
|
|
|
|
alert('管理员账号或密码错误!');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
localStorage.setItem('user', JSON.stringify({ id: 'admin001', role: 'admin', name: '系统管理员' }));
|
|
|
|
|
} else {
|
|
|
|
|
// 普通用户
|
|
|
|
|
localStorage.setItem('user', JSON.stringify({ id: studentId, role: 'user', name: '同学' + studentId.slice(-4) }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alert('登录成功!');
|
|
|
|
|
window.location.href = 'index.html';
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|