dfws-ve-taro-request 0.1.8 → 0.1.9
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/dist/index.esm.js +14 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +14 -11
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6719,9 +6719,10 @@ var _default = dist.default = {
|
|
|
6719
6719
|
};
|
|
6720
6720
|
|
|
6721
6721
|
// 是否进行接口解密
|
|
6722
|
-
var isEncoding = function (url) {
|
|
6722
|
+
var isEncoding = function (url, encode) {
|
|
6723
6723
|
if (url === void 0) { url = ''; }
|
|
6724
|
-
|
|
6724
|
+
if (encode === void 0) { encode = false; }
|
|
6725
|
+
return encode || url.includes('/sso/v1/') || url.includes('/resume/v1/') || url.includes('/resume/v2/');
|
|
6725
6726
|
};
|
|
6726
6727
|
// 加密
|
|
6727
6728
|
var encryptByDES = function (params, debug) {
|
|
@@ -6774,13 +6775,13 @@ var codeMessage = {
|
|
|
6774
6775
|
504: '网关超时。',
|
|
6775
6776
|
};
|
|
6776
6777
|
// 错误上报监控系统
|
|
6777
|
-
var onErrorMsgRrport = function (response, options, Taro) {
|
|
6778
|
+
var onErrorMsgRrport = function (response, options, Taro, encode) {
|
|
6778
6779
|
var _a;
|
|
6779
6780
|
var statusCode = response.statusCode;
|
|
6780
6781
|
var _b = options.method, method = _b === void 0 ? "get" : _b, url = options.url, data = options.data;
|
|
6781
6782
|
var errorText = codeMessage[statusCode] || '';
|
|
6782
6783
|
var statusParams = data;
|
|
6783
|
-
var encoding = isEncoding(url) &&
|
|
6784
|
+
var encoding = isEncoding(url, encode) &&
|
|
6784
6785
|
((_a = response.data) === null || _a === void 0 ? void 0 : _a.type) !== "application/octet-stream";
|
|
6785
6786
|
var errorData = {
|
|
6786
6787
|
'id': '9',
|
|
@@ -6806,7 +6807,7 @@ var onErrorMsgRrport = function (response, options, Taro) {
|
|
|
6806
6807
|
console.log('error:', err);
|
|
6807
6808
|
});
|
|
6808
6809
|
};
|
|
6809
|
-
var checkStatus = function (response, options, Taro) {
|
|
6810
|
+
var checkStatus = function (response, options, Taro, encode) {
|
|
6810
6811
|
var statusCode = response.statusCode, data = response.data;
|
|
6811
6812
|
if (statusCode >= 200 && statusCode < 300 || statusCode == 406) {
|
|
6812
6813
|
if (data.code == 400 || statusCode == 406) {
|
|
@@ -6840,13 +6841,14 @@ var checkStatus = function (response, options, Taro) {
|
|
|
6840
6841
|
icon: 'none',
|
|
6841
6842
|
});
|
|
6842
6843
|
// 上报前端监控系统
|
|
6843
|
-
return onErrorMsgRrport(response, options, Taro);
|
|
6844
|
+
return onErrorMsgRrport(response, options, Taro, encode);
|
|
6844
6845
|
}
|
|
6845
6846
|
};
|
|
6846
|
-
var request = (function (url, data, method, header, Taro, debug) {
|
|
6847
|
+
var request = (function (url, data, method, header, Taro, debug, encode) {
|
|
6847
6848
|
if (method === void 0) { method = 'get'; }
|
|
6848
6849
|
if (debug === void 0) { debug = false; }
|
|
6849
|
-
|
|
6850
|
+
if (encode === void 0) { encode = false; }
|
|
6851
|
+
var isEncode = isEncoding(url, encode); // 判断是否加密
|
|
6850
6852
|
var isMethod = method.toLocaleLowerCase() === 'get' && Object.keys(data).length; // 请求方式get而且加密处理
|
|
6851
6853
|
if (isMethod) {
|
|
6852
6854
|
url = "".concat(url, "?").concat(isEncode ? encryptByDES(objectToQueryString(data), debug) : objectToQueryString(data));
|
|
@@ -6859,7 +6861,7 @@ var request = (function (url, data, method, header, Taro, debug) {
|
|
|
6859
6861
|
header: __assign(__assign({ 'authorization': Taro.getStorageSync('ticket') }, header), { 've-version': header.version || '1.0.0', 'dfws-params': header.params || '', 'content-type': header["content-type"] || 'application/json;charset=utf-8', 'resume-language': header['resume-language'] || 'zh-CN', 'common-params': header['common-params'] || '' })
|
|
6860
6862
|
}).then(function (res) {
|
|
6861
6863
|
var response = isEncode ? __assign(__assign({}, res), { data: decryptByDES(unescape(res.data), debug) }) : res;
|
|
6862
|
-
return checkStatus(response, { url: url, data: data, method: method }, Taro);
|
|
6864
|
+
return checkStatus(response, { url: url, data: data, method: method }, Taro, encode);
|
|
6863
6865
|
}).catch(function (err) {
|
|
6864
6866
|
console.log('error:', err);
|
|
6865
6867
|
if (err && err.statusCode == 401) {
|
|
@@ -6882,10 +6884,11 @@ var request = (function (url, data, method, header, Taro, debug) {
|
|
|
6882
6884
|
});
|
|
6883
6885
|
|
|
6884
6886
|
var index = {
|
|
6885
|
-
request: function (taro, projectChannel, url, data, method, headers, debug) {
|
|
6887
|
+
request: function (taro, projectChannel, url, data, method, headers, debug, isEncode) {
|
|
6886
6888
|
if (projectChannel === void 0) { projectChannel = {}; }
|
|
6887
6889
|
if (headers === void 0) { headers = {}; }
|
|
6888
6890
|
if (debug === void 0) { debug = false; }
|
|
6891
|
+
if (isEncode === void 0) { isEncode = false; }
|
|
6889
6892
|
/**
|
|
6890
6893
|
* 东方网升项目公共 header
|
|
6891
6894
|
* @param {object} dfws_params
|
|
@@ -6895,7 +6898,7 @@ var index = {
|
|
|
6895
6898
|
dfws_header.getNetworkType(function (network) {
|
|
6896
6899
|
channel.network = network;
|
|
6897
6900
|
});
|
|
6898
|
-
return request(url, data, method, __assign({ version: channel.version, params: JSON.stringify(dfws_header.queryChannels()) }, headers), taro, debug);
|
|
6901
|
+
return request(url, data, method, __assign({ version: channel.version, params: JSON.stringify(dfws_header.queryChannels()) }, headers), taro, debug, isEncode);
|
|
6899
6902
|
},
|
|
6900
6903
|
// 接口解密
|
|
6901
6904
|
decryptByDES: decryptByDES,
|