Merge branch 'master' of http://192.168.1.136:82/monitor_v3/hg-monitor-web into …
…master-v32-lushangqing
Showing
1 changed file
with
37 additions
and
23 deletions
1 | +import __global from "./global.js"; | ||
1 | let http = { | 2 | let http = { |
2 | - proxy: null, | ||
3 | isJson: function (obj) { | 3 | isJson: function (obj) { |
4 | var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == | 4 | var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == |
5 | "[object object]" && | 5 | "[object object]" && |
@@ -14,23 +14,39 @@ let http = { | @@ -14,23 +14,39 @@ let http = { | ||
14 | window.top.location.reload(); | 14 | window.top.location.reload(); |
15 | //window.top.location.href = localStorage.getItem('loginUrl'); | 15 | //window.top.location.href = localStorage.getItem('loginUrl'); |
16 | } else { | 16 | } else { |
17 | - http.proxy.$global.showMsg("服务异常,请联系管理员!","error"); | 17 | + __global.showMsg("服务异常,请联系管理员!","error"); |
18 | } | 18 | } |
19 | }catch (e){ | 19 | }catch (e){ |
20 | } | 20 | } |
21 | }, | 21 | }, |
22 | + getUrl: function (){ | ||
23 | + let gateWay = http.getGateWay(); | ||
24 | + if (gateWay && gateWay != null && gateWay != '') { | ||
25 | + return; | ||
26 | + } | ||
27 | + http.get(window.location.origin + '/config/getConfig',{configName:'url'},function(res){ | ||
28 | + sessionStorage.setItem('domainName', res.gateway); | ||
29 | + // sessionStorage.setItem('domainInspectionURI', res.inspection_web); | ||
30 | + // sessionStorage.setItem('domainAssetsManage', res.assetsweb); | ||
31 | + // sessionStorage.setItem('graphEditorOrigin', res.mxgraph_editor); | ||
32 | + // sessionStorage.setItem('tingyun', res.tingyun); | ||
33 | + // sessionStorage.setItem('bigScreen', res.bigScreen); | ||
34 | + // sessionStorage.setItem('sxView', res.sxView); | ||
35 | + // sessionStorage.setItem('workflow', res.workflow); | ||
36 | + // sessionStorage.setItem('mp3', res.mp3); | ||
37 | + // sessionStorage.setItem('jimuReport', res.jimuReport); | ||
38 | + // sessionStorage.setItem('cmdbWeb', res.cmdbWeb); | ||
39 | + }) | ||
40 | + }, | ||
22 | post: function (requestUrl, data, callback, errFunc,showLoadding,setToken) { | 41 | post: function (requestUrl, data, callback, errFunc,showLoadding,setToken) { |
23 | - if (http.proxy == null) { | ||
24 | - const {proxy} = Vue.getCurrentInstance() | ||
25 | - http.proxy = proxy; | ||
26 | - } | 42 | + |
27 | // 默认展示加载狂 | 43 | // 默认展示加载狂 |
28 | if(showLoadding == undefined){ | 44 | if(showLoadding == undefined){ |
29 | showLoadding = true; | 45 | showLoadding = true; |
30 | } | 46 | } |
31 | let loading = null; | 47 | let loading = null; |
32 | if(showLoadding && showLoadding == true){ | 48 | if(showLoadding && showLoadding == true){ |
33 | - loading = http.proxy.$global.showLoading(); | 49 | + loading = __global.showLoading(); |
34 | } | 50 | } |
35 | if(setToken == undefined || setToken == true){ | 51 | if(setToken == undefined || setToken == true){ |
36 | var access_token = 'access_token=' + http.getToken(); | 52 | var access_token = 'access_token=' + http.getToken(); |
@@ -41,7 +57,7 @@ let http = { | @@ -41,7 +57,7 @@ let http = { | ||
41 | } | 57 | } |
42 | } | 58 | } |
43 | $.ajax({ | 59 | $.ajax({ |
44 | - url: sessionStorage.getItem('domainName') + requestUrl, | 60 | + url: http.getGateWay() + requestUrl, |
45 | method: "post", | 61 | method: "post", |
46 | processData: false, | 62 | processData: false, |
47 | contentType: "application/json;charset=UTF-8", | 63 | contentType: "application/json;charset=UTF-8", |
@@ -72,17 +88,14 @@ let http = { | @@ -72,17 +88,14 @@ let http = { | ||
72 | 88 | ||
73 | }, | 89 | }, |
74 | get: function (requestUrl, data, callback, errFunc,showLoadding,setToken) { | 90 | get: function (requestUrl, data, callback, errFunc,showLoadding,setToken) { |
75 | - if (http.proxy == null) { | ||
76 | - const {proxy} = Vue.getCurrentInstance() | ||
77 | - http.proxy = proxy; | ||
78 | - } | 91 | + |
79 | // 默认展示加载狂 | 92 | // 默认展示加载狂 |
80 | if(showLoadding == undefined){ | 93 | if(showLoadding == undefined){ |
81 | showLoadding = true; | 94 | showLoadding = true; |
82 | } | 95 | } |
83 | let loading = null; | 96 | let loading = null; |
84 | if(showLoadding == true){ | 97 | if(showLoadding == true){ |
85 | - loading = http.proxy.$global.showLoading(); | 98 | + loading = __global.showLoading(); |
86 | } | 99 | } |
87 | let header = {}; | 100 | let header = {}; |
88 | if(setToken == undefined || setToken == true){ | 101 | if(setToken == undefined || setToken == true){ |
@@ -99,7 +112,7 @@ let http = { | @@ -99,7 +112,7 @@ let http = { | ||
99 | } | 112 | } |
100 | 113 | ||
101 | $.ajax({ | 114 | $.ajax({ |
102 | - url: sessionStorage.getItem('domainName') + requestUrl, | 115 | + url: http.getGateWay() + requestUrl, |
103 | method: "get", | 116 | method: "get", |
104 | headers: header, | 117 | headers: header, |
105 | data: data, | 118 | data: data, |
@@ -128,11 +141,7 @@ let http = { | @@ -128,11 +141,7 @@ let http = { | ||
128 | }, | 141 | }, |
129 | 142 | ||
130 | uploadFile(requestUrl, parmas,callback) { | 143 | uploadFile(requestUrl, parmas,callback) { |
131 | - if (http.proxy == null) { | ||
132 | - const {proxy} = Vue.getCurrentInstance() | ||
133 | - http.proxy = proxy; | ||
134 | - } | ||
135 | - const loading = http.proxy.$global.showLoading(); | 144 | + const loading = __global.showLoading(); |
136 | var access_token = 'access_token=' + http.getToken(); | 145 | var access_token = 'access_token=' + http.getToken(); |
137 | if (requestUrl.indexOf('?') == -1) { | 146 | if (requestUrl.indexOf('?') == -1) { |
138 | requestUrl += '?' + access_token; | 147 | requestUrl += '?' + access_token; |
@@ -146,7 +155,7 @@ let http = { | @@ -146,7 +155,7 @@ let http = { | ||
146 | })(parmas); | 155 | })(parmas); |
147 | 156 | ||
148 | $.ajax({ | 157 | $.ajax({ |
149 | - url: sessionStorage.getItem('domainName') + requestUrl, | 158 | + url: http.getGateWay() + requestUrl, |
150 | type: 'POST', | 159 | type: 'POST', |
151 | processData: false, | 160 | processData: false, |
152 | mimeType: "multipart/form-data", | 161 | mimeType: "multipart/form-data", |
@@ -157,7 +166,7 @@ let http = { | @@ -157,7 +166,7 @@ let http = { | ||
157 | loading.close(); | 166 | loading.close(); |
158 | // console.log("==>", requestUrl, xhr, textStatus) | 167 | // console.log("==>", requestUrl, xhr, textStatus) |
159 | http.reqErr(xhr); | 168 | http.reqErr(xhr); |
160 | - http.proxy.$global.showMsg("上传失败,请您确认文件是否存在!","error"); | 169 | + __global.showMsg("上传失败,请您确认文件是否存在!","error"); |
161 | 170 | ||
162 | }, | 171 | }, |
163 | success: function (data, textStatus, jqXHR) { | 172 | success: function (data, textStatus, jqXHR) { |
@@ -187,11 +196,16 @@ let http = { | @@ -187,11 +196,16 @@ let http = { | ||
187 | return `${keys}`; | 196 | return `${keys}`; |
188 | } | 197 | } |
189 | let p = formart(parmas); | 198 | let p = formart(parmas); |
190 | - window.open(sessionStorage.getItem('domainName') + requestUrl + "&" + p); | 199 | + window.open( http.getGateWay() + requestUrl + "&" + p); |
191 | }, | 200 | }, |
192 | getToken() { | 201 | getToken() { |
193 | return localStorage.getItem('access_token'); | 202 | return localStorage.getItem('access_token'); |
194 | }, | 203 | }, |
204 | + getGateWay () { | ||
205 | + let gateway = sessionStorage.getItem('domainName'); | ||
206 | + return gateway == null ? '' : gateway; | ||
207 | + } | ||
195 | } | 208 | } |
196 | - | 209 | +// 获取url |
210 | +http.getUrl(); | ||
197 | export default http | 211 | export default http |
-
Please register or login to post a comment