@conecli/cone-render 0.8.19 → 0.8.20-beta.0

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.
Files changed (91) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/common/index.jd.ts +1 -1
  5. package/dist/common/isvStorage/index.h5.ts +1 -0
  6. package/dist/common/isvStorage/index.ts +1 -0
  7. package/dist/common/token/const.ts +1 -0
  8. package/dist/common/token/index.h5.ts +1 -0
  9. package/dist/common/token/index.ts +1 -0
  10. package/dist/common/token/token.jd.ts +1 -0
  11. package/dist/common/token/token.ts +1 -0
  12. package/dist/common/token/token.wxapp.ts +1 -0
  13. package/dist/components/base/CommonFloorHead/index.module.scss +1 -1
  14. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  15. package/dist/components/base/CustomVideo/const.ts +1 -0
  16. package/dist/components/base/CustomVideo/index.module.scss +40 -64
  17. package/dist/components/base/CustomVideo/index.tsx +1 -1
  18. package/dist/components/base/Dialog/index.module.scss +6 -2
  19. package/dist/components/base/Dialog/index.tsx +1 -1
  20. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  21. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  22. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  23. package/dist/components/base/NetworkDataError/const.ts +1 -1
  24. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  25. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  26. package/dist/components/base/Price/{const.ts → Base/const.ts} +0 -0
  27. package/dist/components/base/Price/Base/index.module.scss +136 -0
  28. package/dist/components/base/Price/Base/index.tsx +1 -0
  29. package/dist/components/base/Price/Double/index.module.scss +158 -0
  30. package/dist/components/base/Price/Double/index.tsx +1 -0
  31. package/dist/components/base/Price/index.tsx +1 -1
  32. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  33. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  34. package/dist/components/floorItem.jd.tsx +1 -0
  35. package/dist/components/floorItem.tsx +1 -1
  36. package/dist/components/isv/Floor/index.tsx +1 -1
  37. package/dist/interface/component.ts +1 -1
  38. package/dist/interface/jumpEventReport.ts +1 -1
  39. package/dist/interface/service.ts +1 -1
  40. package/dist/jumpEventReport/base.ts +1 -1
  41. package/dist/jumpEventReport/const.ts +1 -1
  42. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  43. package/dist/jumpEventReport/index.h5.ts +1 -1
  44. package/dist/jumpEventReport/index.weapp.ts +1 -1
  45. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  46. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  47. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  48. package/dist/jumpEventReport/web/report.ts +1 -1
  49. package/dist/jumpEventReport/web.base.ts +1 -1
  50. package/dist/jumpEventReport/web.jd.ts +1 -1
  51. package/dist/jumpEventReport/web.jdb.ts +1 -0
  52. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  53. package/dist/libs/taroAppReport.js +2 -2
  54. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  55. package/dist/open/api/index.ts +1 -1
  56. package/dist/open/api/jump/business.ts +1 -0
  57. package/dist/open/api/jump/index.ts +1 -0
  58. package/dist/open/api/jump/minPath.ts +1 -0
  59. package/dist/open/api/jump/side.ts +1 -0
  60. package/dist/open/api/jump/webUrl.ts +1 -0
  61. package/dist/open/api/jump copy.ts +1 -0
  62. package/dist/open/api/moduleUtil.ts +1 -1
  63. package/dist/open/api/request.ts +1 -0
  64. package/dist/open/api/shopMember.ts +1 -0
  65. package/dist/open/api/userToken.ts +1 -0
  66. package/dist/service/bMallConst.ts +1 -0
  67. package/dist/service/bMallConst.wxapp.ts +1 -0
  68. package/dist/service/fetchGateway.ts +1 -0
  69. package/dist/service/fetchJsonp.ts +1 -0
  70. package/dist/service/http/colorSign.ts +1 -0
  71. package/dist/service/http/colorSign.wxapp.ts +1 -0
  72. package/dist/service/http/const.ts +1 -0
  73. package/dist/service/http/http.ts +1 -0
  74. package/dist/service/http/httpInterceptors.jd.ts +1 -0
  75. package/dist/service/http/httpInterceptors.ts +1 -0
  76. package/dist/service/http/index.ts +1 -0
  77. package/dist/service/requestServer.ts +1 -0
  78. package/dist/utils/connectNativeJsBridge.ts +1 -1
  79. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  80. package/dist/utils/h5Utils.ts +1 -1
  81. package/dist/utils/index.h5.ts +1 -1
  82. package/dist/utils/index.ts +1 -1
  83. package/dist/utils/index.weapp.ts +1 -1
  84. package/dist/utils/jm-common.js +1 -1
  85. package/dist/utils/memberFormatUtils.js +1 -0
  86. package/dist/utils/priceUtils.js +1 -0
  87. package/dist/utils/ready.ts +1 -0
  88. package/dist/utils/utils.ts +1 -1
  89. package/package.json +5 -4
  90. package/dist/components/base/Price/index.module.scss +0 -136
  91. package/dist/open/api/jump.ts +0 -1
