初版登录界面
This commit is contained in:
parent
e4a3241772
commit
a2f0c2af1d
|
@ -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>口 令</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>
|
Loading…
Reference in New Issue