@conecli/cone-render 0.10.1-shop-beta.4 → 0.10.1-shop-beta.6

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 (102) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/environmentType.ts +1 -1
  4. package/dist/common/index.h5.ts +1 -1
  5. package/dist/common/index.jd.ts +1 -1
  6. package/dist/common/index.ts +1 -1
  7. package/dist/common/index.weapp.ts +1 -1
  8. package/dist/common/pageType.ts +1 -1
  9. package/dist/common/sgmCustomCode.ts +1 -1
  10. package/dist/common/token/token.jd.ts +1 -1
  11. package/dist/components/ErrorBoundary.tsx +1 -1
  12. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  13. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  14. package/dist/components/base/CountDown/index.module.scss +49 -44
  15. package/dist/components/base/CountDown/index.tsx +1 -1
  16. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  17. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  18. package/dist/components/base/CustomVideo/common.ts +1 -0
  19. package/dist/components/base/CustomVideo/index.tsx +1 -1
  20. package/dist/components/base/Dialog/index.module.scss +11 -0
  21. package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
  22. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  23. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  24. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  25. package/dist/components/base/InViewRender/index.tsx +1 -1
  26. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  27. package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
  28. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  29. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  30. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  31. package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -3
  32. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  33. package/dist/components/base/LazyLoadImage/index.tsx +1 -1
  34. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  35. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  36. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  37. package/dist/components/base/Price/Base/index.tsx +1 -1
  38. package/dist/components/base/Price/Double/index.module.scss +8 -0
  39. package/dist/components/base/Price/Double/index.tsx +1 -1
  40. package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
  41. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  42. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  43. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  44. package/dist/components/floorItem.jd.tsx +1 -1
  45. package/dist/components/floorItem.tsx +1 -1
  46. package/dist/components/floorItem.weapp.tsx +1 -1
  47. package/dist/components/isv/Floor/index.tsx +1 -1
  48. package/dist/components/remoteFloorItem.tsx +1 -1
  49. package/dist/interface/common.ts +1 -1
  50. package/dist/interface/component.ts +1 -1
  51. package/dist/interface/jumpEventReport.ts +1 -1
  52. package/dist/interface/service.ts +1 -1
  53. package/dist/jumpEventReport/base.ts +1 -1
  54. package/dist/jumpEventReport/const.ts +1 -1
  55. package/dist/jumpEventReport/index.jd.ts +1 -1
  56. package/dist/jumpEventReport/index.weapp.ts +1 -1
  57. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  58. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  59. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  60. package/dist/jumpEventReport/web/report.ts +1 -1
  61. package/dist/jumpEventReport/web.base.ts +1 -1
  62. package/dist/jumpEventReport/web.jd.ts +1 -1
  63. package/dist/jumpEventReport/web.jdb.ts +1 -1
  64. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  65. package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
  66. package/dist/jumpEventReport/web.pc.ts +1 -1
  67. package/dist/jumpEventReport/web.tjapp.ts +1 -1
  68. package/dist/jumpEventReport/web.tjm.ts +1 -1
  69. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  70. package/dist/libs/taroAppReport.js +2 -2
  71. package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -52
  72. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  73. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  74. package/dist/open/api/device.ts +1 -1
  75. package/dist/open/api/request.ts +1 -1
  76. package/dist/open/api/shopMember.ts +1 -1
  77. package/dist/open/api/util.ts +1 -1
  78. package/dist/open/components/index.ts +1 -1
  79. package/dist/sass/app.h5.scss +275 -221
  80. package/dist/sass/base.scss +183 -137
  81. package/dist/service/fetchGateway.ts +1 -1
  82. package/dist/service/fetchGateway.weapp.ts +1 -0
  83. package/dist/service/http/colorSign.ts +1 -1
  84. package/dist/service/http/const.ts +1 -1
  85. package/dist/service/http/h5Http.ts +1 -0
  86. package/dist/service/http/index.h5.ts +1 -0
  87. package/dist/service/requestServer.h5.ts +1 -0
  88. package/dist/service/requestServer.ts +1 -1
  89. package/dist/service/requestServer.weapp.ts +1 -0
  90. package/dist/utils/connectNativeJsBridge.ts +1 -1
  91. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  92. package/dist/utils/h5Utils.ts +1 -1
  93. package/dist/utils/index.h5.ts +1 -1
  94. package/dist/utils/index.ts +1 -1
  95. package/dist/utils/index.weapp.ts +1 -1
  96. package/dist/utils/jumpExtMapUtil.js +1 -0
  97. package/dist/utils/sColor.js +1 -0
  98. package/dist/utils/sgmCodeUtils.ts +1 -1
  99. package/dist/utils/taroRenderUtil.ts +1 -1
  100. package/dist/utils/utils.ts +1 -1
  101. package/package.json +53 -28
  102. package/dist/utils/memberFormatUtils.js +0 -1
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro';
2
  APPID,
