2024-07-17 17:28:54 +08:00
|
|
|
$(window).ready(function () {
|
|
|
|
|
let token = localStorage.getItem("token");
|
|
|
|
|
let url_path = window.location.pathname;
|
|
|
|
|
if (url_path.indexOf("login.html") == -1) {
|
|
|
|
|
if (token) {
|
|
|
|
|
getAjaxRequst("/api/Check/GetUserProfile",{}, function (res) {
|
|
|
|
|
console.log('res::: ', res);
|
|
|
|
|
console.log('res::: ', res);
|
|
|
|
|
if (res.code != 200) {
|
|
|
|
|
toastr.error("登录信息已过期,请重新登录");
|
|
|
|
|
localStorage.removeItem("token");
|
|
|
|
|
window.location.href = "login.html";
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.setItem("account", res.result.account);
|
|
|
|
|
localStorage.setItem("name", res.result.name);
|
|
|
|
|
$("#user-name").text(res.result.name);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
toastr.error("请先登录");
|
|
|
|
|
window.location.href = "login.html";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 15:42:30 +08:00
|
|
|
// Place JavaScript code here.
|
|
|
|
|
$("#login-btn").click(function () {
|
|
|
|
|
let account = $("#login-mobile").val();
|
|
|
|
|
let password = $("#login-pwd").val();
|
|
|
|
|
if (account && password) {
|
|
|
|
|
postAjaxRequst(
|
|
|
|
|
"/api/Check/Login",
|
|
|
|
|
{ account: account, password: password, appKey: "openauth" },
|
|
|
|
|
function (res) {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
toastr.success(res.message);
|
|
|
|
|
localStorage.setItem("token", res.token);
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
window.location.href = "index.html";
|
|
|
|
|
}, 1000);
|
|
|
|
|
} else {
|
|
|
|
|
toastr.error(res.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
alert("Please fill all the fields");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|