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