|
@@ -148,8 +148,6 @@ const post = function (url, data, opts) {
|
|
if (!token && window.location.href.indexOf('login') == -1) {
|
|
if (!token && window.location.href.indexOf('login') == -1) {
|
|
setCookie('behosDateStart', '');
|
|
setCookie('behosDateStart', '');
|
|
setCookie('behosDateEnd', '');
|
|
setCookie('behosDateEnd', '');
|
|
- //alert('无token判断,跳回登录')
|
|
|
|
- // window.location.href = '../login.html';
|
|
|
|
}
|
|
}
|
|
for (let i = 0; i < $('.typeFilter').children().length; i++) {
|
|
for (let i = 0; i < $('.typeFilter').children().length; i++) {
|
|
if (
|
|
if (
|
|
@@ -186,123 +184,32 @@ const post = function (url, data, opts) {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
success: function (res) {
|
|
success: function (res) {
|
|
-
|
|
|
|
- const json = res
|
|
|
|
- let jsonres = null
|
|
|
|
- if (typeof (json) === 'string') {
|
|
|
|
- jsonres = JSON.parse(json)
|
|
|
|
- } else {
|
|
|
|
- jsonres = {
|
|
|
|
- ...json
|
|
|
|
- }
|
|
|
|
|
|
+ if(res.code==="0"){
|
|
|
|
+ resolve({
|
|
|
|
+ data: res
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
-
|
|
|
|
- let dialogcode = jsonres.code === '10020011' || jsonres.code === '10020012' || jsonres.code === '10020013'
|
|
|
|
- if (jsonres.code && dialogcode) {
|
|
|
|
- localStorage.removeItem('accessToken')
|
|
|
|
- console.log('token已清除1')
|
|
|
|
- $.alerModal({
|
|
|
|
- gobackBtn: true,
|
|
|
|
- title: "提示",
|
|
|
|
- type: "modal",
|
|
|
|
- width: '470',
|
|
|
|
- time: 1000,
|
|
|
|
- cancalText: '我知道了',
|
|
|
|
- isFather: true,
|
|
|
|
- fatherWrapper: $("#mainBox", parent.document),
|
|
|
|
- sureBtn: false,
|
|
|
|
- message: jsonres.msg || '登录过期',
|
|
|
|
- callback: function () {
|
|
|
|
-
|
|
|
|
- //alert('跳回登录2')
|
|
|
|
- // localStorage.removeItem('accessToken')
|
|
|
|
- // if (window.parent) {
|
|
|
|
- // window.parent.window.location.href = 'login.html'
|
|
|
|
- // } else {
|
|
|
|
- // window.location.href = 'login.html'
|
|
|
|
- // }
|
|
|
|
- window.parent.window.location.href = 'login.html'
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else if (jsonres.code && dialogcode && (self != top)) {
|
|
|
|
- localStorage.removeItem('accessToken')
|
|
|
|
- console.log('token已清除2')
|
|
|
|
- const dialogmessage = {
|
|
|
|
- iframemessage: 1,
|
|
|
|
- data: jsonres.msg
|
|
|
|
- }
|
|
|
|
- window.parent.postMessage(JSON.stringify(dialogmessage), '*')
|
|
|
|
- }
|
|
|
|
- resolve({
|
|
|
|
- data: res
|
|
|
|
- });
|
|
|
|
|
|
+ //登录信息失效处理
|
|
|
|
+ unloginPop(res.code);
|
|
},
|
|
},
|
|
error: function (error) {
|
|
error: function (error) {
|
|
- const errorCode = {
|
|
|
|
- ...error.responseJSON
|
|
|
|
- }
|
|
|
|
- //const wd = window.parent.window || window;
|
|
|
|
- // if (jsonres.code && (jsonres.code === '10020011' || jsonres.code === '00020007') && (self != top)) {
|
|
|
|
- // let dialog = 'true'
|
|
|
|
- // window.parent.postMessage(dialog, '*')
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
- let dialogcode2 = errorCode.code === '10020011' || errorCode.code === '10020012' || errorCode.code === '10020013'
|
|
|
|
-
|
|
|
|
- if (errorCode.code && dialogcode2 && (self == top)) {
|
|
|
|
- localStorage.removeItem('accessToken')
|
|
|
|
- console.log('token已清除3')
|
|
|
|
- $.alerModal({
|
|
|
|
- gobackBtn: true,
|
|
|
|
- title: "提示",
|
|
|
|
- type: "modal",
|
|
|
|
- width: '470',
|
|
|
|
- time: 1000,
|
|
|
|
- cancalText: '我知道了',
|
|
|
|
- isFather: true,
|
|
|
|
- fatherWrapper: $("#mainBox", parent.document),
|
|
|
|
- sureBtn: false,
|
|
|
|
- message: errorCode.msg || '登录过期',
|
|
|
|
- callback: function () {
|
|
|
|
- //alert('跳回登录1')
|
|
|
|
-
|
|
|
|
- // if (window.parent) {
|
|
|
|
- // window.parent.window.location.href = 'login.html'
|
|
|
|
- // } else {
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
- //localStorage.removeItem('accessToken')
|
|
|
|
- window.location.href = 'login.html'
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- if (errorCode.code && dialogcode2 && (self != top)) {
|
|
|
|
- localStorage.removeItem('accessToken')
|
|
|
|
- const dialogmessage = {
|
|
|
|
- iframemessage: 1,
|
|
|
|
- data: errorCode.msg
|
|
|
|
- }
|
|
|
|
- window.parent.postMessage(JSON.stringify(dialogmessage), '*')
|
|
|
|
- }
|
|
|
|
if (error.status === 403 || error.status === 401) {
|
|
if (error.status === 403 || error.status === 401) {
|
|
setCookie('behosDateStart', '');
|
|
setCookie('behosDateStart', '');
|
|
setCookie('behosDateEnd', '');
|
|
setCookie('behosDateEnd', '');
|
|
if (!token && window.location.href.indexOf('login') == -1) {
|
|
if (!token && window.location.href.indexOf('login') == -1) {
|
|
- //alert('无token判断,跳回登录')
|
|
|
|
- // window.location.href = '../login.html';
|
|
|
|
} else {
|
|
} else {
|
|
if($(".alertModal:visible").length){
|
|
if($(".alertModal:visible").length){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
$.alerModal({
|
|
$.alerModal({
|
|
- "message": "没有该权限",
|
|
|
|
|
|
+ "message": "没有该权限"+error.status,
|
|
type: "tip",
|
|
type: "tip",
|
|
time: '1000',
|
|
time: '1000',
|
|
isFather: true,
|
|
isFather: true,
|
|
fatherWrapper: $("#mainBox", parent.document)
|
|
fatherWrapper: $("#mainBox", parent.document)
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- // wd.location.href = "../login.html";
|
|
|
|
} else if (error.status === 500 || error.status === 501 || error.status === 404) {
|
|
} else if (error.status === 500 || error.status === 501 || error.status === 404) {
|
|
$.alerModal({
|
|
$.alerModal({
|
|
"message": '接口错误',
|
|
"message": '接口错误',
|
|
@@ -311,16 +218,44 @@ const post = function (url, data, opts) {
|
|
isFather: true,
|
|
isFather: true,
|
|
fatherWrapper: $("#mainBox", parent.document)
|
|
fatherWrapper: $("#mainBox", parent.document)
|
|
});
|
|
});
|
|
-
|
|
|
|
- // wd.location.href = '../error.html?code=' + error.status;
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
reject(error);
|
|
reject(error);
|
|
},
|
|
},
|
|
});
|
|
});
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+//登录失效弹窗处理
|
|
|
|
+function unloginPop(code){
|
|
|
|
+ const isOut = code === '10020011' || code === '10020012' || code === '10020013';
|
|
|
|
+ if(isOut){
|
|
|
|
+ if(self != top){
|
|
|
|
+ const dialogmessage = {
|
|
|
|
+ iframemessage: 1,
|
|
|
|
+ data: errorCode.msg
|
|
|
|
+ }
|
|
|
|
+ window.parent.postMessage(JSON.stringify(dialogmessage), '*')
|
|
|
|
+ }else{
|
|
|
|
+ $.alerModal({
|
|
|
|
+ gobackBtn: true,
|
|
|
|
+ title: "提示",
|
|
|
|
+ type: "modal",
|
|
|
|
+ width: '470',
|
|
|
|
+ time: 1000,
|
|
|
|
+ cancalText: '我知道了',
|
|
|
|
+ isFather: true,
|
|
|
|
+ fatherWrapper: $("#mainBox", parent.document),
|
|
|
|
+ sureBtn: false,
|
|
|
|
+ message: errorCode.msg || '登录过期',
|
|
|
|
+ callback: function () {
|
|
|
|
+ window.location.href = 'login.html'
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
// 导出
|
|
// 导出
|
|
const expJson = (url, data) => {
|
|
const expJson = (url, data) => {
|
|
const token = localStorage.getItem('accessToken');
|
|
const token = localStorage.getItem('accessToken');
|