@conecli/cone-render 0.10.1-shop-beta.22 → 0.10.1-shop-beta.24

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 (121) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/accessibility.h5.ts +1 -0
  3. package/dist/common/accessibility.ts +0 -0
  4. package/dist/common/const.ts +1 -1
  5. package/dist/common/index.h5.ts +1 -1
  6. package/dist/common/index.jd.ts +1 -1
  7. package/dist/common/index.ts +1 -1
  8. package/dist/common/index.weapp.ts +1 -1
  9. package/dist/common/jdplayerSdk.weapp.tsx +1 -0
  10. package/dist/common/jssdk.weapp.ts +1 -0
  11. package/dist/common/pageType.ts +1 -1
  12. package/dist/common/token/token.jd.ts +1 -1
  13. package/dist/components/ErrorBoundary.tsx +1 -1
  14. package/dist/components/base/CountDown/index.tsx +1 -1
  15. package/dist/components/base/CustomVideo/index.tsx +1 -1
  16. package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
  17. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  18. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  19. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  20. package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
  21. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  22. package/dist/components/base/JdLoading/index.module.scss +0 -2
  23. package/dist/components/base/JdLoading/index.tsx +1 -1
  24. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  25. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  26. package/dist/components/base/LazyLoadImage/index.tsx +1 -1
  27. package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
  28. package/dist/components/base/NetworkDataError/const.ts +1 -1
  29. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  30. package/dist/components/base/Price/Base/index.tsx +1 -1
  31. package/dist/components/base/Price/Double/index.module.scss +18 -0
  32. package/dist/components/base/Price/Double/index.tsx +1 -1
  33. package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
  34. package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
  35. package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
  36. package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
  37. package/dist/components/floorItem.tsx +1 -1
  38. package/dist/components/isv/Floor/index.tsx +1 -1
  39. package/dist/components/remoteFloorItem.tsx +1 -1
  40. package/dist/config/env.ts +1 -1
  41. package/dist/interface/common.ts +1 -1
  42. package/dist/interface/component.ts +1 -1
  43. package/dist/interface/jumpEventReport.ts +1 -1
  44. package/dist/interface/service.ts +1 -1
  45. package/dist/jumpEventReport/base.ts +1 -1
  46. package/dist/jumpEventReport/const.ts +1 -1
  47. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  48. package/dist/jumpEventReport/index.ts +1 -1
  49. package/dist/jumpEventReport/index.weapp.ts +1 -1
  50. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  51. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  52. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
  53. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  54. package/dist/jumpEventReport/web/report.ts +1 -1
  55. package/dist/jumpEventReport/web.base.ts +1 -1
  56. package/dist/jumpEventReport/web.jd.ts +1 -1
  57. package/dist/jumpEventReport/web.pc.ts +1 -1
  58. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  59. package/dist/language/en_US.json +179 -83
  60. package/dist/language/zh_CN.json +178 -82
  61. package/dist/language/zh_HK.json +178 -82
  62. package/dist/libs/openShopBridge.js +161 -0
  63. package/dist/libs/openShopBridge.min.js +1 -0
  64. package/dist/libs/taroAppReport.js +2 -2
  65. package/dist/modules/ContainerFloorList/index.h5.module.scss +16 -2
  66. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  67. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  68. package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
  69. package/dist/open/api/index.ts +1 -1
  70. package/dist/open/api/shopMember.weapp.ts +1 -0
  71. package/dist/open/api/track.ts +1 -1
  72. package/dist/open/api/util.ts +1 -1
  73. package/dist/open/components/index.ts +1 -1
  74. package/dist/open/index.ts +1 -1
  75. package/dist/sass/app.h5.scss +6 -1
  76. package/dist/service/fetchGateway.ts +1 -1
  77. package/dist/service/fetchGateway.weapp.ts +1 -1
  78. package/dist/service/fetchJsonp.ts +1 -1
  79. package/dist/service/fetchJsonp.weapp.ts +1 -0
  80. package/dist/service/http/h5Http.ts +1 -1
  81. package/dist/service/http/http.ts +1 -1
  82. package/dist/service/http/httpInterceptors.weapp.ts +1 -0
  83. package/dist/service/requestServer.h5.ts +1 -1
  84. package/dist/service/requestServer.ts +1 -1
  85. package/dist/service/requestServer.weapp.ts +1 -1
  86. package/dist/utils/connectNativeJsBridge.ts +1 -1
  87. package/dist/utils/h5Utils.ts +1 -1
  88. package/dist/utils/harmonyCallRouter.h5.ts +1 -0
  89. package/dist/utils/harmonyCallRouter.ts +0 -0
  90. package/dist/utils/index.h5.ts +1 -1
  91. package/dist/utils/index.ts +1 -1
  92. package/dist/utils/index.weapp.ts +1 -1
  93. package/dist/utils/intersectionObserver.ts +1 -1
  94. package/dist/utils/sColor.weapp.ts +1 -0
  95. package/dist/utils/utils.ts +1 -1
  96. package/package.json +13 -15
  97. package/dist/common/index.dynamic.ts +0 -1
  98. package/dist/components/base/Dialog/index.dynamic.module.scss +0 -126
  99. package/dist/components/base/Dialog/index.dynamic.tsx +0 -1
  100. package/dist/components/base/DynamicTest/index.dynamic.module.scss +0 -15
  101. package/dist/components/base/DynamicTest/index.module.scss +0 -16
  102. package/dist/components/base/DynamicTest/index.tsx +0 -1
  103. package/dist/components/base/LazyLoadImage/index.dynamic.module.scss +0 -40
  104. package/dist/components/base/LazyLoadImage/index.dynamic.tsx +0 -1
  105. package/dist/components/base/NetworkDataError/index.dynamic.module.scss +0 -95
  106. package/dist/components/base/NetworkDataError/index.dynamic.tsx +0 -1
  107. package/dist/components/base/Price/Base/index.dynamic.module.scss +0 -63
  108. package/dist/components/base/Price/Base/index.dynamic.tsx +0 -1
  109. package/dist/components/base/Price/Double/index.dynamic.module.scss +0 -172
  110. package/dist/components/base/Price/Double/index.dynamic.tsx +0 -1
  111. package/dist/jumpEventReport/index.dynamic.ts +0 -1
  112. package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
  113. package/dist/open/api/shopMember.dynamic.ts +0 -1
  114. package/dist/open/components/index.dynamic.ts +0 -1
  115. package/dist/sass/app.dynamic.scss +0 -306
  116. package/dist/service/fetchGateway.h5.ts +0 -1
  117. package/dist/service/fetchJsonp.h5.ts +0 -1
  118. package/dist/service/http/colorSign.dynamic.ts +0 -1
  119. package/dist/utils/connectNativeJsBridge.dynamic.ts +0 -1
  120. package/dist/utils/priceUtils.js +0 -1
  121. /package/dist/utils/{sColor.js → sColor.ts} +0 -0
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro';
2
1
  APPID,
