abbott_2024_event/BackEnd/assets/javascript/custom/Login.js

55 lines
1.3 KiB
JavaScript

$(document).ready(function () {
if ($.UrlParam("isLogout") != "true") {
if ($.cookie("token_key") != null) {
if ($.cookie("token_key") != "") {
location.href = "/BackEnd/Index.aspx";
//alert("has token_key value :" + $.cookie("token_key"));
}
}
}
$('#login_btn').on('click', function () {
var id = $("#login_id").val();
var pwd = $("#login_pwd").val();
var err_msg = "";
if (id === "") {
err_msg += "請輸入帳號!\n";
}
if (pwd === "") {
err_msg += "請輸入密碼!\n";
}
if (err_msg !== "") {
alert(err_msg);
return;
}
pwd = sha256_digest(pwd);
var formData = {
id: id,
pwd: pwd
}
$.ajax({
url: "api/signin.ashx",
type: "POST",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
location.href = "Index.aspx";
} else {
alert(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('网絡或伺服器发生错误,请稍后重试!');
}
});
});
});