2024-12-20 23:41:14 +08:00
|
|
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
2025-01-13 23:54:21 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2024-12-20 23:41:14 +08:00
|
|
|
|
2025-01-13 23:54:21 +08:00
|
|
|
<head>
|
2025-01-14 00:37:02 +08:00
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
2025-01-13 23:54:21 +08:00
|
|
|
<script>
|
2025-01-14 00:37:02 +08:00
|
|
|
$(document).ready(function () {
|
|
|
|
// 绑定表单提交事件
|
|
|
|
$('#loginForm').submit(function (event) {
|
|
|
|
event.preventDefault(); // 阻止表单默认提交行为
|
|
|
|
|
|
|
|
// 获取表单数据
|
|
|
|
const formData = $(this).serialize();
|
|
|
|
|
|
|
|
// 异步请求
|
|
|
|
$.ajax({
|
|
|
|
url: '/login',
|
|
|
|
type: 'POST',
|
|
|
|
data: formData,
|
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
|
|
|
if (response.status === 'success') {
|
|
|
|
alert(response.message);
|
|
|
|
window.location.href = '/computer?action=list'; // 跳转至主页
|
|
|
|
} else {
|
|
|
|
$('#message').text(response.message).css('color', 'red');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
$('#message').text('请求失败,请稍后重试').css('color', 'red');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// 刷新验证码
|
|
|
|
$('#captchaImage').click(function () {
|
|
|
|
$(this).attr('src', '/captcha?timestamp=' + new Date().getTime());
|
|
|
|
});
|
|
|
|
});
|
2025-01-13 23:54:21 +08:00
|
|
|
</script>
|
|
|
|
</head>
|
2024-12-20 23:41:14 +08:00
|
|
|
|
2025-01-13 23:54:21 +08:00
|
|
|
<body>
|
|
|
|
<h2>-电脑商城-用户登录</h2>
|
2025-01-14 00:37:02 +08:00
|
|
|
<form id="loginForm">
|
2025-01-13 23:54:21 +08:00
|
|
|
<label for="username">用户名:</label>
|
|
|
|
<input type="text" id="username" name="username" required><br><br>
|
|
|
|
<label for="password">密码:</label>
|
|
|
|
<input type="password" id="password" name="password" required><br><br>
|
|
|
|
<label for="captcha">验证码</label>
|
|
|
|
<input type="text" id="captcha" name="captcha" required>
|
2025-01-14 00:37:02 +08:00
|
|
|
<img id="captchaImage" src="/captcha" alt="验证码" style="cursor: pointer;" title="点击刷新验证码"><br><br>
|
2025-01-13 23:54:21 +08:00
|
|
|
<button type="submit">登录</button>
|
|
|
|
<a href="/register">没有账号?去注册</a>
|
|
|
|
</form>
|
|
|
|
<br>
|
2025-01-14 00:37:02 +08:00
|
|
|
<p id="message"></p>
|
2025-01-13 23:54:21 +08:00
|
|
|
</body>
|
2024-12-20 23:41:14 +08:00
|
|
|
|
2025-01-13 23:54:21 +08:00
|
|
|
</html>
|