3
2
  JshopxColorFunctionIdList,
4
3
  PagesColorFunctionIdList,
5
4
  PAGES_DOMAIN,
6
5
  B2BColorFunctionIdList,
7
6
  MobileVerifyColorList,
8
7
  AppVerifyColorList,
9
8
  JshopxVerifyColorList,
10
9
  BMallVerifyColorList,
11
10
  shopMemberColorFunctionIdList,
12
11
  isLanguageForEn,
13
12
  isJdApp,
14
13
  showSuccessToast,
15
14
  showFailToast,
16
15
  isH5,
17
16
  isMin,
18
17
  isPc,
19
18
  cookiesStr: '',
20
19
  requestHeaderContentType: {
21
20
  jsonHeader: {
22
21
  'content-type': 'application/json;charset=utf-8',
23
22
  },
24
23
  formDataHeader: {
25
24
  'content-type': 'application/x-www-form-urlencoded',
26
25
  },
27
26
  },
28
27
  requestBaseParam: {
29
28
  data: null,
30
29
  header: {
31
30
  'content-type': 'application/json;charset=utf-8',
32
31
  },
33
32
  },
34
33
  timeOut: 7000,
35
34
  apiClientParams: {
36
35
  appid: 'wx_mini_app',
37
36
  clientVersion: '11.0.0',
38
37
  client: 'wh5',
39
38
  area: '1_72_2799_0',
40
39
  screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
41
40
  getSystemInfo?.screenHeight * devicePixelRatio,
42
41
  )}`,
43
42
  uuid: "-1",
44
43
  loginType: '11',
45
44
  },
46
45
  public addressFetchInfo: {
47
46
  reqState: boolean;
48
47
  promiseInstance: null | Promise<any>;
49
48
  };
50
49
  public getPromotionConfig: {
51
50
  projectId: null | string | number;
52
51
  pageId: null | string | number;
53
52
  };
54
53
  public resInfo: ServiceInterFace.HttpRequestInfo;
55
54
  public api: ServiceInterFace.HttpApi;
56
55
  public isPageDomain: boolean;
57
56
  public verifyColorList: string[];
58
57
  constructor(opt) {
59
58
  this._init();
60
59
  this.addressFetchInfo = {
61
60
  reqState: false,
62
61
  promiseInstance: null,
63
62
  };
64
63
  this.getPromotionConfig = {
65
64
  projectId: null,
66
65
  pageId: null,
67
66
  };
68
67
  this._userAreaUpdateListen();
69
68
  this.resInfo = this._getResConfig(opt);
70
69
  this.api = api;
71
70
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
72
71
  this.verifyColorList = [
73
72
  ...MobileVerifyColorList,
74
73
  ...AppVerifyColorList,
75
74
  ...JshopxVerifyColorList,
76
75
  ...BMallVerifyColorList,
77
76
  ];
78
77
  }
79
78
  _init(): void {
80
79
  httpInterceptors.forEach((item) => {
81
80
  Taro.addInterceptor((chain) => item(chain));
82
81
  });
83
82
  }
84
83
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
85
84
  return Object.assign({}, DefaultConfig, opt);
86
85
  }
87
86
 
88
87
  _userAreaUpdateListen() {
89
88
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
90
89
  this.updateApiClientParamsResInfo(areaInfo);
91
90
  });
92
91
  }
93
92
  updateApiClientParamsResInfo(opt = {}) {
94
93
  const { area, realTimeArea, ...others } = opt;
95
94
  this.resInfo.apiClientParams = {
96
95
  ...this.resInfo.apiClientParams,
97
96
  ...others,
98
97
  };
99
98
  area && area !== '' && (this.resInfo.apiClientParams.area = area);
100
99
  realTimeArea &&
101
100
  realTimeArea !== '' &&
102
101
  (this.resInfo.apiClientParams.realTimeArea = realTimeArea);
103
102
  }
104
103
 
105
104
  checkFunctionIdToReturnAppId(functionId) {
106
105
  if (JshopxColorFunctionIdList.includes(functionId)) {
107
106
  return APPID.JSHOPX_COLOR_APPID;
108
107
  } else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
109
108
  return APPID.PAGES_COLOR_APPID;
110
109
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
111
110
  return APPID.SHOP_MEMBER_COLOR_APPID;
112
111
  } else if (B2BColorFunctionIdList.includes(functionId)) {
113
112
  return APPID.B2B_COLOR_APPID;
114
113
  } else if (isPc) {
115
114
  return APPID.MALL_COLOR_APPID;
116
115
  } else {
117
116
  return APPID.SHOP_COLOR_APPID;
118
117
  }
119
118
  }
120
119
 
121
120
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
122
121
  if (functionId === 'receiveShopCoupon') {
123
122
  clientParams = Object.assign(
124
123
  {},
125
124
  {
126
125
  loginType: '1',
127
126
  loginWQBiz: WXAPP_BIZ_KEY,
128
127
  },
129
128
  clientParams,
130
129
  );
131
130
  }
132
131
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
133
132
  const isColorVerify = this.verifyColorList.includes(functionId);
134
133
  const getReqData = {
135
134
  functionId: functionId,
136
135
  body: JSON.stringify(bodyParams),
137
136
  t: Date.now(),
138
137
  ...apiClientParams,
139
138
  };
140
139
  return http
141
140
  .request({
142
141
  url: this.api.apiFunc,
143
142
  data: getReqData,
144
143
  isColorVerify,
145
144
  })
146
145
  .then((res: ServiceInterFace.RequestPromiseRes) => {
147
146
  const { statusCode, data } = res;
148
147
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
149
148
  ok: true,
150
149
  };
151
150
  if (statusCode === 200 && data) {
152
151
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
153
152
  ? Number(res.data.code)
154
153
  : -1;
155
154
  const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
156
155
  ? Number(res.data.subCode)
157
156
  : -1;
158
157
  if (
159
158
  data.success === true ||
160
159
  data.isSuccess ||
161
160
  resCode === 0 ||
162
161
  resCode === 200 ||
163
162
  subCode === 0
164
163
  ) {
165
164
  changeRes = {
166
165
  result: Object.prototype.hasOwnProperty.call(data, 'result')
167
166
  ? data.result
168
167
  : Object.prototype.hasOwnProperty.call(data, 'data')
169
168
  ? data.data
170
169
  : data,
171
170
  code: data.code || 200,
172
171
  ok: true,
173
172
  source: data,
174
173
  };
175
174
  return changeRes;
176
175
  } else {
177
176
  changeRes = {
178
177
  ...data,
179
178
  ok: false,
180
179
  statusCode: res.statusCode,
181
180
  };
182
181
  return changeRes;
183
182
  }
184
183
  } else {
185
184
  changeRes = {
186
185
  ...data,
187
186
  ok: false,
188
187
  statusCode: res.statusCode,
189
188
  };
190
189
  return changeRes;
191
190
  }
192
191
  })
193
192
  .catch((res) => {
194
193
  return {
195
194
  ...res,
196
195
  ok: false,
197
196
  } as ServiceInterFace.RequestResponseFormatRes;
198
197
  });
199
198
  }
200
199
 
201
200
  async receiveCoupon(param = {}, clientParams) {
202
201
  console.warn('receiveCoupon 方法在微信京购小程序环境未经验证,请不要使用!');
203
202
  return await this.gatewayReq(
204
203
  'receiveShopCoupon',
205
204
  {
206
205
  operation: '3',
207
206
  ...param,
208
207
  },
209
208
  { ...clientParams },
210
209
  );
211
210
  }
212
211
 
213
212
  getCustomerCenterDispatch(params = {}) {
214
213
  return this.gatewayReq('customerCenterDispatch', params, {
215
214
  clientVersion: '9.2.0',
216
215
  client: 'H5',
217
216
  uuid: 88888,
218
217
  appid: 'shopmember_m_jd_com',
219
218
  });
220
219
  }
221
220
 
222
221
  batchAddCart(...args) {
223
222
  let skuIds, num, showToast, giftCard;
224
223
  if (['number', 'string'].includes(typeof args[0])) {
225
224
  [skuIds, num = 1, showToast = true, giftCard = false] = args;
226
225
  } else if (typeof args[0] === 'object' && args[0] !== null) {
227
226
  const params = args[0];
228
227
  skuIds = params.skuIds;
229
228
  num = params.num || 1;
230
229
  showToast = params.showToast !== undefined ? params.showToast : true;
231
230
  giftCard = params.giftCard !== undefined ? params.giftCard : false;
232
231
  } else {
233
232
  console.error('batchAddCart() Invalid arguments!', args);
234
233
  const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
235
234
  showFailToast({
236
235
  title: msg,
237
236
  });
238
237
  return Promise.resolve({
239
238
  ok: false,
240
239
  msg,
241
240
  });
242
241
  }
243
242
  const addToWhereText = giftCard ? '购物清单' : '购物车';
244
243
  const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
245
244
  const failMsg = isLanguageForEn
246
245
  ? 'Please retry later'
247
246
  : `加入${addToWhereText}失败,请稍后重试!`;
248
247
  if (skuIds) {
249
248
  return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
250
249
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
251
250
  if (res?.ok) {
252
251
  if (showToast && !res?.isOpenApp)
253
252
  showSuccessToast({
254
253
  title: successMsg,
255
254
  });
256
255
  } else {
257
256
  showToast &&
258
257
  showFailToast({
259
258
  title: res?.errMsg || failMsg,
260
259
  });
261
260
  }
262
261
  return Promise.resolve(res);
263
262
  })
264
263
  .catch((e) => {
265
264
  console.log('调用加购方法异常=======>', e);
266
265
  return Promise.resolve({
267
266
  ok: false,
268
267
  msg: failMsg,
269
268
  });
270
269
  });
271
270
  } else {
272
271
  return Promise.resolve({
273
272
  ok: false,
274
273
  msg: failMsg,
275
274
  });
276
275
  }
277
276
  }
278
277
 
279
278
  async giftCardAddCart(skuList, num) {
280
279
  return this.gatewayReq('giftCardAddCart', {
281
280
  skuList,
282
281
  num: Number(num),
283
282
  });
284
283
  }
285
284
 
286
285
  _addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
287
286
  return new Promise((resolve) => {
288
287
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
289
288
  if (productIdsArr.length > 0) {
290
289
  if (giftCard) {
291
290
  this.giftCardAddCart(productIdsArr, addCardNum)
292
291
  .then((res) => {
293
292
  if (res?.code === '0' && res?.result?.value) {
294
293
  resolve({
295
294
  ok: true,
296
295
  });
297
296
  } else {
298
297
  resolve({
299
298
  ok: false,
300
299
  msg: '加购失败,请稍后重试',
301
300
  });
302
301
  }
303
302
  })
304
303
  .catch((e) => {
305
304
  console.error('礼品卡加车失败: ', e);
306
305
  resolve({
307
306
  ok: false,
308
307
  msg: '加购失败,请稍后重试',
309
308
  });
310
309
  });
311
310
  } else if (isJdApp) {
312
311
  console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
313
312
  } else if (isMin) {
314
313
  console.log('==========>', '京购批量加车!');
315
314
  const productsAddCartList = productIdsArr.map((skuItem) => {
316
315
  return {
317
316
  skuId: skuItem,
318
317
  buyNum: addCardNum,
319
318
  };
320
319
  });
321
320
  global.wxAppBizInstance
322
321
  .addCart({ commArr: productsAddCartList })
323
322
  .then((res) => {
324
323
  console.log('dealCartSuccess: ', res);
325
324
  resolve({
326
325
  ok: true,
327
326
  msg: '已加入购物车!',
328
327
  data: res,
329
328
  });
330
329
  })
331
330
  .catch((e) => {
332
331
  console.log('京购小程序批量加车失败dealCartFail: ', e);
333
332
  resolve({
334
333
  ok: false,
335
334
  msg: '加购失败,请稍后重试',
336
335
  });
337
336
  });
338
337
  } else {
339
338
  console.log('==========>', 'M站批量加车!');
340
339
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
341
340
  }
342
341
  } else {
343
342
  resolve({
344
343
  ok: false,
345
344
  msg: '加购sku不能为空',
346
345
  });
347
346
  }
348
347
  });
349
348
  }
350
349
 
351
350
  productAddToCart() {
352
351
  return Promise.resolve({
353
352
  ok: false,
354
353
  msg: 'productAddToCart暂不支持小程序',
355
354
  });
356
355
  }
356
+ import Taro from '@tarojs/taro';
357
357
  WxappVerifyColorList,
358
358
  isLanguageForEn,
359
359
  isJdApp,
360
360
  showSuccessToast,
361
361
  showFailToast,
362
362
  isMin,
363
363
  cookiesStr: '',
364
364
  requestHeaderContentType: {
365
365
  jsonHeader: {
366
366
  'content-type': 'application/json;charset=utf-8',
367
367
  },
368
368
  formDataHeader: {
369
369
  'content-type': 'application/x-www-form-urlencoded',
370
370
  },
371
371
  },
372
372
  requestBaseParam: {
373
373
  data: null,
374
374
  header: {
375
375
  'content-type': 'application/json;charset=utf-8',
376
376
  },
377
377
  },
378
378
  timeOut: 7000,
379
379
  apiClientParams: {
380
380
  appid: 'wx_mini_app',
381
381
  clientVersion: '11.0.0',
382
382
  client: 'wh5',
383
383
  area: '1_72_2799_0',
384
384
  screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
385
385
  getSystemInfo?.screenHeight * devicePixelRatio,
386
386
  )}`,