1
3
  JshopxColorFunctionIdList,
2
4
  PagesColorFunctionIdList,
3
5
  PAGES_DOMAIN,
4
6
  B2BColorFunctionIdList,
5
7
  MobileVerifyColorList,
6
8
  AppVerifyColorList,
7
9
  JshopxVerifyColorList,
8
10
  BMallVerifyColorList,
9
11
  shopMemberColorFunctionIdList,
10
12
  draBusinessCustomReport,
11
13
  isLanguageForEn,
12
14
  isJdApp,
13
15
  isIosDevice,
14
16
  isAndroidDevice,
15
17
  isJdAndHarmonyDevice,
16
18
  showSuccessToast,
17
19
  showFailToast,
18
20
  isH5,
19
21
  isWxMinAndWxapp,
20
22
  isMin,
21
23
  isPc,
22
24
  draInterfaceCustomReport,
23
25
  callRouterIOS,
24
26
  callRouterAndroid,
25
27
  sendNativePageToShowCartFloatBtn,
26
28
  cookiesStr: '',
27
29
  requestHeaderContentType: {
28
30
  jsonHeader: {
29
31
  'content-type': 'application/json;charset=utf-8',
30
32
  },
31
33
  formDataHeader: {
32
34
  'content-type': 'application/x-www-form-urlencoded',
33
35
  },
34
36
  },
35
37
  requestBaseParam: {
36
38
  data: null,
37
39
  header: {
38
40
  'content-type': 'application/json;charset=utf-8',
39
41
  },
40
42
  },
41
43
  timeOut: 7000,
