1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-05 00:21:38 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
bookshelfplus/bookshelfplus-frontend/views/register.html

105 lines
3.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>
<script>
if(!localStorage) {
alert("您的浏览器不支持localStorage请更换浏览器");
window.location.href = "/";
}
</script>
</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>
$("#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) {
localStorage.setItem("token", data.token);
alert("注册成功");
if(data.group === "ADMIN") {
localStorage.setItem("is_admin", "true");
window.location.href = "/dashboard/admin/index";
} else {
localStorage.setItem("is_admin", "false");
window.location.href = "/dashboard/user/index";
}
} else {
alert("出错啦!");
}
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
}
}).catch(function (error) {
console.log(error);
});
});
</script>
</body>
</html>