387
387
  uuid: '-1',
388
388
  loginType: '11',
389
389
  },
390
390
  public addressFetchInfo: {
391
391
  reqState: boolean;
392
392
  promiseInstance: null | Promise<any>;
393
393
  };
394
394
  public getPromotionConfig: {
395
395
  projectId: null | string | number;
396
396
  pageId: null | string | number;
397
397
  };
398
398
  public resInfo: ServiceInterFace.HttpRequestInfo;
399
399
  public api: ServiceInterFace.HttpApi;
400
400
  public verifyColorList: string[];
401
401
  constructor(opt) {
402
402
  this._init();
403
403
  this.addressFetchInfo = {
404
404
  reqState: false,
405
405
  promiseInstance: null,
406
406
  };
407
407
  this.getPromotionConfig = {
408
408
  projectId: null,
409
409
  pageId: null,
410
410
  };
411
411
  this._userAreaUpdateListen();
412
412
  this.resInfo = this._getResConfig(opt);
413
413
  this.api = api;
414
414
  this.verifyColorList = [
415
415
  ...WxappVerifyColorList,
416
416
  ];
417
417
  }
418
418
  _init(): void {
419
419
  httpInterceptors.forEach((item) => {
420
420
  Taro.addInterceptor((chain) => item(chain));
421
421
  });
422
422
  }