42
44
  apiClientParams: {
43
45
  clientVersion: isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
44
46
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
45
47
  area: '1_72_2799_0',
46
48
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
47
49
  window.screen?.height * devicePixelRatio,
48
50
  )}`,
49
51
  uuid: UUID,
50
52
  },
51
53
  public addressFetchInfo: {
52
54
  reqState: boolean;
53
55
  promiseInstance: null | Promise<any>;
54
56
  };
55
57
  public getPromotionConfig: {
56
58
  projectId: null | string | number;
57
59
  pageId: null | string | number;
58
60
  };
59
61
  public resInfo: ServiceInterFace.HttpRequestInfo;
60
62
  public api: ServiceInterFace.HttpApi;
61
63
  public isPageDomain: boolean;
62
64
  public verifyColorList: string[];
63
65
  private isShowJdShopCartFloatBtn: boolean;
64
66
  constructor(opt) {
65
67
  this._init();
66
68
  this.addressFetchInfo = {
67
69
  reqState: false,
68
70
  promiseInstance: null,
69
71
  };
70
72
  this.getPromotionConfig = {
71
73
  projectId: null,
72
74
  pageId: null,
73
75
  };
74
76
  this._userAreaUpdateListen();
75
77
  this.resInfo = this._getResConfig(opt);
76
78
  this.api = api;
77
79
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
78
80
  this.verifyColorList = [
79
81
  ...MobileVerifyColorList,
80
82
  ...AppVerifyColorList,
81
83
  ...JshopxVerifyColorList,
82
84
  ...BMallVerifyColorList,
83
85
  ];
84
86
  this.isShowJdShopCartFloatBtn =
85
87
  jdAppVersionCompare(isJdAndIosDevice ? '13.8.6' : '13.6.2') >= 0;
86
88
  }
87
89
  _init(): void {
88
90
  httpInterceptors.forEach((item) => {
89
91
  Taro.addInterceptor((chain) => item(chain));
90
92
  });
91
93
  }
92
94
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
93
95
  return Object.assign({}, DefaultConfig, opt);
94
96
  }
95
97
 
96
98
  _userAreaUpdateListen() {
97
99
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
98
100
  area &&
99
101
  area !== '' &&
100
102
  this.updateApiClientParamsResInfo({
101
103
  area,
102
104
  });
103
105
  console.log(
104
106
  'cone-render收到原生端获取传来的四级地址信息',
105
107
  area,
106
108
  '更新后的接口底层信息',
107
109
  this.resInfo.apiClientParams,
108
110
  );
109
111
  });
110
112
  }
111
113
  updateApiClientParamsResInfo(opt = {}) {
112
114
  const { area, ...others } = opt;
113
115
  this.resInfo.apiClientParams = {
114
116
  ...this.resInfo.apiClientParams,
115
117
  ...others,
116
118
  };
117
119
  if (area) {
118
120
  this.resInfo.apiClientParams.area = area;
119
121
  }
120
122
  }
121
123
 
122
124
  checkFunctionIdToReturnAppId(functionId) {
123
125
  if (JshopxColorFunctionIdList.includes(functionId)) {
124
126
  return APPID.JSHOPX_COLOR_APPID;
125
127
  } else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
126
128
  return APPID.PAGES_COLOR_APPID;
127
129
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
128
130
  return APPID.SHOP_MEMBER_COLOR_APPID;
129
131
  } else if (B2BColorFunctionIdList.includes(functionId)) {
130
132
  return APPID.B2B_COLOR_APPID;
131
133
  } else if (isPc) {
132
134
  return APPID.MALL_COLOR_APPID;
133
135
  } else {
134
136
  return APPID.SHOP_COLOR_APPID;
135
137
  }
136
138
  }
137
139
 
138
140
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
139
141
  if (
140
142
  functionId === 'receiveShopCoupon' &&
141
143
  ((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
142
144
  isWxMinAndWxapp)
143
145
  ) {
144
146
  clientParams = Object.assign(
145
147
  {},
146
148
  {
147
149
  loginType: '1',
148
150
  loginWQBiz: WXAPP_BIZ_KEY,
149
151
  },
150
152
  clientParams,
151
153
  );
152
154
  }
153
155
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
154
156
  typeof apiClientParams.appid === 'undefined' &&
155
157
  (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
156
158
  const isColorVerify = this.verifyColorList.includes(functionId);
157
159
  const getReqData = {
158
160
  functionId: functionId,
159
161
  body: JSON.stringify(bodyParams),
160
162
  t: Date.now(),
161
163
  ...apiClientParams,
162
164
  };
163
165
  return http
164
166
  .request({
165
167
  url: this.api.apiFunc,
166
168
  data: getReqData,
167
169
  isColorVerify,
168
170
  })
169
171
  .then((res: ServiceInterFace.RequestPromiseRes) => {
170
172
  const { statusCode, data, status, msg } = res;
171
173
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
172
174
  ok: true,
173
175
  };
174
176
  if ((statusCode === 200 || status === '0') && data) {
175
177
  changeRes = this.dealResponseFormatRes(data);
176
178
  return changeRes;
177
179
  } else {
178
180
  changeRes = {
179
181
  ...data,
180
182
  statusCode,
181
183
  status,
182
184
  msg,
183
185
  ok: false,
184
186
  };
185
187
  return changeRes;
186
188
  }
187
189
  })
188
190
  .catch((res) => {
189
191
  const propertyNames = Object.getOwnPropertyNames(res);
190
192
  const resObject = {};
191
193
  propertyNames.forEach((propertyName) => {
192
194
  resObject[propertyName] = res[propertyName];
193
195
  });
194
196
  draInterfaceCustomReport({
195
197
  subMsg:
196
198
  '接口请求异常,进入catch逻辑,例如h5请求神盾(反爬、小号、风控)或加固拦截返回status为403等',
197
199
  url: this.api.apiFunc,
198
200
  source: 'remote',
199
201
  requestType: res?.requestType,
200
202
  errorType: 'catchError',
201
203
  functionId: getReqData?.functionId,
202
204
  appid: getReqData?.appid,
203
205
  client: getReqData?.client,
204
206
  clientVersion: getReqData?.clientVersion,
205
207
  statusCode: res?.statusCode,
206
208
  status: res?.status,
207
209
  statusText: res?.statusText,
208
210
  code: res?.data?.code || res?.data?.subCode,
209
211
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
210
212
  originReqDataStr: JSON.stringify(getReqData),
211
213
  originResDataStr: JSON.stringify(res, propertyNames),
212
214
  });
213
215
  return {
214
216
  ...resObject,
215
217
  ok: false,
216
218
  } as ServiceInterFace.RequestResponseFormatRes;
217
219
  });
218
220
  }
219
221
 
220
222
  dealResponseFormatRes(data) {
221
223
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
222
224
  ok: true,
223
225
  };
224
226
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
225
227
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
226
228
  ? Number(data.subCode)
227
229
  : -1;
228
230
  if (
229
231
  data.success === true ||
230
232
  data.isSuccess ||
231
233
  resCode === 0 ||
232
234
  resCode === 200 ||
233
235
  subCode === 0
234
236
  ) {
235
237
  changeRes = {
236
238
  result: Object.prototype.hasOwnProperty.call(data, 'result')
237
239
  ? data.result
238
240
  : Object.prototype.hasOwnProperty.call(data, 'data')
239
241
  ? data.data
240
242
  : data,
241
243
  code: data.code ?? 200,
242
244
  ok: true,
243
245
  source: data,
244
246
  };
245
247
  return changeRes;
246
248
  } else {
247
249
  changeRes = {
248
250
  ...data,
249
251
  ok: false,
250
252
  };
251
253
  return changeRes;
252
254
  }
253
255
  }
254
256
 
255
257
  async receiveCoupon(param = {}, clientParams) {
256
258
  const loginType = isPc ? { loginType: 3 } : {};
257
259
  return await this.gatewayReq(
258
260
  'receiveShopCoupon',
259
261
  {
260
262
  operation: '3',
261
263
  ...param,
262
264
  },
263
265
  { ...loginType, ...clientParams },
264
266
  );
265
267
  }
266
268
 
267
269
  getCustomerCenterDispatch(params = {}) {
268
270
  return this.gatewayReq('customerCenterDispatch', params, {
269
271
  clientVersion: '9.2.0',
270
272
  client: 'H5',
271
273
  uuid: 88888,
272
274
  appid: 'shopmember_m_jd_com',
273
275
  });
274
276
  }
275
277
 
276
278
  batchAddCart(...args) {
277
279
  let skuIds, num, showToast, giftCard;
278
280
  if (['number', 'string'].includes(typeof args[0])) {
279
281
  [skuIds, num = 1, showToast = true, giftCard = false] = args;
280
282
  } else if (typeof args[0] === 'object' && args[0] !== null) {
281
283
  const params = args[0];
282
284
  skuIds = params.skuIds;
283
285
  num = params.num || 1;
284
286
  showToast = params.showToast !== undefined ? params.showToast : true;
285
287
  giftCard = params.giftCard !== undefined ? params.giftCard : false;
286
288
  } else {
287
289
  console.error('batchAddCart() Invalid arguments!', args)
288
290
  try{
289
291
  const data = {
290
292
  type: 'batchAddCart',
291
293
  subType: 'invalidInputParameter',
292
294
  errMsg: '入参不合法',
293
295
  originData: args
294
296
  }
295
297
  draBusinessCustomReport(data)
296
298
  }catch(e){
297
299
  console.error('draBusinessCustomReport error:', e)
298
300
  }
299
301
  const msg = isLanguageForEn? 'Please retry later': '加入购物车失败,请稍后重试!'
300
302
  showFailToast({
301
303
  title: msg,
302
304
  });
303
305
  return Promise.resolve({
304
306
  ok: false,
305
307
  msg,
306
308
  });
307
309
  }
308
310
  const addToWhereText = giftCard? '购物清单': '购物车'
309
311
  const successMsg = isLanguageForEn? 'Success': `加入${addToWhereText}成功`
310
312
  const failMsg = isLanguageForEn? 'Please retry later': `加入${addToWhereText}失败,请稍后重试!`
311
313
  if (skuIds) {
312
314
  return this._addShopGoodCart(`${skuIds}`, `${num}`, {giftCard})
313
315
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
314
316
  if (res?.ok) {
315
317
  showToast &&
316
318
  !res?.isOpenApp &&
317
319
  showSuccessToast({
318
320
  title: successMsg,
319
321
  });
320
322
  this.isShowJdShopCartFloatBtn &&
321
323
  sendNativePageToShowCartFloatBtn({
322
324
  isShow: true,
323
325
  });
324
326
  } else {
325
327
  showToast &&
326
328
  showFailToast({
327
329
  title: res?.errMsg || failMsg,
328
330
  });
329
331
  }
330
332
  return Promise.resolve(res);
331
333
  })
332
334
  .catch((e) => {
333
335
  console.log('调用加购方法异常=======>', e);
334
336
  return Promise.resolve({
335
337
  ok: false,
336
338
  msg: failMsg,
337
339
  });
338
340
  });
339
341
  } else {
340
342
  try{
341
343
  const data = {
342
344
  type: 'batchAddCart',
343
345
  subType: 'invalidInputParameter',
344
346
  errMsg: '没有传入合法的skuIds',
345
347
  originData: skuIds
346
348
  }
347
349
  draBusinessCustomReport(data)
348
350
  }catch(e){
349
351
  console.error('draBusinessCustomReport error:', e)
350
352
  }
351
353
  return Promise.resolve({
352
354
  ok: false,
353
355
  msg: failMsg,
354
356
  });
355
357
  }
356
358
  }
357
359
  const loginType = isPc ? { loginType: 3 } : {};
358
360
  return this.gatewayReq(
359
361
  'giftCardAddCart',
360
362
  {
361
363
  skuList,
362
364
  num: Number(num)
363
365
  },
364
366
  { ...loginType},
365
367
  );
366
368
  }
367
369
 
368
370
  _addShopGoodCart(skuIdsStr, addCardNum = '1', {giftCard}) {
369
371
  return new Promise((resolve) => {
370
372
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
371
373
  if (productIdsArr.length > 0) {
372
374
  if(giftCard){
373
375
  this.giftCardAddCart(productIdsArr, addCardNum).then((res) => {
374
376
  if(res?.code === '0' && res?.result?.value){
375
377
  resolve({
376
378
  ok: true,
377
379
  })
378
380
  }else{
379
381
  try{
380
382
  const data = {
381
383
  type: 'batchAddCart',
382
384
  subType: 'addCartFailByGiftCard',
383
385
  errMsg: '礼品卡加车接口返回加车失败标识',
384
386
  originData: res
385
387
  }
386
388
  draBusinessCustomReport(data)
387
389
  }catch(e){
388
390
  console.error('draBusinessCustomReport error:', e)
389
391
  }
390
392
  resolve({
391
393
  ok: false,
392
394
  msg: '加购失败,请稍后重试',
393
395
  });
394
396
  }
395
397
  }).catch((e) => {
396
398
  console.error('礼品卡加车失败: ', e);
397
399
  resolve({
398
400
  ok: false,
399
401
  msg: '加购失败,请稍后重试',
400
402
  });
401
403
  });
402
404
  }
403
405
  else
404
406
  if (isJdApp && !isJdAndHarmonyDevice) {
405
407
  const nativeAddCartCallBack = `nativeBatchAddCart${Date.now() + Number(productIdsArr[0]) + Number(addCardNum)}`;
406
408
  console.log(
407
409
  '==========>',
408
410
  '原生批量加车, 回调方法保证唯一添加skuid和数量,nativeAddCartCallBack',
409
411
  nativeAddCartCallBack,
410
412
  );
411
413
  if (!window[nativeAddCartCallBack]) {
412
414
  window[nativeAddCartCallBack] = (res) => {
413
415
  const getMessageJsonData = typeof res === 'string' ? JSON.parse(res) : res;
414
416
  console.info(
415
417
  '获取批量加车原始数据',
416
418
  res,
417
419
  '====转换后的json数据为===',
418
420
  getMessageJsonData,
419
421
  );
420
422
  try {
421
423
  if (isAndroidDevice) {
422
424
  const isOk = getMessageJsonData?.status === '0';
423
425
  isOk? resolve({
424
426
  ok: true,
425
427
  msg: '已加入购物车!',
426
428
  })
427
429
  : resolve({
428
430
  ok: false,
429
431
  msg: '加购失败,请稍后重试',
430
432
  errMsg: getMessageJsonData?.data?.message ?? '',
431
433
  });
432
434
  if(!isOk){
433
435
  const data = {
434
436
  type: 'batchAddCart',
435
437
  subType: 'addCartFailByH5CallAndroidNative',
436
438
  errMsg: 'H5调用安卓原生加车失败',
437
439
  originData: getMessageJsonData
438
440
  }
439
441
  draBusinessCustomReport(data)
440
442
  }
441
443
  } else if (isIosDevice) {
442
444
  const isOk = getMessageJsonData?.status === '0' && getMessageJsonData?.data?.code === 0;
443
445
  isOk? resolve({
444
446
  ok: true,
445
447
  msg: '已加入购物车!',
446
448
  })
447
449
  : resolve({
448
450
  ok: false,
449
451
  msg: '批量加车失败,请稍后重试',
450
452
  errMsg: getMessageJsonData?.data?.message ?? '',
451
453
  });
452
454
  if(!isOk){
453
455
  const data = {
454
456
  type: 'batchAddCart',
455
457
  subType: 'addCartFailByH5CallIosNative',
456
458
  errMsg: 'H5调用IOS原生加车失败',
457
459
  originData: getMessageJsonData
458
460
  }
459
461
  draBusinessCustomReport(data)
460
462
  }
461
463
  } else {
462
464
  resolve({
463
465
  ok: false,
464
466
  msg: '加购失败,请稍后重试',
465
467
  });
466
468
  const data = {
467
469
  type: 'batchAddCart',
468
470
  subType: 'addCartFailByH5CallUnknownNative',
469
471
  errMsg: 'H5调用未知原生加车失败',
470
472
  }
471
473
  draBusinessCustomReport(data)
472
474
  }
473
475
  } catch (e) {
474
476
  resolve({
475
477
  ok: false,
476
478
  msg: '加购失败,请稍后重试',
477
479
  });
478
480
  console.warn('批量加车转换数据异常', e);
479
481
  const data = {
480
482
  type: 'batchAddCart',
481
483
  subType: 'addCartFailByTransformData',
482
484
  errMsg: '批量加车转换数据异常',
483
485
  originData: e
484
486
  }
485
487
  draBusinessCustomReport(data)
486
488
  }
487
489
  window[nativeAddCartCallBack] = null;
488
490
  };
489
491
  }
490
492
  const productsAddCartList = productIdsArr.map((skuItem) => {
491
493
  const adInfos = getAdInfoBySkuId(skuItem)
492
494
  const extFlag = adInfos? {adInfos}: {}
493
495
  return isAndroidDevice
494
496
  ? {
495
497
  sku: skuItem,
496
498
  num: addCardNum,
497
499
  extFlag
498
500
  }
499
501
  : {
500
502
  productCode: skuItem,
501
503
  buyCount: addCardNum,
502
504
  extFlag
503
505
  };
504
506
  });
505
507
  if (isAndroidDevice) {
506
508
  const androidProductsStr = JSON.stringify(productsAddCartList);
507
509
  callRouterAndroid({
508
510
  routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
509
511
  routerParam: {
510
512
  wareList: productsAddCartList,
511
513
  },
512
514
  callBackName: nativeAddCartCallBack,
513
515
  });
514
516
  } else if (isIosDevice) {
515
517
  if (isLowAppVer) {
516
518
  const lowVersionAppList = productIdsArr.map((skuItem) => {
517
519
  return {
518
520
  sku: skuItem,
519
521
  num: addCardNum,
520
522
  };
521
523
  });
522
524
  const lowVersionAppListStr = JSON.stringify(lowVersionAppList);
523
525
  const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`;
