let form, layer; layui.use(function () { // let isc_login="http://iscssotest.ah.sgcc.com.cn/isc_sso/login?service="; // let logUrl="http://27.50.49.56:8000/zhgd-web/sgIndex.html"; // 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; console.log(hrefUrl) if (hrefUrl && hrefUrl.indexOf("sg_login") > 0) { loginType = "2" } else if (hrefUrl && hrefUrl.indexOf("sc_login") > 0) { loginType = "1" }else{ loginType = "2" } const params = { "username": sm2Encrypt(public_key,field.username), "password": sm2Encrypt(public_key,field.password), "loginType": loginType } console.log(params) let encryptStr = encryptCBC(JSON.stringify(params)); ajaxRequest(login_url, "POST", encryptStr, true, function () { console.log(1) // $('.layui-btn-fluid').empty().append('登录中,请稍后...').attr("disabled", true); }, function (result) { // $('.layui-btn-fluid').empty().append(' '); 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{ window.location.href = "pages/home/navigation.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); } }