423
423
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
424
424
  return Object.assign({}, DefaultConfig, opt);
425
425
  }
426
426
 
427
427
  _userAreaUpdateListen() {
428
428
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
429
429
  this.updateApiClientParamsResInfo(areaInfo);
430
430
  });
431
431
  }
432
432
  updateApiClientParamsResInfo(opt = {}) {
433
433
  const { area, realTimeArea, ...others } = opt;
434
434
  this.resInfo.apiClientParams = {
435
435
  ...this.resInfo.apiClientParams,
436
436
  ...others,
437
437
  };
438
438
  area && area !== '' && (this.resInfo.apiClientParams.area = area);
439
439
  realTimeArea &&
440
440
  realTimeArea !== '' &&
441
441
  (this.resInfo.apiClientParams.realTimeArea = realTimeArea);
442
442
  }
443
443
 
444
444
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
445
445
  if (functionId === 'receiveShopCoupon') {
446
446
  clientParams = Object.assign(
447
447
  {},
448
448
  {
449
449
  loginType: '1',
450
450
  loginWQBiz: WXAPP_BIZ_KEY,
451
451
  },
452
452
  clientParams,
453
453
  );
454
454
  }
455
455
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
456
456
  const isColorVerify = this.verifyColorList.includes(functionId);
457
457
  const getReqData = {
458
458
  functionId: functionId,
459
459
  body: JSON.stringify(bodyParams),
460
460
  t: Date.now(),
461
461
  ...apiClientParams,
462
462
  };