524
526
  jump.side.jdJumpToWeb(url, {});
525
527
  resolve({
526
528
  ok: true,
527
529
  isOpenApp: true,
528
530
  msg: '加购完成, 加购结果请点击购物车确认',
529
531
  });
530
532
  } else {
531
533
  callRouterIOS({
532
534
  routerURL: 'router://JDCartModule/batchAddService',
533
535
  routerParam: {
534
536
  sourceType: 'h5',
535
537
  sourceValue: '店铺批量加购',
536
538
  businessName: 'storeModel',
537
539
  isNewMode: '1',
538
540
  NotPassWebview: '1',
539
541
  products: productsAddCartList,
540
542
  },
541
543
  callBackName: nativeAddCartCallBack,
542
544
  });
543
545
  }
544
546
  }
545
547
  } else if (isMin) {
546
548
  console.log('==========>', '京购批量加车!');
547
549
  const productsAddCartList = productIdsArr.map((skuItem) => {
548
550
  return {
549
551
  skuId: skuItem,
550
552
  buyNum: addCardNum,
551
553
  };
552
554
  });
553
555
  global.wxAppBizInstance
554
556
  .addCart({ commArr: productsAddCartList })
555
557
  .then((res) => {
556
558
  console.log('dealCartSuccess: ', res);
557
559
  resolve({
558
560
  ok: true,
559
561
  msg: '已加入购物车!',
560
562
  data: res,
561
563
  });
562
564
  })
563
565
  .catch((e) => {
564
566
  console.log('京购小程序批量加车失败dealCartFail: ', e);
565
567
  resolve({
566
568
  ok: false,
567
569
  msg: '加购失败,请稍后重试',
568
570
  });
569
571
  const data = {
570
572
  type: 'batchAddCart',
571
573
  subType: 'addCartFailByH5CallMini',
572
574
  errMsg: 'H5调用小程序加车失败',
573
575
  originData: e
574
576
  }
575
577
  draBusinessCustomReport(data)
576
578
  });
577
579
  } else {
578
580
  console.log('==========>', 'M站批量加车!');
579
581
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
580
582
  }