@@ -0,0 +1 @@
1
+ import { isAndroidDevice } from '../utils'
2
  buId: '',
1
3
  console.log('getBMallUserInfo')
2
4
  if (!isApp('jdb')) {
3
5
  return null
4
6
  }
5
7
  if (bMallUserInfo) {
6
8
  return new Promise((resolve) => resolve(bMallUserInfo))
7
9
  }
8
10
  const requestTimeoutPromise = new Promise((resolve) => {
9
11
  setTimeout(() => {
10
12
  resolve({})
11
13
  }, 3000)
12
14
  })
13
15
  const userInfoPromise = new Promise((resolve) => {
14
16
  let result: any = {}
15
17
  try {
16
18
  if (isAndroidDevice) {
17
19
  result = JSON.parse(
18
20
  window.WebViewCommon && window.WebViewCommon.getUserInfo(),
19
21
  )
20
22
  bMallUserInfo = result
21
23
  commonParam.buId = result?.data?.buId
22
24
  resolve(result)
23
25
  } else {
24
26
  window.getUserInfoCallBack = null
25
27
  window.getUserInfoCallBack = function (callBackJson) {
26
28
  if (callBackJson) {
27
29
  result.data = JSON.parse(callBackJson)
28
30
  bMallUserInfo = result
29
31
  commonParam.buId = result?.data?.buId
30
32
  resolve(result)
31
33
  }
32
34
  }
33
35
  window?.webkit?.messageHandlers?.WebViewCommon?.postMessage({
34
36
  businessType: 'router://com.jd.jlstudio/getUserInfo',
35
37
  params: {},
36
38
  callBackName: 'getUserInfoCallBack',
37
39
  method: 'callRouterModuleWithParams',
38
40
  })
39
41
  }
40
42
  } catch (e) {
41
43
  resolve(result)
42
44
  }
43
45
  })
44
46
  return Promise.race([userInfoPromise, requestTimeoutPromise])
45
47
  process.env.NODE_ENV === 'development'
46
48
  ? {
47
49
  apolloId: '48ee955b0fb04d19b9f9fe8cb73d387f',
48
50
  apolloSecret: '0d9c76ee66b0487da4e17d3cf1d7af7a',
49
51
  }
50
52
  : {
51
53
  apolloId: '80c46fd06e4442998609d9f6a4ab96f0',
52
54
  apolloSecret: 'f36bef08bcba4683b409732095793fb2',
53
55
  }
54
56
  if (typeof window.crypto === 'object') {
55
57
  if (typeof (window.crypto as any).randomUUID === 'function') {
56
58
  return (window.crypto as any).randomUUID()
57
59
  }
58
60
  if (
59
61
  typeof (window.crypto as any).getRandomValues === 'function' &&
60
62
  typeof Uint8Array === 'function'
61
63
  ) {
62
64
  const callback = (c) => {
63
65
  const num = Number(c)
64
66
  return (
65
67
  num ^
66
68
  ((window.crypto as any).getRandomValues(new Uint8Array(1))[0] &
67
69
  (15 >> (num / 4)))
68
70
  ).toString(16)
69
71
  }
70
72
  return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, callback)
71
73
  }
72
74
  }
73
75
  let timestamp = new Date().getTime()
74
76
  let perforNow =
75
77
  (typeof window.performance !== 'undefined' &&
76
78
  window.performance.now &&
77
79
  window.performance.now() * 1000) ||
78
80
  0
79
81
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
80
82
  let random = Math.random() * 16