463
463
  return http
464
464
  .request({
465
465
  url: this.api.apiFunc,
466
466
  data: getReqData,
467
467
  isColorVerify,
468
468
  })
469
469
  .then((res: ServiceInterFace.RequestPromiseRes) => {
470
470
  const { statusCode, data } = res;
471
471
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
472
472
  ok: true,
473
473
  };
474
474
  if (statusCode === 200 && data) {
475
475
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
476
476
  ? Number(res.data.code)
477
477
  : -1;
478
478
  const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
479
479
  ? Number(res.data.subCode)
480
480
  : -1;
481
481
  if (
482
482
  data.success === true ||
483
483
  data.isSuccess ||
484
484
  resCode === 0 ||
485
485
  resCode === 200 ||
486
486
  subCode === 0
487
487
  ) {
488
488
  changeRes = {
489
489
  result: Object.prototype.hasOwnProperty.call(data, 'result')
490
490
  ? data.result
491
491
  : Object.prototype.hasOwnProperty.call(data, 'data')
492
492
  ? data.data
493
493
  : data,
494
494
  code: data.code || 200,
495
495
  ok: true,
496
496
  source: data,
497
497
  };
498
498
  return changeRes;
499
499
  } else {
500
500
  changeRes = {
501
501
  ...data,
502
502
  ok: false,
503
503
  statusCode: res.statusCode,
504
504
  };
505
505
  return changeRes;
506
506
  }
507
507
  } else {
508
508
  changeRes = {
509
509
  ...data,
510
510
  ok: false,
511
511
  statusCode: res.statusCode,
512
512
  };
513
513
  return changeRes;
514
514
  }
515
515
  })