581
583
  } else {
582
584
  resolve({
583
585
  ok: false,
584
586
  msg: '加购sku不能为空',
585
587
  });
586
588
  const data = {
587
589
  type: 'batchAddCart',
588
590
  subType: 'addCartFailNoSku',
589
591
  errMsg: '加购sku不能为空',
590
592
  originData: skuIdsStr
591
593
  }
592
594
  draBusinessCustomReport(data)
593
595
  }
594
596
  });
595
597
  }
596
598
 
597
599
  productAddToCart(skuIdsStr, num) {
598
600
  return new Promise((resolve) => {
599
601
  if (window.AddcartToolObj) {
600
602
  window.AddcartToolObj.addCart({
601
603
  skuId: skuIdsStr,
602
604
  num,
603
605
  source: 'sjdpyw',
604
606
  actId: '1',
605
607
  loginType: window?.isJingGouMiniViewState ? '11' : '2',
606
608
  sucFun(res) {
607
609
  console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
608
610
  if (res.errId === '0' && res.cartJson) {
609
611
  resolve({
610
612
  ok: true,
611
613
  msg: '已加入购物车!',
612
614
  ...res,
613
615
  });
614
616
  } else {
615
617
  if (res.errId === '13') {
616
618
  global.doLogin();
617
619
  } else {
618
620
  resolve({
619
621
  ok: false,
620
622
  msg: '加购失败,请稍后重试',
621
623
  ...res,
622
624
  });
623
625
  const data = {
624
626
  type: 'batchAddCart',
625
627
  subType: 'addCartFailByH5CallM',
626
628
  errMsg: 'H5调用M站加车失败',
627
629
  originData: res
628
630
  }
629
631
  draBusinessCustomReport(data)
630
632
  }
631
633
  }
632
634
  },
633
635
  failFun(err) {
634
636
  console.log('fail', err);
635
637
  resolve({
636
638
  ok: false,
637
639
  msg: '加购失败,请稍后重试',
638
640
  ...err,
639
641
  });
640
642
  const data = {
641
643
  type: 'batchAddCart',
642
644
  subType: 'addCartFailByH5CallM',
643
645
  errMsg: 'H5调用M站加车失败',
644
646
  originData: err
645
647
  }
646
648
  draBusinessCustomReport(data)
647
649
  },
648
650
  });
649
651
  } else {
650
652
  resolve({
651
653
  ok: false,
652
654
  msg: '购物车方法检查异常',
653
655
  });
654
656
  const data = {
655
657
  type: 'batchAddCart',
656
658
  subType: 'addCartFailByH5CallM',
657
659
  errMsg: 'H5调用M站加车检查依赖方法异常',
658
660
  }
659
661
  draBusinessCustomReport(data)
660
662
  }
661
663
  });
662
664
  }
