dfws-ve-taro-request 0.0.1 → 0.0.3

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
@@ -123,6 +123,8 @@ var getPublicChannel = function (channels, taro) {
123
123
 
124
124
  // 接口加密密钥
125
125
  var secretkey = "dz15z9z2z15z11z8zf";
126
+ // 图片验证码加密密钥
127
+ var captchaKey = "3dz2dz2bzcz8z30z2hz2nz3dz2nz2mz2oz2n";
126
128
  // 项目渠道配置:管理后台-138美业人才-系统设置-渠道管理
127
129
  var channel = { "project": "VE", "origin": "C", "platform": "XCX", "device": "ZJDF", "version": "1.0.0" };
128
130
 
@@ -6720,16 +6722,19 @@ var isEncoding = function (url) {
6720
6722
  return url.includes('/sso/v1/') || url.includes('/resume/v1/');
6721
6723
  };
6722
6724
  // 加密
6723
- var encryptByDES = function (params) {
6724
- console.log("\u8BF7\u6C42\u53C2\u6570\uFF1A", params);
6725
+ var encryptByDES = function (params, debug) {
6726
+ if (debug === void 0) { debug = false; }
6727
+ debug && console.log("\u8BF7\u6C42\u53C2\u6570\uFF1A", params);
6725
6728
  return encodeURIComponent(_default.encryptByDES(JSON.stringify(params), secretkey));
6726
6729
  };
6727
6730
  //解密
6728
- var decryptByDES = function (params) {
6731
+ var decryptByDES = function (params, debug) {
6732
+ if (debug === void 0) { debug = false; }
6729
6733
  var data = JSON.parse(_default.decryptByDES(params, secretkey));
6730
- console.log("\u83B7\u53D6\u5185\u5BB9\uFF1A", data);
6734
+ debug && console.log("\u83B7\u53D6\u5185\u5BB9\uFF1A", data);
6731
6735
  return data;
6732
6736
  };
6737
+ // 对象转URL字符串
6733
6738
  var objectToQueryString = function (obj) {
6734
6739
  return Object.keys(obj)
6735
6740
  .map(function (key) {
@@ -6739,6 +6744,15 @@ var objectToQueryString = function (obj) {
6739
6744
  })
6740
6745
  .join('&');
6741
6746
  };
6747
+ //短信/邮箱验证码加密
6748
+ var encryptBySso = function (value) {
6749
+ var key = Date.parse(new Date().toString());
6750
+ var sign = _default.encryptByDES("".concat(_default.decrypto(captchaKey, 123, 25)).concat(value).concat(key), secretkey);
6751
+ return {
6752
+ check_sign: sign,
6753
+ check_key: key,
6754
+ };
6755
+ };
6742
6756
 
6743
6757
  var codeMessage = {
6744
6758
  200: '服务器成功返回请求的数据。',
@@ -6814,16 +6828,17 @@ var checkStatus = function (response, options, Taro) {
6814
6828
  return onErrorMsgRrport(response, options, Taro);
6815
6829
  }
6816
6830
  };
6817
- var request = (function (url, data, method, header, Taro) {
6831
+ var request = (function (url, data, method, header, Taro, debug) {
6818
6832
  if (method === void 0) { method = 'get'; }
6833
+ if (debug === void 0) { debug = false; }
6819
6834
  var isEncode = isEncoding(url); // 判断是否加密
6820
6835
  var isMethod = method.toLocaleLowerCase() === 'get' && Object.keys(data).length; // 请求方式get而且加密处理
6821
6836
  if (isMethod) {
6822
- url = "".concat(url, "?").concat(isEncode ? encryptByDES(objectToQueryString(data)) : objectToQueryString(data));
6837
+ url = "".concat(url, "?").concat(isEncode ? encryptByDES(objectToQueryString(data), debug) : objectToQueryString(data));
6823
6838
  }
6824
6839
  return Taro.request({
6825
6840
  url: url,
6826
- data: isEncode ? encryptByDES(data) : data,
6841
+ data: isEncode ? encryptByDES(data, debug) : data,
6827
6842
  method: method,
6828
6843
  timeout: 15000,
6829
6844
  header: {
@@ -6834,7 +6849,7 @@ var request = (function (url, data, method, header, Taro) {
6834
6849
  'resume-language': header['resume-language'] || 'zh-CN',
6835
6850
  }
6836
6851
  }).then(function (res) {
6837
- var response = isEncode ? __assign(__assign({}, res), { data: decryptByDES(unescape(res.data)) }) : res;
6852
+ var response = isEncode ? __assign(__assign({}, res), { data: decryptByDES(unescape(res.data), debug) }) : res;
6838
6853
  return checkStatus(response, { url: url, data: data, method: method }, Taro);
6839
6854
  }).catch(function (err) {
6840
6855
  console.log('error:', err);
@@ -6850,9 +6865,10 @@ var request = (function (url, data, method, header, Taro) {
6850
6865
  });
6851
6866
 
6852
6867
  var index = {
6853
- request: function (taro, projectChannel, url, data, method, headers) {
6868
+ request: function (taro, projectChannel, url, data, method, headers, debug) {
6854
6869
  if (projectChannel === void 0) { projectChannel = {}; }
6855
6870
  if (headers === void 0) { headers = {}; }
6871
+ if (debug === void 0) { debug = false; }
6856
6872
  /**
6857
6873
  * 东方网升项目公共 header
6858
6874
  * @param {object} dfws_params
@@ -6862,8 +6878,14 @@ var index = {
6862
6878
  dfws_header.getNetworkType(function (network) {
6863
6879
  channel.network = network;
6864
6880
  });
6865
- return request(url, data, method, __assign({ version: channel.version, params: JSON.stringify(dfws_header.queryChannels()) }, headers), taro);
6866
- }
6881
+ return request(url, data, method, __assign({ version: channel.version, params: JSON.stringify(dfws_header.queryChannels()) }, headers), taro, debug);
6882
+ },
6883
+ // 接口解密
6884
+ decryptByDES: decryptByDES,
6885
+ // 接口加密
6886
+ encryptByDES: encryptByDES,
6887
+ // 验证码加密
6888
+ encryptBySso: encryptBySso
6867
6889
  };
6868
6890
 
6869
6891
  export { index as default };