516
516
  .catch((res) => {
517
517
  return {
518
518
  ...res,
519
519
  ok: false,
520
520
  } as ServiceInterFace.RequestResponseFormatRes;
521
521
  });
522
522
  }
523
523
 
524
524
  async receiveCoupon(param = {}, clientParams) {
525
525
  console.warn('receiveCoupon 方法在微信京购小程序环境未经验证,请不要使用!');
526
526
  return await this.gatewayReq(
527
527
  'receiveShopCoupon',
528
528
  {
529
529
  operation: '3',
530
530
  ...param,
531
531
  },
532
532
  { ...clientParams },
533
533
  );
534
534
  }
535
535
 
536
536
  getCustomerCenterDispatch(params = {}) {
537
537
  return this.gatewayReq('customerCenterDispatch', params, {
538
538
  clientVersion: '9.2.0',
539
539
  client: 'H5',
540
540
  uuid: 88888,
541
541
  appid: 'shopmember_m_jd_com',
542
542
  });
543
543
  }
544
544
 
545
545
  batchAddCart(...args) {
546
546
  let skuIds, num, showToast, giftCard;
547
547
  if (['number', 'string'].includes(typeof args[0])) {
548
548
  [skuIds, num = 1, showToast = true, giftCard = false] = args;
549
549
  } else if (typeof args[0] === 'object' && args[0] !== null) {
550
550
  const params = args[0];
551
551
  skuIds = params.skuIds;
552
552
  num = params.num || 1;
553
553
  showToast = params.showToast !== undefined ? params.showToast : true;
554
554
  giftCard = params.giftCard !== undefined ? params.giftCard : false;
555
555
  } else {
556
556
  console.error('batchAddCart() Invalid arguments!', args);
557
557
  const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
558
558
  showFailToast({
559
559
  title: msg,
560
560
  });
561
561
  return Promise.resolve({
562
562
  ok: false,
563
563
  msg,
564
564
  });
565
565
  }
566
566
  const addToWhereText = giftCard ? '购物清单' : '购物车';
567
567
  const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
568
568
  const failMsg = isLanguageForEn
569
569
  ? 'Please retry later'
570
570
  : `加入${addToWhereText}失败,请稍后重试!`;
571
571
  if (skuIds) {
572
572
  return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
573
573
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
574
574
  if (res?.ok) {
575
575
  if (showToast && !res?.isOpenApp)
576
576
  showSuccessToast({
577
577
  title: successMsg,
578
578
  });
579
579
  } else {
580
580
  showToast &&
581
581
  showFailToast({
582
582
  title: res?.errMsg || failMsg,
583
583
  });
584
584
  }
585
585
  return Promise.resolve(res);
586
586
  })
