ah_jjzhgd_webscreen/js/login/login.js

67 lines
2.9 KiB
JavaScript
Raw Normal View History

2024-03-25 20:20:02 +08:00
let form, layer;
layui.use(function () {
2024-08-22 17:00:16 +08:00
let logUrl="http://27.50.49.56:21624/zhgd-web/scIndex.html";
let isc_login="http://iscssotest.ah.sgcc.com.cn/isc_sso/login?service=";
2024-09-13 14:52:05 +08:00
// window.location.href =isc_login+logUrl;
// return false;
2024-03-25 20:20:02 +08:00
form = layui.form;
layer = layui.layer;
form.on('submit(demo-login)', function (data) {
let field = data.field;
2024-03-26 19:52:42 +08:00
let loginType = "";
let hrefUrl = window.location.href;
if (hrefUrl && hrefUrl.indexOf("sg_login") > 0) {
loginType = "2"
} else if (hrefUrl && hrefUrl.indexOf("sc_login") > 0) {
loginType = "1"
}
2024-03-25 20:20:02 +08:00
const params = {
"username": field.username,
"password": field.password,
2024-03-26 19:52:42 +08:00
"loginType": loginType
2024-03-25 20:20:02 +08:00
}
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(login_url, "POST", encryptStr, true, function () {
2024-09-13 14:52:05 +08:00
2024-04-16 16:40:54 +08:00
// $('.layui-btn-fluid').empty().append('<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>登录中,请稍后...').attr("disabled", true);
2024-03-25 20:20:02 +08:00
}, function (result) {
2024-09-13 14:52:05 +08:00
console.log(2);
console.log(result);
2024-04-16 16:40:54 +08:00
// $('.layui-btn-fluid').empty().append(' <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">登 录</button>');
2024-03-25 20:20:02 +08:00
if (result.code === 200) {
2024-09-13 19:52:24 +08:00
const uss= sm4.encryptDefault_CBC(result.data.us);
2024-03-26 19:52:42 +08:00
top.layer.msg(result.msg, { icon: 1, time: 500 }, function () {
sessionStorage.setItem("zhgd_token", result.data.access_token);
2024-09-13 19:52:24 +08:00
sessionStorage.setItem("zhgd_us", uss);
2024-03-26 19:52:42 +08:00
const us = JSON.parse(result.data.us);
2024-06-11 11:16:54 +08:00
localStorage.setItem("zhgd_type-noLogin",us.jumpType);
2024-03-26 19:52:42 +08:00
sessionStorage.setItem("zhgd_type", us.jumpType);
2024-08-22 17:00:16 +08:00
// window.location.href = "http://localhost:9528/#/ywgllogin?ticket=5555";
2024-03-26 19:52:42 +08:00
if (us.jumpType === '2') {
window.location.href = "pages/home/navigation.html";
} else if (us.jumpType === '1') {
window.location.href = "pages/web/index.html";
}
2024-03-25 20:20:02 +08:00
});
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
2024-04-16 16:40:54 +08:00
}else if (result.code === 201) {
layer.msg(result.msg, { icon: 2 });
2024-03-25 20:20:02 +08:00
}
2024-03-29 15:25:34 +08:00
}, function (xhr, status, error) {
2024-04-22 13:02:16 +08:00
errorFn(xhr, status, error)
2024-04-03 13:52:23 +08:00
$('.layui-btn-fluid').empty().append('登 录');
}, "application/json", aqEnnable);
2024-03-25 20:20:02 +08:00
});
2024-04-22 13:02:16 +08:00
});
/* 请求错误 */
function errorFn(xhr, status, error) {
if (xhr.status === 0) {
// 网络连接失败
console.error("网络连接失败,请检查网络是否正常");
} else {
// 请求出现其他错误
console.error("ajax请求错误" + error);
}
}