AudioHTML/login.html

158 lines
5.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/app.css" rel="stylesheet">
<script src="js/config.js"></script>
<script src="js/jquery-3.7.1.js"></script>
</head>
<body class="d-flex h-100 text-center text-bg-dark">
<div class="d-flex w-100 h-100 mx-auto flex-column">
<header class="mb-auto">
<!-- <div>
<h3 class="float-md-start mb-0">Cover</h3>
<nav class="nav nav-masthead justify-content-center float-md-end">
<a class="nav-link fw-bold py-1 px-0 active" aria-current="page" href="#">Home</a>
<a class="nav-link fw-bold py-1 px-0" href="#">Features</a>
<a class="nav-link fw-bold py-1 px-0" href="#">Contact</a>
</nav>
</div> -->
</header>
<main class="px-3 d-flex justify-content-center">
<div class="border border-black login">
<div class="dotblock py-3 login-title">GEAZAN</div>
<div class="login-form pt-5 mx-auto">
<div class="mb-4 input-group input-group-lg">
<input class="form-control" id="name" placeholder="Username" />
</div>
<div class="mb-5 input-group input-group-lg">
<input type="password" class="form-control" id="password" placeholder="Password" />
</div>
<div class="mt-5 pb-5 d-grid">
<button type="button" id="submit" class="btn btn-lg btn-dark border border-black">LOGIN</button>
</div>
<div class="mt-5 mb-3" style="color: #888888;">
<div>GUI <span id="guiv">V1.0.0</span>
</div>
<div>FIRMWARE <span id="firmwarev">V1.0.0</span></div>
</div>
</div>
</div>
<!-- <h1>Cover your page.</h1>
<p class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit
the text, and add your own fullscreen background photo to make it your own.</p>
<p class="lead">
<a href="#" class="btn btn-lg btn-light fw-bold border-white bg-white">Learn more</a>
</p> -->
</main>
<footer class="mt-auto text-white-50">
<div class="dotblock d-flex justify-content-between px-5 py-4">
<div class="">Geazan</div>
<div>www.geazan.com</div>
</div>
</footer>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
//初始化配置
loadData()
})
$(document).ready(function () {
console.log('ready', $("#name").val())
window.focus()
$("#name").focus()
var alertState = sessionStorage.getItem('alert')
if (alertState == 'alert') {
sessionStorage.removeItem('alert');
console.log('重新跳转')
window.location.href = 'login.html?t=' + new Date().getTime()
}
$("#submit").on("click", function () {
let name = $("#name").val()
let password = $("#password").val()
if (name.length == 0) {
sessionStorage.setItem('alert', 'alert');
alert('Please enter your username')
return
}
if (password.length == 0) {
sessionStorage.setItem('alert', 'alert');
alert('Please enter the account login password')
return
}
let url = '/cgi-bin/test.cgi';
let postData = {
action: 'login_set',
name: name,
password: password
}
$.ajax({
type: 'POST',
url: url,
data: postData,
dataType: "json",
//contentType: "application/json; charset=utf-8",
success: function (res) {
if (res.success) {
// alert('Login successful')
window.location.href = "/home.html"
}
else {
alert(res.message)
sessionStorage.setItem('alert', 'alert');
return
}
},
error: function (res) {
alert('error')
// sessionStorage.setItem('state', 'logined');
// window.location.href = "home.html"
}
})
})
})
function loadData() {
let url = "http://192.168.0.116/cgi-bin/test.cgi?action=system_get"
$.ajax({
type: "GET",
url: url,
success: function (res) {
data = res.content
bindData()
},
error: function () {
data = {
gui: "v1.0.2",
firmware: "v1.0.0",
sn: "SN-2343-123-NNDD",
hostname: "Test.Hostname"
}
bindData()
}
})
}
function bindData() {
$("#guiv").text(`${data.gui}`)
$("#firmwarev").text(`${data.firmware}`)
$("#sn").text(`${data.sn}`)
$("#hostName").text(`${data.hostname}`)
}
</script>
<script src="js/main.js"></script>
</body>
</html>