dfws-ve-taro-request 0.1.7 → 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.umd.js CHANGED
@@ -6723,9 +6723,10 @@
6723
6723
  };
6724
6724
 
6725
6725
  // 是否进行接口解密
6726
- var isEncoding = function (url) {
6726
+ var isEncoding = function (url, encode) {
6727
6727
  if (url === void 0) { url = ''; }
6728
- return url.includes('/sso/v1/') || url.includes('/resume/v1/');
6728
+ if (encode === void 0) { encode = false; }
6729
+ return encode || url.includes('/sso/v1/') || url.includes('/resume/v1/') || url.includes('/resume/v2/');
6729
6730
  };
6730
6731
  // 加密
6731
6732
  var encryptByDES = function (params, debug) {
@@ -6778,13 +6779,13 @@
6778
6779
  504: '网关超时。',
6779
6780
  };
6780
6781
  // 错误上报监控系统
6781
- var onErrorMsgRrport = function (response, options, Taro) {
6782
+ var onErrorMsgRrport = function (response, options, Taro, encode) {
6782
6783
  var _a;
6783
6784
  var statusCode = response.statusCode;
6784
6785
  var _b = options.method, method = _b === void 0 ? "get" : _b, url = options.url, data = options.data;
6785
6786
  var errorText = codeMessage[statusCode] || '';
6786
6787
  var statusParams = data;
6787
- var encoding = isEncoding(url) &&
6788
+ var encoding = isEncoding(url, encode) &&
6788
6789
  ((_a = response.data) === null || _a === void 0 ? void 0 : _a.type) !== "application/octet-stream";
6789
6790
  var errorData = {
6790
6791
  'id': '9',
@@ -6810,7 +6811,7 @@
6810
6811
  console.log('error:', err);
6811
6812
  });
6812
6813
  };
6813
- var checkStatus = function (response, options, Taro) {
6814
+ var checkStatus = function (response, options, Taro, encode) {
6814
6815
  var statusCode = response.statusCode, data = response.data;
6815
6816
  if (statusCode >= 200 && statusCode < 300 || statusCode == 406) {
6816
6817
  if (data.code == 400 || statusCode == 406) {
@@ -6844,13 +6845,14 @@
6844
6845
  icon: 'none',
6845
6846
  });
6846
6847
  // 上报前端监控系统
6847
- return onErrorMsgRrport(response, options, Taro);
6848
+ return onErrorMsgRrport(response, options, Taro, encode);
6848
6849
  }
6849
6850
  };
6850
- var request = (function (url, data, method, header, Taro, debug) {
6851
+ var request = (function (url, data, method, header, Taro, debug, encode) {
6851
6852
  if (method === void 0) { method = 'get'; }
6852
6853
  if (debug === void 0) { debug = false; }
6853
- var isEncode = isEncoding(url); // 判断是否加密
6854
+ if (encode === void 0) { encode = false; }
6855
+ var isEncode = isEncoding(url, encode); // 判断是否加密
6854
6856
  var isMethod = method.toLocaleLowerCase() === 'get' && Object.keys(data).length; // 请求方式get而且加密处理
6855
6857
  if (isMethod) {
6856
6858
  url = "".concat(url, "?").concat(isEncode ? encryptByDES(objectToQueryString(data), debug) : objectToQueryString(data));
@@ -6863,13 +6865,21 @@
6863
6865
  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'] || '' })
6864
6866
  }).then(function (res) {
6865
6867
  var response = isEncode ? __assign(__assign({}, res), { data: decryptByDES(unescape(res.data), debug) }) : res;
6866
- return checkStatus(response, { url: url, data: data, method: method }, Taro);
6868
+ return checkStatus(response, { url: url, data: data, method: method }, Taro, encode);
6867
6869
  }).catch(function (err) {
6868
6870
  console.log('error:', err);
6869
- Taro.showToast({
6870
- title: '网络异常,请稍后重试',
6871
- icon: 'none',
6872
- });
6871
+ if (err && err.statusCode == 401) {
6872
+ Taro.removeStorage({ key: 'ticket' });
6873
+ Taro.removeStorage({ key: 'user_id' });
6874
+ Taro.removeStorage({ key: 'openid' });
6875
+ Taro.removeStorage({ key: 'mobile' });
6876
+ }
6877
+ else {
6878
+ Taro.showToast({
6879
+ title: '网络异常,请稍后重试',
6880
+ icon: 'none',
6881
+ });
6882
+ }
6873
6883
  return {
6874
6884
  status: 0,
6875
6885
  errMsg: '',
@@ -6878,10 +6888,11 @@
6878
6888
  });
6879
6889
 
6880
6890
  var index = {
6881
- request: function (taro, projectChannel, url, data, method, headers, debug) {
6891
+ request: function (taro, projectChannel, url, data, method, headers, debug, isEncode) {
6882
6892
  if (projectChannel === void 0) { projectChannel = {}; }
6883
6893
  if (headers === void 0) { headers = {}; }
6884
6894
  if (debug === void 0) { debug = false; }
6895
+ if (isEncode === void 0) { isEncode = false; }
6885
6896
  /**
6886
6897
  * 东方网升项目公共 header
6887
6898
  * @param {object} dfws_params
@@ -6891,7 +6902,7 @@
6891
6902
  dfws_header.getNetworkType(function (network) {
6892
6903
  channel.network = network;
6893
6904
  });
6894
- return request(url, data, method, __assign({ version: channel.version, params: JSON.stringify(dfws_header.queryChannels()) }, headers), taro, debug);
6905
+ return request(url, data, method, __assign({ version: channel.version, params: JSON.stringify(dfws_header.queryChannels()) }, headers), taro, debug, isEncode);
6895
6906
  },
6896
6907
  // 接口解密
6897
6908
  decryptByDES: decryptByDES,