|
|
import __global from "./global.js";
|
|
|
let http = {
|
|
|
proxy: null,
|
|
|
isJson: function (obj) {
|
|
|
var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() ==
|
|
|
"[object object]" &&
|
...
|
...
|
@@ -14,23 +14,39 @@ let http = { |
|
|
window.top.location.reload();
|
|
|
//window.top.location.href = localStorage.getItem('loginUrl');
|
|
|
} else {
|
|
|
http.proxy.$global.showMsg("服务异常,请联系管理员!","error");
|
|
|
__global.showMsg("服务异常,请联系管理员!","error");
|
|
|
}
|
|
|
}catch (e){
|
|
|
}
|
|
|
},
|
|
|
post: function (requestUrl, data, callback, errFunc,showLoadding,setToken) {
|
|
|
if (http.proxy == null) {
|
|
|
const {proxy} = Vue.getCurrentInstance()
|
|
|
http.proxy = proxy;
|
|
|
getUrl: function (){
|
|
|
let gateWay = http.getGateWay();
|
|
|
if (gateWay && gateWay != null && gateWay != '') {
|
|
|
return;
|
|
|
}
|
|
|
http.get(window.location.origin + '/config/getConfig',{configName:'url'},function(res){
|
|
|
sessionStorage.setItem('domainName', res.gateway);
|
|
|
// sessionStorage.setItem('domainInspectionURI', res.inspection_web);
|
|
|
// sessionStorage.setItem('domainAssetsManage', res.assetsweb);
|
|
|
// sessionStorage.setItem('graphEditorOrigin', res.mxgraph_editor);
|
|
|
// sessionStorage.setItem('tingyun', res.tingyun);
|
|
|
// sessionStorage.setItem('bigScreen', res.bigScreen);
|
|
|
// sessionStorage.setItem('sxView', res.sxView);
|
|
|
// sessionStorage.setItem('workflow', res.workflow);
|
|
|
// sessionStorage.setItem('mp3', res.mp3);
|
|
|
// sessionStorage.setItem('jimuReport', res.jimuReport);
|
|
|
// sessionStorage.setItem('cmdbWeb', res.cmdbWeb);
|
|
|
})
|
|
|
},
|
|
|
post: function (requestUrl, data, callback, errFunc,showLoadding,setToken) {
|
|
|
|
|
|
// 默认展示加载狂
|
|
|
if(showLoadding == undefined){
|
|
|
showLoadding = true;
|
|
|
}
|
|
|
let loading = null;
|
|
|
if(showLoadding && showLoadding == true){
|
|
|
loading = http.proxy.$global.showLoading();
|
|
|
loading = __global.showLoading();
|
|
|
}
|
|
|
if(setToken == undefined || setToken == true){
|
|
|
var access_token = 'access_token=' + http.getToken();
|
...
|
...
|
@@ -41,7 +57,7 @@ let http = { |
|
|
}
|
|
|
}
|
|
|
$.ajax({
|
|
|
url: sessionStorage.getItem('domainName') + requestUrl,
|
|
|
url: http.getGateWay() + requestUrl,
|
|
|
method: "post",
|
|
|
processData: false,
|
|
|
contentType: "application/json;charset=UTF-8",
|
...
|
...
|
@@ -72,17 +88,14 @@ let http = { |
|
|
|
|
|
},
|
|
|
get: function (requestUrl, data, callback, errFunc,showLoadding,setToken) {
|
|
|
if (http.proxy == null) {
|
|
|
const {proxy} = Vue.getCurrentInstance()
|
|
|
http.proxy = proxy;
|
|
|
}
|
|
|
|
|
|
// 默认展示加载狂
|
|
|
if(showLoadding == undefined){
|
|
|
showLoadding = true;
|
|
|
}
|
|
|
let loading = null;
|
|
|
if(showLoadding == true){
|
|
|
loading = http.proxy.$global.showLoading();
|
|
|
loading = __global.showLoading();
|
|
|
}
|
|
|
let header = {};
|
|
|
if(setToken == undefined || setToken == true){
|
...
|
...
|
@@ -99,7 +112,7 @@ let http = { |
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
url: sessionStorage.getItem('domainName') + requestUrl,
|
|
|
url: http.getGateWay() + requestUrl,
|
|
|
method: "get",
|
|
|
headers: header,
|
|
|
data: data,
|
...
|
...
|
@@ -128,11 +141,7 @@ let http = { |
|
|
},
|
|
|
|
|
|
uploadFile(requestUrl, parmas,callback) {
|
|
|
if (http.proxy == null) {
|
|
|
const {proxy} = Vue.getCurrentInstance()
|
|
|
http.proxy = proxy;
|
|
|
}
|
|
|
const loading = http.proxy.$global.showLoading();
|
|
|
const loading = __global.showLoading();
|
|
|
var access_token = 'access_token=' + http.getToken();
|
|
|
if (requestUrl.indexOf('?') == -1) {
|
|
|
requestUrl += '?' + access_token;
|
...
|
...
|
@@ -146,7 +155,7 @@ let http = { |
|
|
})(parmas);
|
|
|
|
|
|
$.ajax({
|
|
|
url: sessionStorage.getItem('domainName') + requestUrl,
|
|
|
url: http.getGateWay() + requestUrl,
|
|
|
type: 'POST',
|
|
|
processData: false,
|
|
|
mimeType: "multipart/form-data",
|
...
|
...
|
@@ -157,7 +166,7 @@ let http = { |
|
|
loading.close();
|
|
|
// console.log("==>", requestUrl, xhr, textStatus)
|
|
|
http.reqErr(xhr);
|
|
|
http.proxy.$global.showMsg("上传失败,请您确认文件是否存在!","error");
|
|
|
__global.showMsg("上传失败,请您确认文件是否存在!","error");
|
|
|
|
|
|
},
|
|
|
success: function (data, textStatus, jqXHR) {
|
...
|
...
|
@@ -187,11 +196,16 @@ let http = { |
|
|
return `${keys}`;
|
|
|
}
|
|
|
let p = formart(parmas);
|
|
|
window.open(sessionStorage.getItem('domainName') + requestUrl + "&" + p);
|
|
|
window.open( http.getGateWay() + requestUrl + "&" + p);
|
|
|
},
|
|
|
getToken() {
|
|
|
return localStorage.getItem('access_token');
|
|
|
},
|
|
|
getGateWay () {
|
|
|
let gateway = sessionStorage.getItem('domainName');
|
|
|
return gateway == null ? '' : gateway;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取url
|
|
|
http.getUrl();
|
|
|
export default http |
...
|
...
|
|