mylomen-server/static/login_shuidi.html
shaoyongjun 0729ac880f to:sync
2024-10-02 12:04:55 +08:00

72 lines
2.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>水滴登录页</title>
<link rel="stylesheet" href="/v1/static/css/shuidi.css">
<style>
footer {
box-sizing: border-box;
text-align: center;
margin: 0;
padding: 0;
/*background-color: #457B9D;*/
}
</style>
</head>
<body>
<div class="box">
<div class="content">
<h2>登录</h2>
<div>
<input id="myAccount" type="text" placeholder="请输入用户名">
</div>
<div>
<input id="myPwd" type="password" placeholder="请输入密码">
</div>
<div>
<input type="submit" value="登录" onclick="toLogin()">
</div>
</div>
<a href="#" class="btns">忘记密码</a>
<a href="#" class="btns register">注册</a>
</div>
<footer>
<p>
<a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">沪ICP备18034819号</a>
<a href="https://beian.mps.gov.cn/" target="_blank" rel="nofollow"><i class="police-ico"></i>沪公网安备31011302007198号</a>
</p>
</footer>
</body>
<script>
async function toLogin() {
try {
let response = await fetch('/v1/user/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify({
account: document.getElementById('myAccount').value,
password: document.getElementById('myPwd').value
})
});
let result = await response.json()
console.log(result)
if (result.code === 0 && result.data !== undefined) {
console.log('登录成功');
localStorage.setItem("token", result.data.token);
// alert(localStorage.getItem("token"))
}
} catch (error) {
console.log('Request Failed', error);
alert("系统异常,请稍后再试");
}
}
</script>
</html>