初始化v1
This commit is contained in:
81
src/main/resources/templates/merchant/login.html
Normal file
81
src/main/resources/templates/merchant/login.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<!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>
|
||||
body {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.login-card {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-5">
|
||||
<div class="card login-card shadow-lg">
|
||||
<div class="card-header bg-dark text-white text-center py-4">
|
||||
<h3 class="mb-0">
|
||||
<i class="bi bi-shop"></i> 商家后台
|
||||
</h3>
|
||||
<p class="mb-0 mt-2">商家登录</p>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<form id="loginForm">
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">
|
||||
<i class="bi bi-person"></i> 用户名
|
||||
</label>
|
||||
<input type="text" class="form-control form-control-lg" id="username" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">
|
||||
<i class="bi bi-lock"></i> 密码
|
||||
</label>
|
||||
<input type="password" class="form-control form-control-lg" id="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-dark btn-lg w-100 mt-3">
|
||||
<i class="bi bi-box-arrow-in-right"></i> 登录
|
||||
</button>
|
||||
</form>
|
||||
<div class="mt-4 text-center">
|
||||
<a href="/merchant/register.html" class="text-decoration-none">还没有账号?立即注册</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
const response = await fetch('/merchant/login', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
credentials: 'include', // 确保发送Cookie
|
||||
body: JSON.stringify({
|
||||
username: document.getElementById('username').value,
|
||||
password: document.getElementById('password').value
|
||||
})
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.code === 200) {
|
||||
// 使用Session,不需要存储token
|
||||
window.location.href = '/merchant/dashboard.html';
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user