663
665
  bMallGetUserInfo = () => {
664
666
  return getBMallUserInfo();
665
667
  };
666
668
  async bMallAddCart(params = {}) {
667
669
  return await this.gatewayReq('bmall_cartAdd', params, {
668
670
  client: 'H5',
669
671
  clientVersion: '5.5.0',
670
672
  });
671
673
  }
672
674
  async bMallChangeCart(params = {}) {
673
675
  return await this.gatewayReq('bmall_cartChange', params, {
674
676
  client: 'H5',
675
677
  clientVersion: '5.5.0',
676
678
  });
677
679
  }
678
680
  async bMallRemoveCart(params = {}) {
679
681
  return await this.gatewayReq(
680
682
  'bmall_cartRemove',
681
683
  params,
682
684
  {
683
685
  client: 'H5',
684
686
  clientVersion: '5.5.0',
685
687
  },
686
688
  );
687
689
  }
688
690
  async bMallGetOmittedProduct(params = {}) {
689
691
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
690
692
  client: 'H5',
691
693
  clientVersion: '5.5.0',
692
694
  });
693
695
  }
694
696
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
695
697
  const params = await getParams({ ...data, skuId, bMallTag, num });
696
698
  return await this.bMallAddCart(params);
697
699
  }
698
700
  async bMallGetSkuNumService(bMallTag = 1) {
699
701
  const params = await getParams({ bMallTag });
700
702
  delete params.operations;
701
703
  return await this.bMallGetOmittedProduct(params);
702
704
  }