81
83
  if (timestamp > 0) {
82
84
  random = (timestamp + random) % 16 | 0
83
85
  timestamp = Math.floor(timestamp / 16)
84
86
  } else {
85
87
  random = (perforNow + random) % 16 | 0
86
88
  perforNow = Math.floor(perforNow / 16)
87
89
  }
88
90
  return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
89
91
  })
90
92
  skuId,
91
93
  bMallTag = 1,
92
94
  num,
93
95
  skuUuid,
94
96
  ...otherGoodParams
95
97
  let buId = commonParam.buId
96
98
  if (!buId) {
97
99
  const useInfo: any = await getBMallUserInfo()
98
100
  buId = useInfo?.data?.buId
99
101
  }
100
102
  let params: any = {
101
103
  uniformBizInfo: {
102
104
  tenantId: 1024,
103
105
  ua: 1,
104
106
  buId: buId || 456,
105
107
  bMallTag: bMallTag,
106
108
  },
107
109
  commonParam: {
108
110
  pid: 100,
109
111
  verticalCode: 'cn_retail_bmall',
110
112
  ua: 1,
111
113
  language: 'zh',
112
114
  },
113
115
  operations: [{ TheSkus: [{ Id: skuId, num: num ?? 1 }] }],
114
116
  apolloId: APOLLO.apolloId,
115
117
  apolloSecret: APOLLO.apolloSecret,
116
118
  client: 'H5',
117
119
  verticalTag: 'cn_retail_bmall',
118
120
  carttype: bMallTag == 1 ? 21 : 22,
119
121
  bMallTag: bMallTag,
120
122
  traceId: getUuid(),
121
123
  noResponse: true,
122
124
  }
123
125
  if (skuUuid) {
124
126
  params.operations[0].TheSkus[0].skuUuid = skuUuid
125
127
  }
126
128
  if (otherGoodParams.buId) {
127
129
  const uniformBizInfo = {
128
130
  buId: otherGoodParams.buId,
129
131
  }
130
132
  params.operations[0].TheSkus[0].uniformBizInfo = uniformBizInfo
131
133
  }
132
134
  if (window?.siteTransResult?.gridInfoList) {
133
135
  params = {
134
136
  ...params,
135
137
  cartLocationList: [
136
138
  {
137
139
  gridInfos:
138
140
  window?.siteTransResult?.gridInfoList &&
139
141
  JSON.parse(window?.siteTransResult?.gridInfoList),
140
142
  areaIdSet:
141
143
  window?.siteTransResult?.area &&
142
144
  window?.siteTransResult?.area?.split('-'),
143
145
  },
144
146
  ],
145
147
  }
146
148
  }
147
149
  return params
