[Forntend] 登入 開發機與測試機程序判斷
This commit is contained in:
parent
730654dc66
commit
d943fb3fc5
@ -56,7 +56,7 @@
|
||||
<label class="custom-control-label" for="rememberme"> 記住我</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default float-right" onclick="Login(event)">登入</button>
|
||||
<button type="submit" class="btn btn-default float-right" onclick="Login(null,event)">登入</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="blankpage-footer text-center">
|
||||
@ -78,7 +78,7 @@
|
||||
<script src="lib/notifications/sweetalert2/sweetalert2.bundle.js"></script>-->
|
||||
<script src="lib/notifications/toastr/toastr.min.js"></script>
|
||||
<script src="js/toast.js"></script>
|
||||
|
||||
|
||||
|
||||
<!--Bajascript-->
|
||||
<script src="js/bajascript/bscriptReq.js"></script>
|
||||
@ -118,18 +118,20 @@
|
||||
[
|
||||
"init",
|
||||
|
||||
] ,loadedJsPack);
|
||||
], loadedJsPack);
|
||||
}
|
||||
|
||||
function loadedJsPack() {
|
||||
myBaja = new MyBaja();
|
||||
myBaja.setMyUserAccount(Login)
|
||||
if (location.href.indexOf("localhost:5966") == -1) {
|
||||
myBaja = new MyBaja();
|
||||
myBaja.setMyUserAccount(Login)
|
||||
}
|
||||
|
||||
if (localStorage.getItem('taipei-t') == 'true') {
|
||||
if (localStorage.getItem('mitsubishi-t') == 'true') {
|
||||
document.getElementById("rememberme").checked = true;
|
||||
remember = true;
|
||||
$("#account").val(atob(localStorage.getItem('taipei-a')));
|
||||
$("#password").val(atob(localStorage.getItem('taipei-p')));
|
||||
$("#account").val(atob(localStorage.getItem('mitsubishi-a')));
|
||||
$("#password").val(atob(localStorage.getItem('mitsubishi-p')));
|
||||
}
|
||||
else {
|
||||
document.getElementById("rememberme").checked = false;
|
||||
@ -167,81 +169,90 @@
|
||||
|
||||
$("#rememberme").click(function () {
|
||||
if (remember) {
|
||||
localStorage.setItem('taipei-t', 'false');
|
||||
localStorage.removeItem('taipei-a');
|
||||
localStorage.removeItem('taipei-p');
|
||||
localStorage.setItem('mitsubishi-t', 'false');
|
||||
localStorage.removeItem('mitsubishi-a');
|
||||
localStorage.removeItem('mitsubishi-p');
|
||||
remember = false;
|
||||
} else {
|
||||
localStorage.setItem('taipei-t', 'true');
|
||||
localStorage.setItem('taipei-a', btoa($("#account").val()));
|
||||
localStorage.setItem('taipei-p', btoa($("#password").val()));
|
||||
localStorage.setItem('mitsubishi-t', 'true');
|
||||
localStorage.setItem('mitsubishi-a', btoa($("#account").val()));
|
||||
localStorage.setItem('mitsubishi-p', btoa($("#password").val()));
|
||||
remember = true;
|
||||
}
|
||||
});
|
||||
|
||||
$("#account").change(function () {
|
||||
if (remember) {
|
||||
localStorage.setItem('taipei-a', btoa($("#account").val()));
|
||||
localStorage.setItem('mitsubishi-a', btoa($("#account").val()));
|
||||
} else {
|
||||
localStorage.removeItem('taipei-a');
|
||||
localStorage.removeItem('mitsubishi-a');
|
||||
}
|
||||
});
|
||||
|
||||
$("#password").change(function () {
|
||||
if (remember) {
|
||||
localStorage.setItem('taipei-p', btoa($("#password").val()));
|
||||
localStorage.setItem('mitsubishi-p', btoa($("#password").val()));
|
||||
} else {
|
||||
localStorage.removeItem('taipei-p');
|
||||
localStorage.removeItem('mitsubishi-p');
|
||||
}
|
||||
});
|
||||
|
||||
function Login(account) {
|
||||
|
||||
console.log(account)
|
||||
/*if ($("#login-form").valid()) {*/
|
||||
var url = baseApiUrl + "/api/Login/";
|
||||
var send_data = {
|
||||
account: account,
|
||||
password: "rJ2T5Kkj"
|
||||
}
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: url,
|
||||
data: JSON.stringify(send_data),
|
||||
async: false,
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
dataType: 'json',
|
||||
success: function (rel) {
|
||||
console.log(rel)
|
||||
$("#login-form").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
//rel = JSON.stringify(rel);
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg || "系統內部發生錯誤,請聯絡系統管理員");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
toast_ok(rel.msg);
|
||||
localStorage.setItem('JWT-Authorization', rel.data.token);
|
||||
location.href = "index.html";
|
||||
return;
|
||||
}
|
||||
},
|
||||
error: function (xhr, textStatus, thrownError) {
|
||||
alert(textStatus);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
function Login(account, e) {
|
||||
e ? e.preventDefault() : "";
|
||||
/*if ($("#login-form").valid()) {*/
|
||||
var url = baseApiUrl + "/api/Login/";
|
||||
var send_data = {
|
||||
account: account,
|
||||
password: "rJ2T5Kkj"
|
||||
}
|
||||
if (location.href.indexOf("localhost:5966") != -1) {
|
||||
send_data = {
|
||||
account: $("#account").val(),
|
||||
password: $("#password").val()
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: url,
|
||||
data: JSON.stringify(send_data),
|
||||
async: false,
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
dataType: 'json',
|
||||
success: function (rel) {
|
||||
console.log(rel)
|
||||
|
||||
//rel = JSON.stringify(rel);
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg || "系統內部發生錯誤,請聯絡系統管理員");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
toast_ok(rel.msg);
|
||||
localStorage.setItem('JWT-Authorization', rel.data.token);
|
||||
location.href = "index.html";
|
||||
return;
|
||||
}
|
||||
},
|
||||
error: function (xhr, textStatus, thrownError) {
|
||||
alert(textStatus);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
//#region 登入表單驗證
|
||||
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user