ah_jjzhgd_webscreen/api/commonRequest.js

81 lines
2.4 KiB
JavaScript
Raw Normal View History

2024-04-23 18:23:20 +08:00
let aqEnnable = true // 参数加密开关
2024-04-16 16:40:54 +08:00
//后端路径
2024-04-23 18:23:20 +08:00
const commonUrl = "http://192.168.0.14:18080/zhgd/";
2024-04-16 16:40:54 +08:00
//前端路径
2024-04-23 18:23:20 +08:00
const URL_IP="http://192.168.0.14:21624/zhgd-web"
2024-03-25 20:21:14 +08:00
/* 登录相关 */
const login_url = commonUrl + "auth/login"; // 登录url
const login_out = commonUrl + "auth/logout"; // 登出url
2024-03-26 19:52:42 +08:00
const page_jump = commonUrl + "auth/pageJump"; // 登出url
2024-04-16 16:40:54 +08:00
const login_sg_page = URL_IP+"/sg_login.html" // 施工大屏登录页面
const login_sc_page = URL_IP+"/sc_login.html" // 省侧大屏登录页面
const login_sg_index = URL_IP+"/pages/home/navigation.html" // 施工大屏首页
const login_sc_index = URL_IP+"/pages/web/index.html" // 省侧大屏首页
2024-03-25 20:21:14 +08:00
2024-03-29 15:25:34 +08:00
/* POST 请求 */
2024-04-09 18:05:53 +08:00
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType, isAes) {
2024-03-25 20:20:02 +08:00
$.ajax({
url: url,
type: type,
headers: {
2024-04-01 09:12:20 +08:00
"authorization": sessionStorage.getItem("zhgd_token"),
"decrypt": isAes ? '' : 'decrypt'
2024-03-25 20:20:02 +08:00
},
data: data,
async: async,
beforeSend: beforeFn,
contentType: contentType || "application/x-www-form-urlencoded; charset=utf-8",
success: successFn,
error: errorFn
});
2024-03-26 19:52:42 +08:00
}
/* 施工大屏跳转 ajax请求封装 */
function ajaxRequest2(url, type, token, successFn, errorFn) {
$.ajax({
url: url,
type: type,
headers: {
2024-04-09 18:05:53 +08:00
"authorization": token,
"decrypt": 'decrypt'
2024-03-26 19:52:42 +08:00
},
success: successFn,
error: errorFn
});
2024-03-29 15:25:34 +08:00
}
/* GET请求 */
2024-04-01 09:12:20 +08:00
function ajaxRequestGet(url, type, async, beforeFn, successFn, errorFn, isAes) {
2024-03-29 15:25:34 +08:00
$.ajax({
url: url,
type: type,
headers: {
2024-04-01 09:12:20 +08:00
"authorization": sessionStorage.getItem("zhgd_token"),
"decrypt": isAes ? '' : 'decrypt'
2024-03-29 15:25:34 +08:00
},
2024-04-09 18:05:53 +08:00
async: async,
beforeSend: beforeFn,
success: successFn,
error: errorFn
});
}
/* GET请求 */
function ajaxRequestGetExport(url, type, async, beforeFn, successFn, errorFn, isAes) {
$.ajax({
url: url,
type: type,
headers: {
"authorization": sessionStorage.getItem("zhgd_token"),
"decrypt": isAes ? '' : 'decrypt'
},
xhrFields: {
responseType: 'blob' // 告诉 xhr 我们期望返回的数据类型是 blob
},
2024-04-01 19:49:28 +08:00
async: async,
beforeSend: beforeFn,
success: successFn,
error: errorFn
});
2024-03-25 20:20:02 +08:00
}