@@ -0,0 +1 @@
1
+ export const getBMallUserInfo = () => {
2
  return new Promise((resolve) => {
1
3
  resolve({})
2
4
  })
3
5
  return {}
@@ -0,0 +1 @@
1
+ import { api } from '../api'
2
  clientVersion: '11.0.0',
1
3
  client: 'wh5',
2
4
  area: '1_72_2799_0',
3
5
  loginType: '2',
4
6
  uuid: UUID,
5
7
  functionId: string,
6
8
  body = {},
7
9
  options = {},
8
10
  requestOptions = {},
9
11
  const params = Object.assign(
10
12
  {},
11
13
  {
12
14
  t: Date.now(),
13
15
  functionId,
14
16
  appid: 'shop_m_jd_com',
15
17
  body: JSON.stringify(body),
16
18
  },
17
19
  clientParams,
18
20
  options,
19
21
  )
20
22
  console.warn(
21
23
  'fetchGateway url:' + api.apiFunc + ',functionId:' + params.functionId,
22
24
  )
23
25
  return http.post(api.apiFunc, params, requestOptions)
@@ -0,0 +1 @@
1
+ const defaultOptions = {
2
  timeout: 5000,
1
3
  jsonpCallback: 'callback',
2
4
  return `jsonp_${Date.now()}_${Math.ceil(Math.random() * 100000)}`
3
5
  try {
4
6
  delete window[functionName]
5
7
  } catch (e) {
6
8
  window[functionName] = undefined
7
9
  }
8
10
  const script = document.getElementById(scriptId)
9
11
  document.getElementsByTagName('head')[0].removeChild(script)
10
12
  const timeout =
11
13
 
12
14
  options.timeout != null ? options.timeout : defaultOptions.timeout
13
15
  const jsonpCallback =
14
16
 
15
17
  options.jsonpCallback != null
16
18
  ? options.jsonpCallback
17
19
  : defaultOptions.jsonpCallback
18
20
  let timeoutId: string | number | NodeJS.Timeout | undefined
19
21
  return new Promise((resolve, reject) => {
20
22
  const callbackFunction = generateCallbackFunction()
21
23
  window[callbackFunction] = function (response: any) {
22
24
  resolve({
23
25
  ok: true,
24
26
  json: function () {
25
27
  return Promise.resolve(response)
26
28
  },
27
29
  })
28
30
  if (timeoutId) clearTimeout(timeoutId)
29
31
  removeScript(jsonpCallback + '_' + callbackFunction)
30
32
  clearFunction(callbackFunction)
31
33
  }
32
34
  url += url.indexOf('?') === -1 ? '?' : '&'
33
35
  const jsonpScript = document.createElement('script')
34
36
  jsonpScript.setAttribute(
35
37
  'src',
36
38
  url + jsonpCallback + '=' + callbackFunction,
37
39
  )
38
40
  jsonpScript.id = jsonpCallback + '_' + callbackFunction
39
41
  document.getElementsByTagName('head')[0].appendChild(jsonpScript)
40
42
  timeoutId = setTimeout(() => {
41
43
  reject(new Error(`JSONP request to ${url} timed out`))
42
44
  clearFunction(callbackFunction)
43
45
  removeScript(jsonpCallback + '_' + callbackFunction)
44
46
  }, timeout)
45
47
  })
@@ -0,0 +1 @@
1
+ import { ServiceInterFace } from '../../interface'
2
  AppVerifyColorList,
1
3
  SHOP_VERIFY_CODE,
2
4
  PAGES_VERIFY_CODE,
3
5
  B2B_VERITY_CODE,
4
6
  PAGES_DOMAIN,
5
7
  B2BColorFunctionIdList,
6
8
  public fmInfo: {
7
9
  eid?: string
8
10
  fp?: string
9
11
  jsToken?: string
10
12
  sdkToken?: string
11
13
  }
12
14
  public api: ServiceInterFace.HttpApi
13
15
  public paramsSignInstance: any
14
16
  public paramsSignPagesInstance: any
15
17
  public paramsSignBmallInstance: any
16
18
  public isPageDomain: boolean
17
19
  constructor() {
18
20
  this.api = api
19
21
  this.isPageDomain = location?.hostname === PAGES_DOMAIN
20
22
  this.paramsSignInstance = undefined
21
23
  this.paramsSignPagesInstance = undefined
22
24
  this.paramsSignBmallInstance = undefined
23
25
  this.fmInfo = {}
24
26
  this._initSign()
25
27
  }
26
28
 
27
29
  _getMobileJsToken(): Promise<{
28
30
  ok: boolean
29
31
  data?: any
30
32
  error?: any
31
33
  }> {
32
34
  return new Promise((resolve, reject) => {
33
35
  try {
34
36
  if (window?.getJsToken) {
35
37
  window.getJsToken(function (res) {
36
38
  console.log('JS token 获取结果:', res)
37
39
  resolve({
38
40
  ok: true,
39
41
  data: res,
40
42
  })
41
43
  }, 600)
42
44
  } else {
43
45
  reject({
44
46
  ok: false,
45
47
  error: '没有识别到getJsToken全局方法',
46
48
  })
47
49
  }
48
50
  } catch (e) {
49
51
  console.log('获取指纹JS token 异常', e)
50
52
  reject({
51
53
  ok: false,
52
54
  error: e,
53
55
  })
54
56
  }
55
57
  })
56
58
  }
57
59
 
58
60
  async getFmInfo() {
59
61
  try {
60
62
  const { ok, data } = await this._getMobileJsToken()
61
63
  this.fmInfo = ok && data ? data : this.fmInfo
62
64
  return this.fmInfo
63
65
  } catch (e) {
64
66
  console.log('获取指纹信息异常', e)
65
67
  return this.fmInfo
66
68
  }
67
69
  }
68
70
 
69
71
  _initSign() {
70
72
  this.paramsSignInstance = window.PSign
71
73
  ? window.PSign
72
74
  : window.ParamsSign
73
75
  ? this._initParamsSignInstance(SHOP_VERIFY_CODE)
74
76
  : null
75
77
  this.paramsSignPagesInstance = window.ParamsSign
76
78
  ? this._initParamsSignInstance(PAGES_VERIFY_CODE)
77
79
  : null
78
80
  this.paramsSignBmallInstance = window.ParamsSign
79
81
  ? this._initParamsSignInstance(B2B_VERITY_CODE)
80
82
  : null
81
83
  }
82
84
 
83
85
  _initParamsSignInstance(appId) {
84
86
  return new window.ParamsSign({
85
87
  appId: appId,
86
88
  debug: false,
87
89
  preRequest: false,
88
90
  onSign: ({ code }) => {
89
91
  console.log('签名可用率监控', code)
90
92
  },
91
93
  onRequestTokenRemotely: ({ code, message }) => {
92
94
  console.log('算法接口可用率监控', code, message)
93
95
  },
94
96
  onRequestToken: ({ code, message }) => {
95
97
  console.log('token的可用率监控', code, message)
96
98
  },
97
99
  })
98
100
  }
99
101
 
100
102
  paramsSign(data) {
101
103
  try {
102
104
  console.log('获取加签参数', data, this.paramsSignInstance)
103
105
  if (!data || typeof data !== 'object' || !this.paramsSignInstance) {
104
106
  return Promise.resolve(data)
105
107
  } else {
106
108
  const param: any = {
107
109
  appid: data.appid,
108
110
  client: data.client,
109
111
  clientVersion: data.clientVersion,
110
112
  functionId: data.functionId,
111
113
  t: data.t,
112
114
  sign: data?.sign,
113
115
  jsonp: data?.jsonp,
114
116
  }
115
117
  data && data.body && (param.body = sha256(data.body).toString())
116
118
  console.log(
117
119
  '获取加签前的参数处理',
118
120
  param,
119
121
  '获取下发data',
120
122
  data,
121
123
  '获取加签实例',
122
124
  this.paramsSignInstance,
123
125
  this.paramsSignPagesInstance,
124
126
  )
125
127
  return this.isPageDomain &&
126
128
  this.paramsSignPagesInstance &&
127
129
  AppVerifyColorList.includes(param.functionId)
128
130
  ? this.paramsSignPagesInstance.sign(param)
129
131
  : this.paramsSignBmallInstance &&
130
132
  B2BColorFunctionIdList.includes(param.functionId)
131
133
  ? this.paramsSignBmallInstance.sign(param)
132
134
  : this.paramsSignInstance.sign(param)
133
135
  }
134
136
  } catch (e) {
135
137
  console.log('获取加签参数结果异常', e)
136
138
  return Promise.resolve(data)
137
139
  }
138
140
  }
@@ -0,0 +1 @@
1
+ import global from '../../common'
2
  WXAPP_VERIFY_CODE,
1
3
  WxappVerifyColorList
2
4
  public fmInfo: {
3
5
  eid?: string
4
6
  fp?: string
5
7
  jsToken?: string
6
8
  sdkToken?: string
7
9
  }
8
10
  constructor() {
9
11
  this.fmInfo = {}
10
12
  }
11
13
 
12
14
  async getFmInfo() {
13
15
  if (!this.fmInfo["eid"]) {
14
16
  try {
15
17
  const getFmRes = await global.wxAppFingerReportInstance.getFm();
16
18
  console.log("获取指纹信息", getFmRes);
17
19
  this.fmInfo = getFmRes;
18
20
  return this.fmInfo;
19
21
  } catch (e) {
20
22
  console.log("获取指纹信息异常", e);
21
23
  return this.fmInfo;
22
24
  }
23
25
  } else {
24
26
  return this.fmInfo;
25
27
  }
26
28
  }
27
29
 
28
30
  paramsSign(data) {
29
31
  return global?.wxAppParamsSignInstance
30
32
  ? global.wxAppParamsSignInstance?.paramsSign({
31
33
  color: WxappVerifyColorList.includes(data?.functionId),
32
34
  verifyCode: WXAPP_VERIFY_CODE,
33
35
  data,
34
36
  })
35
37
  : Promise.resolve(data)
36
38
  }
@@ -0,0 +1 @@
1
+ export const HttpStatus = {
2
  SUCCESS: 200,
1
3
  CREATED: 201,
2
4
  ACCEPTED: 202,
3
5
  CLIENT_ERROR: 400,
4
6
  AUTHENTICATE: 401,
5
7
  FORBIDDEN: 403,
6
8
  NOT_FOUND: 404,
7
9
  SERVER_ERROR: 500,
8
10
  BAD_GATEWAY: 502,
9
11
  SERVICE_UNAVAILABLE: 503,
10
12
  GATEWAY_TIMEOUT: 504,
11
13
  [HttpStatus.NOT_FOUND]: '请求资源不存在',
12
14
  [HttpStatus.BAD_GATEWAY]: '服务端异常,请稍后重试',
13
15
  [HttpStatus.FORBIDDEN]: '没有权限访问',
14
16
  [HttpStatus.AUTHENTICATE]: '需要鉴权',
15
17
  [HttpStatus.SUCCESS]: '成功',
16
18
  'whx_getShopHomeFloorInfo',
17
19
  'whx_searchWare',
18
20
  'shopGuessYouLike',
19
21
  'whx_getMShopCategory',
20
22
  'whx_newWareList',
21
23
  'getShopHomePromotionWebPage',
22
24
  'whx_getShopCampaignPage',
23
25
  'whx_getPromotionWares',
24
26
  'whx_buyerShowPage',
25
27
  'whx_getShopGwredPage',
26
28
  'whx_getShopSpeciSecKillPage',
27
29
  'whx_getSignInfo',
28
30
  'whx_getSignPrize',
29
31
  'getShopHomeFloorInfo',
30
32
  'shopGuessYouLike',
31
33
  'getShopHomePromotionWebPage',
32
34
  'getVipDetail',
33
35
  'getShopCategory',
34
36
  'getShopNavigationCategory',
35
37
  'getPagePreview',
36
38
  'bmall_cart',
37
39
  'bmall_getOmittedProduct',
38
40
  'bmall_cartAdd',
39
41
  'bmall_cartChange',
40
42
  'bmall_cartRemove',
41
43
  "whx_getShopHomeFloorInfo",
42
44
  "whx_searchWare",
43
45
  "shopGuessYouLike",
44
46
  "whx_getMShopCategory",
45
47
  "whx_newWareList",
46
48
  "getShopHomePromotionWebPage",
47
49
  "whx_getShopCampaignPage",
48
50
  "whx_getPromotionWares",
49
51
  "whx_buyerShowPage"
50
52
  'getShopHomeFloorInfo',
51
53
  'getShopCategory',
52
54
  'getShopNavigationCategory',
53
55
  'receiveShopCoupon',
54
56
  'getShopHomePromotionWebPage',
55
57
  'shopGuessYouLike',
56
58
  'addRemind',
57
59
  'cancelRemind',
58
60
  'getVipDetail',
59
61
  'shopDetail',
60
62
  'address_queryAddress',
61
63
  'shopMemberSprintJoinActivity',
62
64
  'shopMemberSprintReceivePrize',
63
65
  'customerCenterDispatch'
64
66
  'bmall_cart',
65
67
  'bmall_getOmittedProduct',
66
68
  'bmall_cartAdd',
67
69
  'bmall_cartChange',
68
70
  'bmall_cartRemove',
69
71
  SHOP_COLOR_APPID: 'shop_m_jd_com',
70
72
  JSHOPX_COLOR_APPID: 'jshopx_jd_com',
71
73
  PAGES_COLOR_APPID: 'pages_jd_com',
72
74
  B2B_COLOR_APPID: 'b2b',
73
75
  SHOP_MEMBER_COLOR_APPID: 'shopmember_m_jd_com'
@@ -0,0 +1 @@
1
+ import Taro, { RequestTask } from '@tarojs/taro'
2
  jsonHeader = 'application/json;charset=utf-8',
1
3
  formDataHeader = 'application/x-www-form-urlencoded',
2
4
  public fmInfo: {
3
5
  eid?: string
4
6
  fp?: string
5
7
  jsToken?: string
6
8
  sdkToken?: string
7
9
  }
8
10
  public api: ServiceInterFace.HttpApi
9
11
  constructor() {
10
12
  this._init()
11
13
  this.api = api
12
14
  }
13
15
  _init(): void {
14
16
  httpInterceptors.forEach((item) => {
15
17
  Taro.addInterceptor((chain) => item(chain))
16
18
  })
17
19
  }
18
20
 
19
21
  get(
20
22
  url: string,
21
23
  data: any = null,
22
24
  otherOptions = {},
23
25
  ): Promise<Taro.request.SuccessCallbackResult<any>> {
24
26
  return this.request({ url, data, method: 'GET', ...otherOptions })
25
27
  }
26
28
 
27
29
  post(
28
30
  url: string,
29
31
  data: any = null,
30
32
  otherOptions = {},
31
33
  ): Promise<Taro.request.SuccessCallbackResult<any>> {
32
34
  return this.request({ url, data, method: 'POST', ...otherOptions })
33
35
  }
34
36
 
35
37
  async request({
36
38
  url,
37
39
  method = 'POST',
38
40
  timeout = 7000,
39
41
  isColorVerify = false,
40
42
  ...otherOptions
41
43
  }): Promise<Taro.request.SuccessCallbackResult<any>> {
42
44
  const { header: otherHeader, ...otherOpts } = otherOptions
43
45
  const header = {
44
46
  'content-type':
45
47
  method === 'POST'
46
48
  ? RequestHeaderContentType.formDataHeader
47
49
  : RequestHeaderContentType.jsonHeader,
48
50
  ...otherHeader,
49
51
  }
50
52
  const getReqData = otherOptions.data
51
53
  if (url === this.api.apiFunc && typeof getReqData === 'object') {
52
54
  const { functionId } = getReqData
53
55
  console.log('获取当前是否需要color加固', isColorVerify, functionId)
54
56
  if (isColorVerify) {
55
57
  const { h5st } = await colorSign.paramsSign(getReqData)
56
58
  h5st && (getReqData.h5st = encodeURI(h5st))
57
59
  console.log(`${functionId}的apiReq_h5st===>:${h5st}`)
58
60
  }
59
61
  const { jsToken } = await colorSign.getFmInfo()
60
62
  jsToken && (getReqData['x-api-eid-token'] = jsToken)
61
63
  }
62
64
  const param: any = {
63
65
  url,
64
66
  method,
65
67
  timeout,
66
68
  header,
67
69
  credentials: 'include',
68
70
  ...otherOpts,
69
71
  }
70
72
  const requestTask = Taro.request(param)
71
73
  const requestTimeoutPromise =
72
74
  new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
73
75
  setTimeout(() => {
74
76
  resolve({
75
77
  statusCode: 500,
76
78
  resTimeoutState: true,
77
79
  errMsg: 'request timeout',
78
80
  })
79
81
  }, timeout)
80
82
  })
81
83
  return Promise.race([requestTask, requestTimeoutPromise]).then(
82
84
  (res: any) => {
83
85
  if (res && res.statusCode === 500 && res.resTimeoutState) {
84
86
  console.warn('request 请求超时 url:' + url)
85
87
  requestTask.abort && requestTask.abort()
86
88
  }
87
89
  return res
88
90
  },
89
91
  )
90
92
  }
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro'
2
  const requestParams = chain.requestParams
1
3
  const { header } = requestParams
2
4
  const userInfo = global?.info?.userInfo
3
5
  console.log('获取用户信息', userInfo)
4
6
  if (userInfo) {
5
7
  header[
6
8
  'Cookie'
7
9
  ] = `pin=${userInfo.encodePin};ticket=${userInfo.ptkey};pt_pin=${userInfo.encodePin};pt_key=${userInfo.ptkey};${global.info.cookiesStr}`
8
10
  }
9
11
  return chain.proceed(requestParams).then((res) => {
10
12
  if (res.statusCode === HttpStatus.SUCCESS) {
11
13
  return res
12
14
  } else {
13
15
  return {
14
16
  statusCode: res.statusCode,
15
17
  msg: httpStatusMsg[res.statusCode] || defaultHttpStatusMsg,
16
18
  }
17
19
  }
18
20
  })
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro'
2
  const requestParams = chain.requestParams
1
3
  return chain.proceed(requestParams).then((res) => {
2
4
  if (res.statusCode === HttpStatus.SUCCESS) {
3
5
  return res
4
6
  } else {
5
7
  return {
6
8
  statusCode: res.statusCode,
7
9
  msg: httpStatusMsg[res.statusCode] || defaultHttpStatusMsg,
8
10
  }
9
11
  }
10
12
  })
@@ -0,0 +1 @@
1
+ import Http from './http'