mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
103 lines
3.4 KiB
HTML
103 lines
3.4 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<%- include("./component/header.html"); %>
|
|
<style>
|
|
.main {
|
|
width: 80vw !important;
|
|
max-width: initial !important;
|
|
}
|
|
|
|
#bookImage {
|
|
/* width: 100%; */
|
|
height: auto;
|
|
max-height: 300px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group {
|
|
display: grid;
|
|
grid-template-columns: auto auto;
|
|
width: 250px;
|
|
margin: 0 auto;
|
|
row-gap: 20px;
|
|
margin-bottom: 30px;
|
|
place-items: center;
|
|
}
|
|
|
|
.form-group > input {
|
|
height: 25px;
|
|
}
|
|
|
|
.btn-submit {
|
|
height: 30px;
|
|
width: 72px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<%- include("./component/navbar.html"); %>
|
|
<main class="main">
|
|
<h1><%= headText %></h1>
|
|
<div id="container">
|
|
<div>
|
|
<!-- 用户登录 输入用户名和密码的文本框 -->
|
|
<div class="form">
|
|
<div class="form-group">
|
|
<label for="username">用户名</label>
|
|
<input type="text" id="username" placeholder="用户名">
|
|
<label for="password">密码</label>
|
|
<input type="password" id="password" placeholder="密码">
|
|
</div>
|
|
<button class="btn-register">注册</button>
|
|
<p>
|
|
<a href="/login">登录</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<%- include("./component/footer.html"); %>
|
|
|
|
<script>
|
|
localStorageUtils.checkLocalStorage();
|
|
|
|
$("#username").val("xiaomo");
|
|
$("#password").val("123456");
|
|
$(".btn-register").click(function() {
|
|
var username = $("#username").val();
|
|
var password = $("#password").val();
|
|
|
|
postRequest("/user/register", { username: username, password: password })
|
|
.then(function (response) {
|
|
var axiosData = response.data;
|
|
var status = axiosData.status;
|
|
var data = axiosData.data;
|
|
|
|
if (status === "success") {
|
|
console.log(data);
|
|
if(data) {
|
|
localStorageUtils.userLogin({
|
|
token: data.token,
|
|
is_admin: data.group === "ADMIN",
|
|
});
|
|
alert("注册成功");
|
|
if (localStorageUtils.getIsAdmin()) {
|
|
window.location.href = "/dashboard/admin/index";
|
|
} else {
|
|
window.location.href = "/dashboard/user/index";
|
|
}
|
|
} else {
|
|
alert("出错啦!");
|
|
}
|
|
} else {
|
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
|
}
|
|
}).catch(function (error) {
|
|
console.log(error);
|
|
alert("无法连接到服务器,请检查网络连接!");
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |