初版登录界面

This commit is contained in:
zifan 2023-09-18 20:49:08 +08:00
parent e4a3241772
commit a2f0c2af1d
1 changed files with 51 additions and 0 deletions

51
www/login.html Executable file
View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="zifan">
<meta name="keywords" content="物联网">
<title>登录页面</title>
</head>
<body>
<form onsubmit="return login(this)">
<div>
<label>用户名</label>
<input name="name">
</div>
<div>
<label>&nbsp;&nbsp;&nbsp;</label>
<input name="pwd" type="password">
</div>
<div>
<button>登录</button>
</div>
</form>
<script>
function login(form) {
let login_data = {
name: form.name.value.trim(),
pwd: form.pwd.value.trim()
};
fetch("/cgi-bin/login.cgi", {
method: "POST",
body: JSON.stringify(login_data),
headers: {
"Content-Type": "application/json;charset=utf-8"
}
}).then(resp => resp.json()).then(data => {
console.log(data);
if (data.code == 0) {
open("/index.html", "_self");
} else {
alert(data.msg);
}
})
return false;
}
</script>
</body>
</html>