ah_jjzhgd_webscreen/js/login/login.js

67 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let form, layer;
layui.use(function () {
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=";
// window.location.href =isc_login+logUrl;
// return false;
form = layui.form;
layer = layui.layer;
form.on('submit(demo-login)', function (data) {
let field = data.field;
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"
}
const params = {
"username": field.username,
"password": field.password,
"loginType": loginType
}
let encryptStr = encryptCBC(JSON.stringify(params));
ajaxRequest(login_url, "POST", encryptStr, true, function () {
// $('.layui-btn-fluid').empty().append('<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>登录中,请稍后...').attr("disabled", true);
}, function (result) {
console.log(2);
console.log(result);
// $('.layui-btn-fluid').empty().append(' <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">登 录</button>');
if (result.code === 200) {
const uss= sm4.encryptDefault_CBC(result.data.us);
top.layer.msg(result.msg, { icon: 1, time: 500 }, function () {
sessionStorage.setItem("zhgd_token", result.data.access_token);
sessionStorage.setItem("zhgd_us", uss);
const us = JSON.parse(result.data.us);
localStorage.setItem("zhgd_type-noLogin",us.jumpType);
sessionStorage.setItem("zhgd_type", us.jumpType);
// window.location.href = "http://localhost:9528/#/ywgllogin?ticket=5555";
if (us.jumpType === '2') {
window.location.href = "pages/home/navigation.html";
} else if (us.jumpType === '1') {
window.location.href = "pages/web/index.html";
}
});
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}else if (result.code === 201) {
layer.msg(result.msg, { icon: 2 });
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
$('.layui-btn-fluid').empty().append('登 录');
}, "application/json", aqEnnable);
});
});
/* 请求错误 */
function errorFn(xhr, status, error) {
if (xhr.status === 0) {
// 网络连接失败
console.error("网络连接失败,请检查网络是否正常");
} else {
// 请求出现其他错误
console.error("ajax请求错误" + error);
}
}