86 lines
3.1 KiB
HTML
86 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>用户登录 - NAC资产一键上链系统</title>
|
|
<link rel="stylesheet" href="/css/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<div class="logo">
|
|
<h1>NAC资产一键上链系统</h1>
|
|
<p>NewAssetChain One-Click Asset Onboarding System</p>
|
|
</div>
|
|
<nav id="main-nav">
|
|
<a href="/">首页</a>
|
|
<a href="/user/login.html" class="active">登录</a>
|
|
<a href="/user/register.html">注册</a>
|
|
</nav>
|
|
</header>
|
|
|
|
<main>
|
|
<div class="form-container">
|
|
<h2>用户登录</h2>
|
|
<form id="login-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-actions">
|
|
<button type="submit" class="btn btn-primary">登录</button>
|
|
<a href="/user/register.html" class="btn btn-secondary">注册账号</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
<p>© 2026 NewAssetChain. All rights reserved.</p>
|
|
<p>NAC资产一键上链系统 v1.0</p>
|
|
</footer>
|
|
</div>
|
|
|
|
<script src="/js/main.js"></script>
|
|
<script>
|
|
document.getElementById('login-form').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
try {
|
|
const response = await NAC.apiRequest('/auth/login', {
|
|
method: 'POST',
|
|
body: JSON.stringify({ username, password }),
|
|
});
|
|
|
|
if (response.success) {
|
|
NAC.setToken(response.data.token);
|
|
NAC.setUser(response.data.user);
|
|
NAC.showAlert('登录成功!', 'success');
|
|
|
|
// 根据角色跳转
|
|
setTimeout(() => {
|
|
if (response.data.user.role === 'admin') {
|
|
window.location.href = '/admin/dashboard.html';
|
|
} else {
|
|
window.location.href = '/user/dashboard.html';
|
|
}
|
|
}, 1000);
|
|
} else {
|
|
NAC.showAlert(response.message || '登录失败', 'error');
|
|
}
|
|
} catch (error) {
|
|
NAC.showAlert(error.message || '登录失败', 'error');
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|