实现登录注册接口
Change-Id: I3d57cca89cac8945d562f6a39127b3454c1cd9ac
diff --git a/src/main/resources/static/login.html b/src/main/resources/static/login.html
new file mode 100644
index 0000000..993941d
--- /dev/null
+++ b/src/main/resources/static/login.html
@@ -0,0 +1,38 @@
+<!-- src/main/resources/static/login.html -->
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+ <meta charset="UTF-8">
+ <title>登录</title>
+</head>
+<body>
+<h2>用户登录</h2>
+<form id="loginForm">
+ <label>身份证号:</label>
+ <input type="number" name="identificationNumber" required>
+ <label>密码:</label>
+ <input type="password" name="password" required>
+ <button type="submit">登录</button>
+</form>
+<script>
+ document.getElementById('loginForm')
+ .addEventListener('submit', async e => {
+ e.preventDefault();
+ const form = new URLSearchParams(new FormData(e.target));
+ const res = await fetch('/login', {
+ method: 'POST',
+ body: form
+ });
+ const json = await res.json();
+ if (res.ok && json.code === 0) {
+ // 保存 token
+ localStorage.setItem('token', json.data);
+ // 跳转到受保护的页面
+ window.location.href = 'home.html';
+ } else {
+ alert(json.msg);
+ }
+ });
+</script>
+</body>
+</html>