dlt-for-react 2.3.4 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/lib/components/HqCascader/index.js +4 -6
- package/lib/components/HqCheckBox/index.js +2 -4
- package/lib/components/HqInputPicker/render.js +3 -1
- package/lib/components/HqMultiSelect/index.js +2 -4
- package/lib/components/HqSelect/getSelectName.js +2 -6
- package/lib/components/HqSelect/index.js +3 -5
- package/lib/components/HqSelector/NHSelector/resultview/index.js +1 -1
- package/lib/components/HqSelector/NHSelector/table/index.js +1 -1
- package/lib/components/HqSelector/NHSelector/tree/index.js +1 -1
- package/lib/components/HqSwitch/index.js +2 -4
- package/lib/components/KyCheckBox/index.js +2 -4
- package/lib/components/KyExcel/index.js +2 -2
- package/lib/components/KyTable/highSelect.js +2 -4
- package/lib/components/KyTable/index.js +5 -7
- package/lib/components/KyTableCardList/highSelect.js +2 -4
- package/lib/components/KyTableCardList/index.js +2 -2
- package/lib/components/KyTree/index.js +2 -2
- package/lib/components/KyUpload/index.js +5 -5
- package/lib/index.js +105 -0
- package/lib/layouts/Login/index-pre.js +1 -1
- package/lib/layouts/Login/index.js +1 -1
- package/lib/layouts/Login/login.js +1 -1
- package/lib/layouts/Top/index.js +1 -1
- package/lib/layouts/layout/index.js +3 -3
- package/lib/layouts/mixTop/index.js +1 -1
- package/lib/utils/AxiosUtil.js +534 -0
- package/lib/utils/NHCore.js +3 -1
- package/lib/utils/NHFetch.js +67 -221
- package/lib/utils/env.js +29 -0
- package/lib/utils/toFormDesignPage.js +2 -6
- package/lib/utils/toFormFillingPage.js +2 -6
- package/lib/utils/toProcessApplyPage.js +2 -6
- package/lib/utils/toProcessDesignPage.js +3 -7
- package/lib/utils/toProcessVerifyPage.js +2 -6
- package/lib/utils/toProcessViewPage.js +2 -6
- package/lib/utils/user.js +80 -0
- package/package.json +4 -2
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEnv = exports.setEnvs = undefined;
|
|
7
|
+
|
|
8
|
+
var _typeof2 = require("babel-runtime/helpers/typeof");
|
|
9
|
+
|
|
10
|
+
var _typeof3 = _interopRequireDefault(_typeof2);
|
|
11
|
+
|
|
12
|
+
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
|
|
13
|
+
|
|
14
|
+
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
|
15
|
+
|
|
16
|
+
var _promise = require("babel-runtime/core-js/promise");
|
|
17
|
+
|
|
18
|
+
var _promise2 = _interopRequireDefault(_promise);
|
|
19
|
+
|
|
20
|
+
var _stringify = require("babel-runtime/core-js/json/stringify");
|
|
21
|
+
|
|
22
|
+
var _stringify2 = _interopRequireDefault(_stringify);
|
|
23
|
+
|
|
24
|
+
var _extends2 = require("babel-runtime/helpers/extends");
|
|
25
|
+
|
|
26
|
+
var _extends3 = _interopRequireDefault(_extends2);
|
|
27
|
+
|
|
28
|
+
var _message2 = require("antd/lib/message");
|
|
29
|
+
|
|
30
|
+
var _message3 = _interopRequireDefault(_message2);
|
|
31
|
+
|
|
32
|
+
var _modal = require("antd/lib/modal");
|
|
33
|
+
|
|
34
|
+
var _modal2 = _interopRequireDefault(_modal);
|
|
35
|
+
|
|
36
|
+
exports.checkRefresh = checkRefresh;
|
|
37
|
+
exports.expiredTips = expiredTips;
|
|
38
|
+
exports.query = query;
|
|
39
|
+
exports.queryCancel = queryCancel;
|
|
40
|
+
exports.exportDataExcel = exportDataExcel;
|
|
41
|
+
exports.exportTemplateExcel = exportTemplateExcel;
|
|
42
|
+
exports.importExcel = importExcel;
|
|
43
|
+
exports.post = post;
|
|
44
|
+
exports.postForm = postForm;
|
|
45
|
+
exports.get = get;
|
|
46
|
+
exports.insert = insert;
|
|
47
|
+
exports.update = update;
|
|
48
|
+
exports.remove = remove;
|
|
49
|
+
exports.requestAll = requestAll;
|
|
50
|
+
exports.nhFetch = nhFetch;
|
|
51
|
+
|
|
52
|
+
var _env = require("./env");
|
|
53
|
+
|
|
54
|
+
Object.defineProperty(exports, "setEnvs", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _env.setEnvs;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "getEnv", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _env.getEnv;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
require("antd/lib/message/style");
|
|
68
|
+
|
|
69
|
+
require("antd/lib/modal/style");
|
|
70
|
+
|
|
71
|
+
var _axios = require("axios");
|
|
72
|
+
|
|
73
|
+
var _axios2 = _interopRequireDefault(_axios);
|
|
74
|
+
|
|
75
|
+
var _qs = require("qs");
|
|
76
|
+
|
|
77
|
+
var _qs2 = _interopRequireDefault(_qs);
|
|
78
|
+
|
|
79
|
+
var _history = require("history");
|
|
80
|
+
|
|
81
|
+
var _user = require("./user");
|
|
82
|
+
|
|
83
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
84
|
+
|
|
85
|
+
var confirm = _modal2.default.confirm; /*
|
|
86
|
+
* @Description: axios 请求工具(适配 dlt-for-react)
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
var hashHistory = (0, _history.createHashHistory)();
|
|
90
|
+
|
|
91
|
+
var i18n = {
|
|
92
|
+
tips: "提示",
|
|
93
|
+
timeout: "请求超时",
|
|
94
|
+
timeoutRetry: "请求超时,是否重试?",
|
|
95
|
+
sessionExpired: "会话已过期!",
|
|
96
|
+
reRegister: "重新登录"
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
window.flag = false;
|
|
100
|
+
var isRefreshing = false;
|
|
101
|
+
var requests = [];
|
|
102
|
+
|
|
103
|
+
var getLocale = function getLocale() {
|
|
104
|
+
return window.__LOCALE__ || typeof localStorage !== "undefined" && localStorage.getItem("umi_locale") || "zh-CN";
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var reqrefreshTokenGet = function reqrefreshTokenGet() {
|
|
108
|
+
return query("api/refreshToken");
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
_axios2.default.defaults.timeout = 6000;
|
|
112
|
+
_axios2.default.defaults.withCredentials = true;
|
|
113
|
+
_axios2.default.defaults.headers["Access-Control-Allow-Origin"] = "*";
|
|
114
|
+
_axios2.default.defaults.headers["Access-Control-Allow-Methods"] = "GET, POST, PATCH, PUT, DELETE, OPTIONS";
|
|
115
|
+
_axios2.default.defaults.headers["Access-Control-Allow-Headers"] = "Origin, Content-Type, X-Auth-Token";
|
|
116
|
+
_axios2.default.defaults.headers.get["X-Requested-With"] = "XMLHttpRequest";
|
|
117
|
+
_axios2.default.defaults.headers.post["X-Requested-With"] = "XMLHttpRequest";
|
|
118
|
+
_axios2.default.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8";
|
|
119
|
+
_axios2.default.defaults.headers.post["Accept"] = "application/json";
|
|
120
|
+
_axios2.default.defaults.headers.put["X-Requested-With"] = "XMLHttpRequest";
|
|
121
|
+
_axios2.default.defaults.headers.delete["X-Requested-With"] = "XMLHttpRequest";
|
|
122
|
+
|
|
123
|
+
_axios2.default.interceptors.response.use(function (response) {
|
|
124
|
+
if ((0, _env.getEnv)("gateway_version") == "3") {
|
|
125
|
+
(0, _user.setResponseTime)(Math.floor(new Date().getTime() / 1000));
|
|
126
|
+
if ((response.status == 401 || response.status == 302) && response.data && response.data.code == "53000010" && !window.loginWarnflag) {
|
|
127
|
+
return checkRefresh(response);
|
|
128
|
+
}
|
|
129
|
+
} else if (response.status == 302) {
|
|
130
|
+
expiredTips();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (response.data && response.data.code !== 701 && response.data.code != 200 && response.data.code != 1006 && response.data.message) {
|
|
135
|
+
_message3.default.destroy();
|
|
136
|
+
_message3.default.error(response.data.message);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return response;
|
|
140
|
+
}, function (error) {
|
|
141
|
+
if (error.config && error.config.showTimeout && error.code == "ECONNABORTED" && error.message.indexOf("timeout") != -1 && !window.timeoutWarnflag) {
|
|
142
|
+
window.timeoutWarnflag = true;
|
|
143
|
+
if (error.config.showTimeout == "again") {
|
|
144
|
+
var timeoutModal = confirm({
|
|
145
|
+
title: i18n.tips,
|
|
146
|
+
content: i18n.timeoutRetry,
|
|
147
|
+
onOk: function onOk() {
|
|
148
|
+
timeoutModal.destroy();
|
|
149
|
+
window.timeoutWarnflag = false;
|
|
150
|
+
return _axios2.default.request(error.config);
|
|
151
|
+
},
|
|
152
|
+
onCancel: function onCancel() {
|
|
153
|
+
window.timeoutWarnflag = false;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
} else {
|
|
157
|
+
_message3.default.warning(i18n.timeout, 3, function () {
|
|
158
|
+
window.timeoutWarnflag = false;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if ((0, _env.getEnv)("gateway_version") == "3") {
|
|
164
|
+
if (error.response && (error.response.status == 401 || error.response.status == 302) && error.response.data && error.response.data.code == "53000010" && !window.loginWarnflag) {
|
|
165
|
+
return checkRefresh(error);
|
|
166
|
+
}
|
|
167
|
+
} else if (error.response && error.response.status == 302) {
|
|
168
|
+
expiredTips();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (error.code == "ECONNABORTED" && error.message.indexOf("timeout") != -1 && !error.response) {
|
|
173
|
+
error.response = {
|
|
174
|
+
status: 504,
|
|
175
|
+
statusText: "timeout",
|
|
176
|
+
data: {
|
|
177
|
+
data: false,
|
|
178
|
+
meta: {
|
|
179
|
+
message: i18n.timeout,
|
|
180
|
+
statusCode: 504,
|
|
181
|
+
success: false
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return error.response ? error.response : error;
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
_axios2.default.interceptors.request.use(function (config) {
|
|
191
|
+
config.headers["X-Language"] = getLocale();
|
|
192
|
+
|
|
193
|
+
var user = JSON.parse(window.sessionStorage.getItem(_user.userCacheKey) || "{}");
|
|
194
|
+
if (user != null && user.userId) {
|
|
195
|
+
config.headers["loginUserId"] = user.userId;
|
|
196
|
+
config.headers["loginUserOrgId"] = user.orgId;
|
|
197
|
+
config.headers.post["loginUserOrgId"] = user.orgId;
|
|
198
|
+
config.headers.post["loginUserId"] = user.userId;
|
|
199
|
+
config.headers.get["loginUserId"] = user.userId;
|
|
200
|
+
config.headers.get["loginUserOrgId"] = user.orgId;
|
|
201
|
+
|
|
202
|
+
var Authorization = user.tokenId || window.sessionStorage.getItem("access_token") || "";
|
|
203
|
+
if (Authorization != null && Authorization != "") {
|
|
204
|
+
config.headers["Authorization"] = Authorization;
|
|
205
|
+
config.headers.delete["Authorization"] = Authorization;
|
|
206
|
+
config.headers.get["Authorization"] = Authorization;
|
|
207
|
+
config.headers.post["Authorization"] = Authorization;
|
|
208
|
+
config.headers.put["Authorization"] = Authorization;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
config.params = (0, _extends3.default)({}, config.params || {}, {
|
|
213
|
+
_t: Date.parse(new Date()) / 1000
|
|
214
|
+
});
|
|
215
|
+
return config;
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
function checkRefresh(error) {
|
|
219
|
+
var expire = (0, _user.getExpire)();
|
|
220
|
+
var nowTime = Math.floor(new Date().getTime() / 1000);
|
|
221
|
+
var freshTime = (0, _user.getResponseTime)();
|
|
222
|
+
|
|
223
|
+
if (nowTime - freshTime < expire) {
|
|
224
|
+
if (!isRefreshing) {
|
|
225
|
+
isRefreshing = true;
|
|
226
|
+
reqrefreshTokenGet().then(function (res) {
|
|
227
|
+
isRefreshing = false;
|
|
228
|
+
if (res && res.code == 200) {
|
|
229
|
+
(0, _user.setExpire)(res.data.expiration);
|
|
230
|
+
var token = res.data.token || "";
|
|
231
|
+
(0, _user.setTokenCache)(token);
|
|
232
|
+
var user = JSON.parse(window.sessionStorage.getItem(_user.userCacheKey) || "{}");
|
|
233
|
+
if (user && user.userId) {
|
|
234
|
+
user.tokenId = token;
|
|
235
|
+
window.sessionStorage.setItem(_user.userCacheKey, (0, _stringify2.default)(user));
|
|
236
|
+
}
|
|
237
|
+
error.config.headers.Authorization = token;
|
|
238
|
+
return token;
|
|
239
|
+
}
|
|
240
|
+
expiredTips();
|
|
241
|
+
}).then(function (token) {
|
|
242
|
+
if (token) {
|
|
243
|
+
requests.forEach(function (cb) {
|
|
244
|
+
return cb(token);
|
|
245
|
+
});
|
|
246
|
+
requests = [];
|
|
247
|
+
}
|
|
248
|
+
}).catch(function (err) {
|
|
249
|
+
isRefreshing = false;
|
|
250
|
+
console.log(err);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
var retryOriginalRequest = new _promise2.default(function (resolve) {
|
|
254
|
+
requests.push(function (token) {
|
|
255
|
+
error.config.headers.Authorization = token;
|
|
256
|
+
resolve((0, _axios2.default)(error.config));
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
return retryOriginalRequest;
|
|
260
|
+
}
|
|
261
|
+
expiredTips();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function expiredTips() {
|
|
265
|
+
if (window.loginWarnflag) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
window.loginWarnflag = true;
|
|
269
|
+
var returnUrl = encodeURIComponent(window.location.href);
|
|
270
|
+
|
|
271
|
+
_modal2.default.warning({
|
|
272
|
+
title: i18n.tips,
|
|
273
|
+
key: "1",
|
|
274
|
+
content: i18n.sessionExpired,
|
|
275
|
+
okText: i18n.reRegister,
|
|
276
|
+
onOk: function onOk() {
|
|
277
|
+
(0, _user.removeCache)();
|
|
278
|
+
window.loginWarnflag = false;
|
|
279
|
+
hashHistory.push({
|
|
280
|
+
pathname: "/login",
|
|
281
|
+
search: returnUrl ? "?returnUrl=" + returnUrl : ""
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function query(url, params) {
|
|
288
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
289
|
+
|
|
290
|
+
return new _promise2.default(function (resolve, reject) {
|
|
291
|
+
_axios2.default.get(url, (0, _extends3.default)({ params: params }, config)).then(function (res) {
|
|
292
|
+
resolve(res.data);
|
|
293
|
+
}).catch(function (err) {
|
|
294
|
+
reject(err.data);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function queryCancel(url, params) {
|
|
300
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
301
|
+
var axiosCancel = arguments[3];
|
|
302
|
+
var cancelVar = arguments[4];
|
|
303
|
+
|
|
304
|
+
if (typeof axiosCancel[cancelVar] === "function") {
|
|
305
|
+
axiosCancel[cancelVar]("终止请求");
|
|
306
|
+
}
|
|
307
|
+
config.cancelToken = new _axios2.default.CancelToken(function executor(c) {
|
|
308
|
+
axiosCancel[cancelVar] = c;
|
|
309
|
+
});
|
|
310
|
+
return new _promise2.default(function (resolve, reject) {
|
|
311
|
+
_axios2.default.get(url, (0, _extends3.default)({ params: params }, config)).then(function (res) {
|
|
312
|
+
if (res.message == "终止请求") {
|
|
313
|
+
resolve({});
|
|
314
|
+
}
|
|
315
|
+
resolve(res.data);
|
|
316
|
+
}).catch(function (err) {
|
|
317
|
+
reject(err);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function exportDataExcel(url, params) {
|
|
323
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
324
|
+
|
|
325
|
+
return new _promise2.default(function (resolve, reject) {
|
|
326
|
+
_axios2.default.post(url, (0, _extends3.default)({}, params), (0, _extends3.default)({ responseType: "blob" }, config)).then(function (res) {
|
|
327
|
+
resolve(res);
|
|
328
|
+
}).catch(function (err) {
|
|
329
|
+
reject(err.data);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function exportTemplateExcel(url, params) {
|
|
335
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
336
|
+
|
|
337
|
+
return new _promise2.default(function (resolve, reject) {
|
|
338
|
+
_axios2.default.get(url, (0, _extends3.default)({ params: params, responseType: "blob" }, config)).then(function (res) {
|
|
339
|
+
resolve(res);
|
|
340
|
+
}).catch(function (err) {
|
|
341
|
+
reject(err.data);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function importExcel(url, datas, config) {
|
|
347
|
+
return new _promise2.default(function (resolve, reject) {
|
|
348
|
+
_axios2.default.post(url, datas, config).then(function (res) {
|
|
349
|
+
resolve(res.data);
|
|
350
|
+
}).catch(function (err) {
|
|
351
|
+
reject(err.data);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function post(url, datas, params) {
|
|
357
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
358
|
+
|
|
359
|
+
return new _promise2.default(function (resolve, reject) {
|
|
360
|
+
_axios2.default.post(url, datas, (0, _extends3.default)({ params: params }, config)).then(function (res) {
|
|
361
|
+
resolve(res.data);
|
|
362
|
+
}).catch(function (err) {
|
|
363
|
+
reject(err.data);
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function postForm(url, datas, params) {
|
|
369
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
370
|
+
|
|
371
|
+
return new _promise2.default(function (resolve, reject) {
|
|
372
|
+
_axios2.default.post(url, _qs2.default.stringify(datas), (0, _extends3.default)({ params: params }, config)).then(function (res) {
|
|
373
|
+
resolve(res.data);
|
|
374
|
+
}).catch(function (err) {
|
|
375
|
+
reject(err.data);
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function get(url, params) {
|
|
381
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
382
|
+
|
|
383
|
+
return new _promise2.default(function (resolve, reject) {
|
|
384
|
+
_axios2.default.get(url, (0, _extends3.default)({ params: params }, config)).then(function (res) {
|
|
385
|
+
resolve(res.data);
|
|
386
|
+
}).catch(function (err) {
|
|
387
|
+
reject(err.data);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function insert(url, datas, params) {
|
|
393
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
394
|
+
|
|
395
|
+
return post(url, datas, params, config);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function update(url, datas, params) {
|
|
399
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
400
|
+
|
|
401
|
+
return post(url, datas, params, config);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function remove(url, datas, params) {
|
|
405
|
+
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
406
|
+
|
|
407
|
+
return post(url, datas, params, config);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function requestAll() {
|
|
411
|
+
for (var _len = arguments.length, paramsFun = Array(_len), _key = 0; _key < _len; _key++) {
|
|
412
|
+
paramsFun[_key] = arguments[_key];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return new _promise2.default(function (resolve, reject) {
|
|
416
|
+
_axios2.default.all.apply(_axios2.default, paramsFun).then(_axios2.default.spread(function () {
|
|
417
|
+
var responseList = [];
|
|
418
|
+
|
|
419
|
+
for (var _len2 = arguments.length, response = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
420
|
+
response[_key2] = arguments[_key2];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
var _iteratorNormalCompletion = true;
|
|
424
|
+
var _didIteratorError = false;
|
|
425
|
+
var _iteratorError = undefined;
|
|
426
|
+
|
|
427
|
+
try {
|
|
428
|
+
for (var _iterator = (0, _getIterator3.default)(response), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
429
|
+
var res = _step.value;
|
|
430
|
+
|
|
431
|
+
if (!res.status && res.response) {
|
|
432
|
+
responseList.push(res.response.data);
|
|
433
|
+
} else {
|
|
434
|
+
responseList.push(res.data);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
} catch (err) {
|
|
438
|
+
_didIteratorError = true;
|
|
439
|
+
_iteratorError = err;
|
|
440
|
+
} finally {
|
|
441
|
+
try {
|
|
442
|
+
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
443
|
+
_iterator.return();
|
|
444
|
+
}
|
|
445
|
+
} finally {
|
|
446
|
+
if (_didIteratorError) {
|
|
447
|
+
throw _iteratorError;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return responseList;
|
|
453
|
+
})).then(function (res) {
|
|
454
|
+
resolve(res);
|
|
455
|
+
}).catch(function (err) {
|
|
456
|
+
reject(err.data);
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* 兼容 dlt-for-react 的 NHFetch 适配函数
|
|
463
|
+
* 签名:nhFetch(url, method, params, errorFunc)
|
|
464
|
+
*/
|
|
465
|
+
function nhFetch(pUrl, pMethod, params, errorFunc) {
|
|
466
|
+
var url = pUrl || "";
|
|
467
|
+
var method = (pMethod || "POST").toUpperCase();
|
|
468
|
+
|
|
469
|
+
if (url.startsWith("/") && typeof window.baseUrl === "string") {
|
|
470
|
+
url = window.baseUrl + url;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
var isGet = method === "GET";
|
|
474
|
+
var isPost = method === "POST";
|
|
475
|
+
var config = { headers: {} };
|
|
476
|
+
|
|
477
|
+
if (isGet) {
|
|
478
|
+
config.headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";
|
|
479
|
+
if (params !== undefined && params !== "" && (0, _stringify2.default)(params) !== "{}") {
|
|
480
|
+
if (typeof params === "string") {
|
|
481
|
+
url = url + (url.indexOf("?") > -1 ? "&" : "?") + params;
|
|
482
|
+
} else {
|
|
483
|
+
var paramsStr = "";
|
|
484
|
+
for (var key in params) {
|
|
485
|
+
if ((0, _typeof3.default)(params[key]) === "object" && params[key] !== null) {
|
|
486
|
+
for (var key2 in params[key]) {
|
|
487
|
+
paramsStr += "&" + key + "." + key2 + "=" + params[key][key2];
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
paramsStr += "&" + key + "=" + params[key];
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
url = paramsStr ? url + (url.indexOf("?") > -1 ? "&" : "?") + paramsStr.slice(1) : url;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
config.params = {};
|
|
497
|
+
config.params._t = Date.parse(new Date()) / 1000;
|
|
498
|
+
} else if (isPost) {
|
|
499
|
+
if (params !== undefined && params !== "") {
|
|
500
|
+
if (params instanceof FormData) {
|
|
501
|
+
config.headers = {};
|
|
502
|
+
config.data = params;
|
|
503
|
+
} else if (typeof params === "string") {
|
|
504
|
+
config.headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";
|
|
505
|
+
config.data = params;
|
|
506
|
+
} else {
|
|
507
|
+
config.headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
508
|
+
config.data = (0, _stringify2.default)(params);
|
|
509
|
+
}
|
|
510
|
+
} else {
|
|
511
|
+
config.headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
config.headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
515
|
+
config.method = "POST";
|
|
516
|
+
if (params !== undefined && params !== "") {
|
|
517
|
+
config.data = (0, _stringify2.default)(params);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
config.url = url;
|
|
522
|
+
config.method = isGet ? "GET" : "POST";
|
|
523
|
+
|
|
524
|
+
return new _promise2.default(function (resolve) {
|
|
525
|
+
_axios2.default.request(config).then(function (res) {
|
|
526
|
+
resolve(res ? res.data : undefined);
|
|
527
|
+
}).catch(function (err) {
|
|
528
|
+
if (errorFunc && typeof errorFunc === "function") {
|
|
529
|
+
errorFunc(err);
|
|
530
|
+
}
|
|
531
|
+
resolve(undefined);
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
}
|
package/lib/utils/NHCore.js
CHANGED
|
@@ -26,6 +26,8 @@ exports.animationFramePolyfill = animationFramePolyfill;
|
|
|
26
26
|
|
|
27
27
|
var _common = require('./common');
|
|
28
28
|
|
|
29
|
+
var _AxiosUtil = require('./AxiosUtil');
|
|
30
|
+
|
|
29
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
32
|
|
|
31
33
|
// 获取窗口信息
|
|
@@ -278,7 +280,7 @@ var validateCode = exports.validateCode = function () {
|
|
|
278
280
|
|
|
279
281
|
baseUrl = window.xtglUrl || 'api/hq-xtgl';
|
|
280
282
|
_context.next = 6;
|
|
281
|
-
return
|
|
283
|
+
return (0, _AxiosUtil.nhFetch)(baseUrl + '/outer/getCsszByCsbz', 'GET', {
|
|
282
284
|
csbz: 'XTGL_TSZF'
|
|
283
285
|
});
|
|
284
286
|
|