587
587
  .catch((e) => {
588
588
  console.log('调用加购方法异常=======>', e);
589
589
  return Promise.resolve({
590
590
  ok: false,
591
591
  msg: failMsg,
592
592
  });
593
593
  });
594
594
  } else {
595
595
  return Promise.resolve({
596
596
  ok: false,
597
597
  msg: failMsg,
598
598
  });
599
599
  }
600
600
  }
601
601
 
602
602
  async giftCardAddCart(skuList, num) {
603
603
  return this.gatewayReq('giftCardAddCart', {
604
604
  skuList,
605
605
  num: Number(num),
606
606
  });
607
607
  }
608
608
 
609
609
  _addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
610
610
  return new Promise((resolve) => {
611
611
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
612
612
  if (productIdsArr.length > 0) {
613
613
  if (giftCard) {
614
614
  this.giftCardAddCart(productIdsArr, addCardNum)
615
615
  .then((res) => {
616
616
  if (res?.code === '0' && res?.result?.value) {
617
617
  resolve({
618
618
  ok: true,
619
619
  });
620
620
  } else {
621
621
  resolve({
622
622
  ok: false,
623
623
  msg: '加购失败,请稍后重试',
624
624
  });
625
625
  }
626
626
  })
627
627
  .catch((e) => {
628
628
  console.error('礼品卡加车失败: ', e);
629
629
  resolve({
630
630
  ok: false,
631
631
  msg: '加购失败,请稍后重试',
632
632
  });
633
633
  });
634
634
  } else if (isJdApp) {
635
635
  console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
636
636
  } else if (isMin) {
637
637
  console.log('==========>', '京购批量加车!');
638
638
  const productsAddCartList = productIdsArr.map((skuItem) => {
639
639
  return {
640
640
  skuId: skuItem,
641
641
  buyNum: addCardNum,
642
642
  };
643
643
  });
644
644
  global.wxAppBizInstance
645
645
  .addCart({ commArr: productsAddCartList })
646
646
  .then((res) => {
647
647
  console.log('dealCartSuccess: ', res);
648
648
  resolve({
649
649
  ok: true,
650
650
  msg: '已加入购物车!',
651
651
  data: res,
652
652
  });
653
653
  })
654
654
  .catch((e) => {
655
655
  console.log('京购小程序批量加车失败dealCartFail: ', e);
656
656
  resolve({
657
657
  ok: false,
658
658
  msg: '加购失败,请稍后重试',
659
659
  });
660
660
  });
661
661
  } else {
662
662
  console.log('==========>', 'M站批量加车!');
663
663
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
664
664
  }
665
665
  } else {
666
666
  resolve({
667
667
  ok: false,
668
668
  msg: '加购sku不能为空',
669
669
  });
670
670
  }
671
671
  });
672
672
  }
673
673
 
674
674
  productAddToCart() {
675
675
  return Promise.resolve({
676
676
  ok: false,
677
677
  msg: 'productAddToCart暂不支持小程序',
678
678
  });
679
679
  }
680
680
  bMallGetUserInfo(){
681
681
  return Promise.resolve({
682
682
  ok: false,
683
683
  msg: 'productAddToCart暂不支持小程序',
684
684
  });
685
685
  }
686
686
  bMallGetSkuNumApi(){
687
687
  return Promise.resolve({
688
688
  ok: false,
689
689
  msg: 'productAddToCart暂不支持小程序',
690
690
  });
691
691
  }
692
692
  bMallCartHandle(){
693
693
  return Promise.resolve({
694
694
  ok: false,
695
695
  msg: 'productAddToCart暂不支持小程序',
696
696
  });
697
697
  }