703
705
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
704
706
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
705
707
  return await this.bMallRemoveCart(params);
706
708
  }
707
709
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
708
710
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
709
711
  return await this.bMallChangeCart(params);
710
712
  }
711
713
 
712
714
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
713
715
  if (!needRequest && isH5 && window?.bMallCartData) {
714
716
  return window?.bMallCartData;
715
717
  }
716
718
  const cartData = await this.bMallGetSkuNumService(bMallTag);
717
719
  let items;
718
720
  if (cartData.ok && cartData.result) {
719
721
  items = cartData?.result?.items || {};
720
722
  }
721
723
  if (isH5) {
722
724
  window.bMallCartData = items;
723
725
  }
724
726
  return items;
725
727
  }
726
728
 
727
729
  async bMallCartHandle(goodItem, num) {
728
730
  try {
729
731
  const {
730
732
  skuUuid,
731
733
  limitUpper,
732
734
  limitLower,
733
735
  } = goodItem;
734
736
  let cartNum = Number(num);
735
737
  if (limitLower && cartNum && cartNum < limitLower) {
736
738
  cartNum = limitLower;
737
739
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
738
740
  cartNum = limitUpper;
739
741
  }
740
742
  if (skuUuid && cartNum > 0) {
741
743
  return this.bMallChangeCartService({
742
744
  ...goodItem,
743
745
  skuUuid,
744
746
  num: cartNum,
745
747
  });
746
748
  } else if (!skuUuid && cartNum > 0) {
747
749
  return this.bMallAddCartService({ ...goodItem, num: cartNum });
748
750
  } else if (skuUuid && !cartNum) {
749
751
  return this.bMallRemoveCartService({
750
752
  ...goodItem,
751
753
  skuUuid,
752
754
  num: cartNum,
753
755
  });
754
756
  } else {
755
757
  console.error('参数不全');
756
758
  return false;
757
759
  }
758
760
  } catch (e) {
759
761
  console.error(e);
760
762
  }
761
763
  }