公共js修改

This commit is contained in:
cwchen 2024-03-29 15:25:34 +08:00
parent ac52b9abae
commit 10f9ca2fc7
3 changed files with 36 additions and 9 deletions

View File

@ -1,15 +1,15 @@
let aqEnnable = false;// 参数加密开关
const commonUrl = "http://10.40.92.106:18080/zhgd/";
let aqEnnable = true // 参数加密开关
const commonUrl = "http://10.40.92.33:18080/zhgd/";
/* 登录相关 */
const login_url = commonUrl + "auth/login"; // 登录url
const login_out = commonUrl + "auth/logout"; // 登出url
const page_jump = commonUrl + "auth/pageJump"; // 登出url
const login_sg_page = "http://10.40.92.106:8101/sg_login.html" // 施工大屏登录页面
const login_sc_page = "http://10.40.92.106:8100/sc_login.html" // 省侧大屏登录页面
const login_sg_index = "http://10.40.92.106:8101/pages/home/navigation.html" // 施工大屏首页
const login_sc_index = "http://10.40.92.106:8100/pages/web/index.html" // 省侧大屏首页
const login_sg_page = "http://10.40.92.33:8101/sg_login.html" // 施工大屏登录页面
const login_sc_page = "http://10.40.92.33:8100/sc_login.html" // 省侧大屏登录页面
const login_sg_index = "http://10.40.92.33:8101/pages/home/navigation.html" // 施工大屏首页
const login_sc_index = "http://10.40.92.33:8100/pages/web/index.html" // 省侧大屏首页
// ajax 请求封装
/* POST 请求 */
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType) {
$.ajax({
url: url,
@ -37,4 +37,20 @@ function ajaxRequest2(url, type, token, successFn, errorFn) {
success: successFn,
error: errorFn
});
}
/* GET请求 */
function ajaxRequestGet(url, type, data, async, beforeFn, successFn, errorFn) {
$.ajax({
url: url,
type: type,
headers: {
"authorization": sessionStorage.getItem("zhgd_token")
},
data: data,
async: async,
beforeSend: beforeFn,
success: successFn,
error: errorFn
});
}

View File

@ -35,8 +35,8 @@ layui.use(function () {
} else if (result.code === 500) {
layer.msg(result.msg, { icon: 2 });
}
}, function (xhr) {
error(xhr)
}, function (xhr, status, error) {
error(xhr, status, error)
}, "application/json");
});
});

View File

@ -4,6 +4,7 @@ const zhgd_type = sessionStorage.getItem("zhgd_type");
const roleCode = JSON.parse(us).roleCode;
const orgId = JSON.parse(us).orgId;
const userId = JSON.parse(us).userId;
/* 退出登录 */
function loginout(type) {
if (type) {
@ -53,6 +54,16 @@ function loginout(type) {
});
}
}
/* 请求错误 */
function error(xhr, status, error) {
if (xhr.status === 0) {
// 网络连接失败
console.error("网络连接失败,请检查网络是否正常");
} else {
// 请求出现其他错误
console.error("ajax请求错误" + error);
}
}
/* 返回登录页 */
function backLoginPage() {