初始化

This commit is contained in:
2025-11-26 11:18:26 +08:00
commit 0564b8c1f3
579 changed files with 346253 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
let ajxjsum = 0;
// 判断是否未定义 或者 null
function IsUndefined(obj) {
return typeof obj === 'undefined' || obj == null;
}
let tc = null;
function MyPost(url, data, back, badback, completeback) {
if (IsUndefined(data) || IsUndefined(data.isSwal) || data.isSwal != false) {
ajxjsum++;
tc = Swal.fire({
onClose: (elm) => {
if (!(IsUndefined(completeback))) {
completeback();
}
},
title: '',
html: !(IsUndefined(data) || IsUndefined(data.title)) ? data.title : '加载中...',
showConfirmButton: false,
allowOutsideClick: false,
showCancelButton: false,
onBeforeOpen: () => {
Swal.showLoading()
}
})
}
try {
if ((!IsUndefined(data) && !IsUndefined(data.type) && data.type == 1)) {
$.ajax({
type: "post",
url: url,
cache: false,
processData: false,
contentType: false,
data: !(IsUndefined(data) || IsUndefined(data.data))?data.data : {},
"success": function (res) {
// 已经失去登录信息 刷新界面重新登录
if (typeof (res) == 'string' && res.indexOf("<title>BLV RCU | 登录</title>") > -1) {
location.reload();
}
if (!(IsUndefined(back))) {
try {
back(res);
} catch (e) {
console.log("bad - err");
}
}
},
"error": function (xmlhttp, errorText) {
if (!(IsUndefined(badback))) {
try {
badback(errorText);
} catch (e) {
console.log("badback - err");
}
}
},
"complete": function (XMLHttpRequest, status) {
if (IsUndefined(data) || IsUndefined(data.isSwal) || data.isSwal != false) {
ajxjsum--;
}
/// 动画不突兀
if (ajxjsum == 0) {
if (ajxjsum == 0 && tc != null) {
tc.close();
}
}
},
})
return;
}
$.ajax({
"url": url,
"type": 'POST',
"data": !(IsUndefined(data) || IsUndefined(data.data)) ? data.data : {},
"success": function (res) {
// 已经失去登录信息 刷新界面重新登录
if (typeof (res) == 'string' && res.indexOf("<title>BLV RCU | 登录</title>") > -1) {
location.reload();
}
if (!(IsUndefined(back))) {
try {
back(res);
} catch (e) {
console.log(e)
}
}
},
"error": function (xmlhttp, errorText) {
if (!(IsUndefined(badback))) {
try {
badback(errorText);
} catch (e) {
}
}
},
"complete": function (XMLHttpRequest, status) {
if (IsUndefined(data) || IsUndefined(data.isSwal) || data.isSwal != false) {
ajxjsum--;
}
if (ajxjsum == 0 && tc != null) {
tc.close();
}
}
})
} catch (e) {
console.log(e)
ajxjsum--;
if (!(IsUndefined(badback))) {
badback(e);
}
} finally {
if (ajxjsum < 0) {
ajxjsum = 0;
}
}
}