@conecli/cone-render 0.10.1-shop3.14 → 0.10.1-shop3.140

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/README.md +1 -1
  2. package/dist/api/index.ts +1 -1
  3. package/dist/common/accessibility.h5.ts +1 -0
  4. package/dist/common/accessibility.ts +1 -0
  5. package/dist/common/const.ts +1 -1
  6. package/dist/common/index.h5.ts +1 -1
  7. package/dist/common/index.jd.ts +1 -1
  8. package/dist/common/index.ts +1 -1
  9. package/dist/common/index.weapp.ts +1 -1
  10. package/dist/common/jdplayerSdk.weapp.tsx +1 -0
  11. package/dist/common/jssdk.ts +1 -1
  12. package/dist/common/jssdk.weapp.ts +1 -0
  13. package/dist/common/pageType.ts +1 -1
  14. package/dist/common/token/index.h5.ts +1 -1
  15. package/dist/common/token/token.jd.ts +1 -1
  16. package/dist/common/wxappApi.ascf.ts +1 -0
  17. package/dist/common/wxappApi.ts +1 -1
  18. package/dist/components/ErrorBoundary.tsx +1 -1
  19. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  20. package/dist/components/base/CountDown/index.tsx +1 -1
  21. package/dist/components/base/CountDownForApp/index.module.scss +52 -0
  22. package/dist/components/base/CountDownForApp/index.tsx +1 -0
  23. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  24. package/dist/components/base/CustomVideo/index.tsx +1 -1
  25. package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
  26. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  27. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  28. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  29. package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
  30. package/dist/components/base/InViewRender/index.tsx +1 -1
  31. package/dist/components/base/LazyLayoutLoad/index.module.scss +9 -9
  32. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  33. package/dist/components/base/LazyLoadImage/const.ts +1 -1
  34. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  35. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  36. package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
  37. package/dist/components/base/NetworkDataError/const.ts +1 -1
  38. package/dist/components/base/NetworkDataError/index.module.scss +118 -72
  39. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  40. package/dist/components/base/Price/Base/index.module.scss +12 -0
  41. package/dist/components/base/Price/Base/index.tsx +1 -1
  42. package/dist/components/base/Price/Double/index.module.scss +26 -2
  43. package/dist/components/base/Price/Double/index.tsx +1 -1
  44. package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
  45. package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
  46. package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
  47. package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
  48. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  49. package/dist/components/floorItem.tsx +1 -1
  50. package/dist/components/isv/Floor/index.tsx +1 -1
  51. package/dist/components/remoteFloorItem.tsx +1 -1
  52. package/dist/config/env.ts +1 -1
  53. package/dist/interface/common.ts +1 -1
  54. package/dist/interface/component.ts +1 -1
  55. package/dist/interface/jumpEventReport.ts +1 -1
  56. package/dist/interface/service.ts +1 -1
  57. package/dist/jumpEventReport/base.ts +1 -1
  58. package/dist/jumpEventReport/const.ts +1 -1
  59. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  60. package/dist/jumpEventReport/index.h5.ts +1 -1
  61. package/dist/jumpEventReport/index.jd.ts +1 -1
  62. package/dist/jumpEventReport/index.weapp.ts +1 -1
  63. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  64. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  65. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
  66. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  67. package/dist/jumpEventReport/web/report.ts +1 -1
  68. package/dist/jumpEventReport/web.base.ts +1 -1
  69. package/dist/jumpEventReport/web.jd.ts +1 -1
  70. package/dist/jumpEventReport/web.pc.ts +1 -1
  71. package/dist/jumpEventReport/web.tjm.ts +1 -1
  72. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  73. package/dist/language/en_US.json +398 -0
  74. package/dist/language/zh_CN.json +398 -0
  75. package/dist/language/zh_HK.json +398 -0
  76. package/dist/libs/openShopBridge.js +161 -0
  77. package/dist/libs/openShopBridge.min.js +1 -0
  78. package/dist/libs/taroAppReport.js +2 -2
  79. package/dist/modules/ContainerFloorList/index.h5.module.scss +16 -2
  80. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  81. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  82. package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
  83. package/dist/open/api/environment.ts +1 -1
  84. package/dist/open/api/shopMember.ts +1 -1
  85. package/dist/open/api/shopMember.weapp.ts +1 -0
  86. package/dist/open/api/track.ts +1 -1
  87. package/dist/open/api/util.ts +1 -1
  88. package/dist/open/components/index.ts +1 -1
  89. package/dist/open/index.ts +1 -1
  90. package/dist/sass/app.h5.scss +12 -1
  91. package/dist/sass/base.scss +8 -4
  92. package/dist/service/fetchGateway.ts +1 -1
  93. package/dist/service/fetchGateway.weapp.ts +1 -1
  94. package/dist/service/fetchJsonp.weapp.ts +1 -0
  95. package/dist/service/http/const.ts +1 -1
  96. package/dist/service/http/h5Http.ts +1 -1
  97. package/dist/service/http/httpInterceptors.weapp.ts +1 -0
  98. package/dist/service/requestServer.h5.ts +1 -1
  99. package/dist/service/requestServer.ts +1 -1
  100. package/dist/service/requestServer.weapp.ts +1 -1
  101. package/dist/utils/connectNativeJsBridge.ts +1 -1
  102. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  103. package/dist/utils/h5Utils.ts +1 -1
  104. package/dist/utils/harmonyCallRouter.h5.ts +1 -0
  105. package/dist/utils/harmonyCallRouter.ts +0 -0
  106. package/dist/utils/index.h5.ts +1 -1
  107. package/dist/utils/index.ts +1 -1
  108. package/dist/utils/index.weapp.ts +1 -1
  109. package/dist/utils/jumpExtMapUtil.ts +1 -0
  110. package/dist/utils/jumpExtMapUtil.weapp.ts +1 -0
  111. package/dist/utils/log.ts +1 -0
  112. package/dist/utils/sColor.weapp.ts +1 -0
  113. package/dist/utils/utils.ts +1 -1
  114. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  115. package/dist/wxapp/common/user_info.js +1 -1
  116. package/dist/wxapp/pages/shopx/prefetch.js +1 -0
  117. package/package.json +169 -141
  118. package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
  119. package/dist/utils/priceUtils.js +0 -1
  120. /package/dist/utils/{jumpExtMapUtil.js → jumpExtMapUtil.h5.ts} +0 -0
  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
  draBusinessCustomReport,
13
12
  isLanguageForEn,
14
13
  isJdApp,
15
14
  isIosDevice,
16
15
  isAndroidDevice,
17
16
  isJdAndHarmonyDevice,
18
17
  showSuccessToast,
19
18
  showFailToast,
20
19
  isH5,
21
20
  isWxMinAndWxapp,
22
21
  isMin,
23
22
  isPc,
24
23
  draInterfaceCustomReport,
25
24
  callRouterIOS,
26
25
  callRouterAndroid,
27
26
  sendNativePageToShowCartFloatBtn,
28
27
  cookiesStr: '',
29
28
  requestHeaderContentType: {
30
29
  jsonHeader: {
31
30
  'content-type': 'application/json;charset=utf-8',
32
31
  },
33
32
  formDataHeader: {
34
33
  'content-type': 'application/x-www-form-urlencoded',
35
34
  },
36
35
  },
37
36
  requestBaseParam: {
38
37
  data: null,
39
38
  header: {
40
39
  'content-type': 'application/json;charset=utf-8',
41
40
  },
42
41
  },
43
42
  timeOut: 7000,
44
43
  apiClientParams: {
45
44
  clientVersion: isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
46
45
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
47
46
  area: '1_72_2799_0',
48
47
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
49
48
  window.screen?.height * devicePixelRatio,
50
49
  )}`,
51
50
  uuid: UUID,
52
51
  },
53
52
  public addressFetchInfo: {
54
53
  reqState: boolean;
55
54
  promiseInstance: null | Promise<any>;
56
55
  };
57
56
  public getPromotionConfig: {
58
57
  projectId: null | string | number;
59
58
  pageId: null | string | number;
60
59
  };
61
60
  public resInfo: ServiceInterFace.HttpRequestInfo;
62
61
  public api: ServiceInterFace.HttpApi;
63
62
  public isPageDomain: boolean;
64
63
  public verifyColorList: string[];
65
64
  private isShowJdShopCartFloatBtn: boolean;
66
65
  constructor(opt) {
67
66
  this._init();
68
67
  this.addressFetchInfo = {
69
68
  reqState: false,
70
69
  promiseInstance: null,
71
70
  };
72
71
  this.getPromotionConfig = {
73
72
  projectId: null,
74
73
  pageId: null,
75
74
  };
76
75
  this._userAreaUpdateListen();
77
76
  this.resInfo = this._getResConfig(opt);
78
77
  this.api = api;
79
78
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
80
79
  this.verifyColorList = [
81
80
  ...MobileVerifyColorList,
82
81
  ...AppVerifyColorList,
83
82
  ...JshopxVerifyColorList,
84
83
  ...BMallVerifyColorList,
85
84
  ];
86
85
  this.isShowJdShopCartFloatBtn =
87
86
  jdAppVersionCompare(isJdAndIosDevice ? '13.8.6' : '13.6.2') >= 0;
88
87
  }
89
88
  _init(): void {
90
89
  httpInterceptors.forEach((item) => {
91
90
  Taro.addInterceptor((chain) => item(chain));
92
91
  });
93
92
  }
94
93
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
95
94
  return Object.assign({}, DefaultConfig, opt);
96
95
  }
97
96
 
98
97
  _userAreaUpdateListen() {
99
98
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
100
99
  area &&
101
100
  area !== '' &&
102
101
  this.updateApiClientParamsResInfo({
103
102
  area,
104
103
  });
105
104
  console.log(
106
105
  'cone-render收到原生端获取传来的四级地址信息',
107
106
  area,
108
107
  '更新后的接口底层信息',
109
108
  this.resInfo.apiClientParams,
110
109
  );
111
110
  });
112
111
  }
113
112
  updateApiClientParamsResInfo(opt = {}) {
114
113
  const { area, ...others } = opt;
115
114
  this.resInfo.apiClientParams = {
116
115
  ...this.resInfo.apiClientParams,
117
116
  ...others,
118
117
  };
119
118
  if (area) {
120
119
  this.resInfo.apiClientParams.area = area;
121
120
  }
122
121
  }
123
122
 
124
123
  checkFunctionIdToReturnAppId(functionId) {
125
124
  if (JshopxColorFunctionIdList.includes(functionId)) {
126
125
  return APPID.JSHOPX_COLOR_APPID;
127
126
  } else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
128
127
  return APPID.PAGES_COLOR_APPID;
129
128
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
130
129
  return APPID.SHOP_MEMBER_COLOR_APPID;
131
130
  } else if (B2BColorFunctionIdList.includes(functionId)) {
132
131
  return APPID.B2B_COLOR_APPID;
133
132
  } else if (isPc) {
134
133
  return APPID.MALL_COLOR_APPID;
135
134
  } else {
136
135
  return APPID.SHOP_COLOR_APPID;
137
136
  }
138
137
  }
139
138
 
140
139
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
141
140
  if (
142
141
  functionId === 'receiveShopCoupon' &&
143
142
  ((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
144
143
  isWxMinAndWxapp)
145
144
  ) {
146
145
  clientParams = Object.assign(
147
146
  {},
148
147
  {
149
148
  loginType: '1',
150
149
  loginWQBiz: WXAPP_BIZ_KEY,
151
150
  },
152
151
  clientParams,
153
152
  );
154
153
  }
155
154
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
156
155
  typeof apiClientParams.appid === 'undefined' &&
157
156
  (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
158
157
  const isColorVerify = this.verifyColorList.includes(functionId);
159
158
  const getReqData = {
160
159
  functionId: functionId,
161
160
  body: JSON.stringify(bodyParams),
162
161
  t: Date.now(),
163
162
  ...apiClientParams,
164
163
  };
165
164
  return http
166
165
  .request({
167
166
  url: this.api.apiFunc,
168
167
  data: getReqData,
169
168
  isColorVerify,
170
169
  })
171
170
  .then((res: ServiceInterFace.RequestPromiseRes) => {
172
171
  const { statusCode, data, status, msg } = res;
173
172
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
174
173
  ok: true,
175
174
  };
176
175
  if ((statusCode === 200 || status === '0') && data) {
177
176
  changeRes = this.dealResponseFormatRes(data);
178
177
  return changeRes;
179
178
  } else {
180
179
  changeRes = {
181
180
  ...data,
182
181
  statusCode,
183
182
  status,
184
183
  msg,
185
184
  ok: false,
186
185
  };
187
186
  return changeRes;
188
187
  }
189
188
  })
190
189
  .catch((res) => {
191
190
  const propertyNames = Object.getOwnPropertyNames(res);
192
191
  const resObject = {};
193
192
  propertyNames.forEach((propertyName) => {
194
193
  resObject[propertyName] = res[propertyName];
195
194
  });
196
195
  draInterfaceCustomReport({
197
196
  subMsg:
198
197
  '接口请求异常,进入catch逻辑,例如h5请求神盾(反爬、小号、风控)或加固拦截返回status为403等',
199
198
  url: this.api.apiFunc,
200
199
  source: 'remote',
201
200
  requestType: res?.requestType,
202
201
  errorType: 'catchError',
203
202
  functionId: getReqData?.functionId,
204
203
  appid: getReqData?.appid,
205
204
  client: getReqData?.client,
206
205
  clientVersion: getReqData?.clientVersion,
207
206
  statusCode: res?.statusCode,
208
207
  status: res?.status,
209
208
  statusText: res?.statusText,
210
209
  code: res?.data?.code || res?.data?.subCode,
211
210
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
212
211
  originReqDataStr: JSON.stringify(getReqData),
213
212
  originResDataStr: JSON.stringify(res, propertyNames),
214
213
  });
215
214
  return {
216
215
  ...resObject,
217
216
  ok: false,
218
217
  } as ServiceInterFace.RequestResponseFormatRes;
219
218
  });
220
219
  }
221
220
 
222
221
  dealResponseFormatRes(data) {
223
222
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
224
223
  ok: true,
225
224
  };
226
225
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
227
226
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
228
227
  ? Number(data.subCode)
229
228
  : -1;
230
229
  if (
231
230
  data.success === true ||
232
231
  data.isSuccess ||
233
232
  resCode === 0 ||
234
233
  resCode === 200 ||
235
234
  subCode === 0
236
235
  ) {
237
236
  changeRes = {
238
237
  result: Object.prototype.hasOwnProperty.call(data, 'result')
239
238
  ? data.result
240
239
  : Object.prototype.hasOwnProperty.call(data, 'data')
241
240
  ? data.data
242
241
  : data,
243
242
  code: data.code ?? 200,
244
243
  ok: true,
245
244
  source: data,
246
245
  };
247
246
  return changeRes;
248
247
  } else {
249
248
  changeRes = {
250
249
  ...data,
251
250
  ok: false,
252
251
  };
253
252
  return changeRes;
254
253
  }
255
254
  }
256
255
 
257
256
  async receiveCoupon(param = {}, clientParams) {
258
257
  const loginType = isPc ? { loginType: 3 } : {};
259
258
  return await this.gatewayReq(
260
259
  'receiveShopCoupon',
261
260
  {
262
261
  operation: '3',
263
262
  ...param,
264
263
  },
265
264
  { ...loginType, ...clientParams },
266
265
  );
267
266
  }
268
267
 
269
268
  getCustomerCenterDispatch(params = {}) {
270
269
  return this.gatewayReq('customerCenterDispatch', params, {
271
270
  clientVersion: '9.2.0',
272
271
  client: 'H5',
273
272
  uuid: 88888,
274
273
  appid: 'shopmember_m_jd_com',
275
274
  });
276
275
  }
277
276
 
278
277
  batchAddCart(...args) {
279
278
  let skuIds, num, showToast, giftCard;
280
279
  if (['number', 'string'].includes(typeof args[0])) {
281
280
  [skuIds, num = 1, showToast = true, giftCard = false] = args;
282
281
  } else if (typeof args[0] === 'object' && args[0] !== null) {
283
282
  const params = args[0];
284
283
  skuIds = params.skuIds;
285
284
  num = params.num || 1;
286
285
  showToast = params.showToast !== undefined ? params.showToast : true;
287
286
  giftCard = params.giftCard !== undefined ? params.giftCard : false;
288
287
  } else {
289
288
  console.error('batchAddCart() Invalid arguments!', args)
290
289
  try{
291
290
  const data = {
292
291
  type: 'batchAddCart',
293
292
  subType: 'invalidInputParameter',
294
293
  errMsg: '入参不合法',
295
294
  originData: args
296
295
  }
297
296
  draBusinessCustomReport(data)
298
297
  }catch(e){
299
298
  console.error('draBusinessCustomReport error:', e)
300
299
  }
301
300
  const msg = isLanguageForEn? 'Please retry later': '加入购物车失败,请稍后重试!'
302
301
  showFailToast({
303
302
  title: msg,
304
303
  });
305
304
  return Promise.resolve({
306
305
  ok: false,
307
306
  msg,
308
307
  });
309
308
  }
310
309
  const addToWhereText = giftCard? '购物清单': '购物车'
311
310
  const successMsg = isLanguageForEn? 'Success': `加入${addToWhereText}成功`
312
311
  const failMsg = isLanguageForEn? 'Please retry later': `加入${addToWhereText}失败,请稍后重试!`
313
312
  if (skuIds) {
314
313
  return this._addShopGoodCart(`${skuIds}`, `${num}`, {giftCard})
315
314
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
316
315
  if (res?.ok) {
317
316
  showToast &&
318
317
  !res?.isOpenApp &&
319
318
  showSuccessToast({
320
319
  title: successMsg,
321
320
  });
322
321
  this.isShowJdShopCartFloatBtn &&
323
322
  sendNativePageToShowCartFloatBtn({
324
323
  isShow: true,
325
324
  });
326
325
  } else {
327
326
  showToast &&
328
327
  showFailToast({
329
328
  title: res?.errMsg || failMsg,
330
329
  });
331
330
  }
332
331
  return Promise.resolve(res);
333
332
  })
334
333
  .catch((e) => {
335
334
  console.log('调用加购方法异常=======>', e);
336
335
  return Promise.resolve({
337
336
  ok: false,
338
337
  msg: failMsg,
339
338
  });
340
339
  });
341
340
  } else {
342
341
  try{
343
342
  const data = {
344
343
  type: 'batchAddCart',
345
344
  subType: 'invalidInputParameter',
346
345
  errMsg: '没有传入合法的skuIds',
347
346
  originData: skuIds
348
347
  }
349
348
  draBusinessCustomReport(data)
350
349
  }catch(e){
351
350
  console.error('draBusinessCustomReport error:', e)
352
351
  }
353
352
  return Promise.resolve({
354
353
  ok: false,
355
354
  msg: failMsg,
356
355
  });
357
356
  }
358
357
  }
359
358
  const loginType = isPc ? { loginType: 3 } : {};
360
359
  return this.gatewayReq(
361
360
  'giftCardAddCart',
362
361
  {
363
362
  skuList,
364
363
  num: Number(num)
365
364
  },
366
365
  { ...loginType},
367
366
  );
368
367
  }
369
368
 
370
369
  _addShopGoodCart(skuIdsStr, addCardNum = '1', {giftCard}) {
371
370
  return new Promise((resolve) => {
372
371
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
373
372
  if (productIdsArr.length > 0) {
374
373
  if(giftCard){
375
374
  this.giftCardAddCart(productIdsArr, addCardNum).then((res) => {
376
375
  if(res?.code === '0' && res?.result?.value){
377
376
  resolve({
378
377
  ok: true,
379
378
  })
380
379
  }else{
381
380
  try{
382
381
  const data = {
383
382
  type: 'batchAddCart',
384
383
  subType: 'addCartFailByGiftCard',
385
384
  errMsg: '礼品卡加车接口返回加车失败标识',
386
385
  originData: res
387
386
  }
388
387
  draBusinessCustomReport(data)
389
388
  }catch(e){
390
389
  console.error('draBusinessCustomReport error:', e)
391
390
  }
392
391
  resolve({
393
392
  ok: false,
394
393
  msg: '加购失败,请稍后重试',
395
394
  });
396
395
  }
397
396
  }).catch((e) => {
398
397
  console.error('礼品卡加车失败: ', e);
399
398
  resolve({
400
399
  ok: false,
401
400
  msg: '加购失败,请稍后重试',
402
401
  });
403
402
  });
404
403
  }
405
404
  else
406
405
  if (isJdApp && !isJdAndHarmonyDevice) {
407
406
  const nativeAddCartCallBack = `nativeBatchAddCart${Date.now() + Number(productIdsArr[0]) + Number(addCardNum)}`;
408
407
  console.log(
409
408
  '==========>',
410
409
  '原生批量加车, 回调方法保证唯一添加skuid和数量,nativeAddCartCallBack',
411
410
  nativeAddCartCallBack,
412
411
  );
413
412
  if (!window[nativeAddCartCallBack]) {
414
413
  window[nativeAddCartCallBack] = (res) => {
415
414
  const getMessageJsonData = typeof res === 'string' ? JSON.parse(res) : res;
416
415
  console.info(
417
416
  '获取批量加车原始数据',
418
417
  res,
419
418
  '====转换后的json数据为===',
420
419
  getMessageJsonData,
421
420
  );
422
421
  try {
423
422
  if (isAndroidDevice) {
424
423
  const isOk = getMessageJsonData?.status === '0';
425
424
  isOk? resolve({
426
425
  ok: true,
427
426
  msg: '已加入购物车!',
428
427
  })
429
428
  : resolve({
430
429
  ok: false,
431
430
  msg: '加购失败,请稍后重试',
432
431
  errMsg: getMessageJsonData?.data?.message ?? '',
433
432
  });
434
433
  if(!isOk){
435
434
  const data = {
436
435
  type: 'batchAddCart',
437
436
  subType: 'addCartFailByH5CallAndroidNative',
438
437
  errMsg: 'H5调用安卓原生加车失败',
439
438
  originData: getMessageJsonData
440
439
  }
441
440
  draBusinessCustomReport(data)
442
441
  }
443
442
  } else if (isIosDevice) {
444
443
  const isOk = getMessageJsonData?.status === '0' && getMessageJsonData?.data?.code === 0;
445
444
  isOk? resolve({
446
445
  ok: true,
447
446
  msg: '已加入购物车!',
448
447
  })
449
448
  : resolve({
450
449
  ok: false,
451
450
  msg: '批量加车失败,请稍后重试',
452
451
  errMsg: getMessageJsonData?.data?.message ?? '',
453
452
  });
454
453
  if(!isOk){
455
454
  const data = {
456
455
  type: 'batchAddCart',
457
456
  subType: 'addCartFailByH5CallIosNative',
458
457
  errMsg: 'H5调用IOS原生加车失败',
459
458
  originData: getMessageJsonData
460
459
  }
461
460
  draBusinessCustomReport(data)
462
461
  }
463
462
  } else {
464
463
  resolve({
465
464
  ok: false,
466
465
  msg: '加购失败,请稍后重试',
467
466
  });
468
467
  const data = {
469
468
  type: 'batchAddCart',
470
469
  subType: 'addCartFailByH5CallUnknownNative',
471
470
  errMsg: 'H5调用未知原生加车失败',
472
471
  }
473
472
  draBusinessCustomReport(data)
474
473
  }
475
474
  } catch (e) {
476
475
  resolve({
477
476
  ok: false,
478
477
  msg: '加购失败,请稍后重试',
479
478
  });
480
479
  console.warn('批量加车转换数据异常', e);
481
480
  const data = {
482
481
  type: 'batchAddCart',
483
482
  subType: 'addCartFailByTransformData',
484
483
  errMsg: '批量加车转换数据异常',
485
484
  originData: e
486
485
  }
487
486
  draBusinessCustomReport(data)
488
487
  }
489
488
  window[nativeAddCartCallBack] = null;
490
489
  };
491
490
  }
492
491
  const productsAddCartList = productIdsArr.map((skuItem) => {
493
492
  const adInfos = getAdInfoBySkuId(skuItem)
494
493
  const extFlag = adInfos? {adInfos}: {}
495
494
  return isAndroidDevice
496
495
  ? {
497
496
  sku: skuItem,
498
497
  num: addCardNum,
499
498
  extFlag
500
499
  }
501
500
  : {
502
501
  productCode: skuItem,
503
502
  buyCount: addCardNum,
504
503
  extFlag
505
504
  };
506
505
  });
507
506
  if (isAndroidDevice) {
508
507
  const androidProductsStr = JSON.stringify(productsAddCartList);
509
508
  callRouterAndroid({
510
509
  routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
511
510
  routerParam: {
512
511
  wareList: productsAddCartList,
513
512
  },
514
513
  callBackName: nativeAddCartCallBack,
515
514
  });
516
515
  } else if (isIosDevice) {
517
516
  if (isLowAppVer) {
518
517
  const lowVersionAppList = productIdsArr.map((skuItem) => {
519
518
  return {
520
519
  sku: skuItem,
521
520
  num: addCardNum,
522
521
  };
523
522
  });
524
523
  const lowVersionAppListStr = JSON.stringify(lowVersionAppList);
525
524
  const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`;
526
525
  jump.side.jdJumpToWeb(url, {});
527
526
  resolve({
528
527
  ok: true,
529
528
  isOpenApp: true,
530
529
  msg: '加购完成, 加购结果请点击购物车确认',
531
530
  });
532
531
  } else {
533
532
  callRouterIOS({
534
533
  routerURL: 'router://JDCartModule/batchAddService',
535
534
  routerParam: {
536
535
  sourceType: 'h5',
537
536
  sourceValue: '店铺批量加购',
538
537
  businessName: 'storeModel',
539
538
  isNewMode: '1',
540
539
  NotPassWebview: '1',
541
540
  products: productsAddCartList,
542
541
  },
543
542
  callBackName: nativeAddCartCallBack,
544
543
  });
545
544
  }
546
545
  }
547
546
  } else if (isMin) {
548
547
  console.log('==========>', '京购批量加车!');
549
548
  const productsAddCartList = productIdsArr.map((skuItem) => {
550
549
  return {
551
550
  skuId: skuItem,
552
551
  buyNum: addCardNum,
553
552
  };
554
553
  });
555
554
  global.wxAppBizInstance
556
555
  .addCart({ commArr: productsAddCartList })
557
556
  .then((res) => {
558
557
  console.log('dealCartSuccess: ', res);
559
558
  resolve({
560
559
  ok: true,
561
560
  msg: '已加入购物车!',
562
561
  data: res,
563
562
  });
564
563
  })
565
564
  .catch((e) => {
566
565
  console.log('京购小程序批量加车失败dealCartFail: ', e);
567
566
  resolve({
568
567
  ok: false,
569
568
  msg: '加购失败,请稍后重试',
570
569
  });
571
570
  const data = {
572
571
  type: 'batchAddCart',
573
572
  subType: 'addCartFailByH5CallMini',
574
573
  errMsg: 'H5调用小程序加车失败',
575
574
  originData: e
576
575
  }
577
576
  draBusinessCustomReport(data)
578
577
  });
579
578
  } else {
580
579
  console.log('==========>', 'M站批量加车!');
581
580
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
582
581
  }
583
582
  } else {
584
583
  resolve({
585
584
  ok: false,
586
585
  msg: '加购sku不能为空',
587
586
  });
588
587
  const data = {
589
588
  type: 'batchAddCart',
590
589
  subType: 'addCartFailNoSku',
591
590
  errMsg: '加购sku不能为空',
592
591
  originData: skuIdsStr
593
592
  }
594
593
  draBusinessCustomReport(data)
595
594
  }
596
595
  });
597
596
  }
598
597
 
599
598
  productAddToCart(skuIdsStr, num) {
600
599
  return new Promise((resolve) => {
601
600
  if (window.AddcartToolObj) {
602
601
  window.AddcartToolObj.addCart({
603
602
  skuId: skuIdsStr,
604
603
  num,
605
604
  source: 'sjdpyw',
606
605
  actId: '1',
607
606
  loginType: window?.isJingGouMiniViewState ? '11' : '2',
608
607
  sucFun(res) {
609
608
  console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
610
609
  if (res.errId === '0' && res.cartJson) {
611
610
  resolve({
612
611
  ok: true,
613
612
  msg: '已加入购物车!',
614
613
  ...res,
615
614
  });
616
615
  } else {
617
616
  if (res.errId === '13') {
618
617
  global.doLogin();
619
618
  } else {
620
619
  resolve({
621
620
  ok: false,
622
621
  msg: '加购失败,请稍后重试',
623
622
  ...res,
624
623
  });
625
624
  const data = {
626
625
  type: 'batchAddCart',
627
626
  subType: 'addCartFailByH5CallM',
628
627
  errMsg: 'H5调用M站加车失败',
629
628
  originData: res
630
629
  }
631
630
  draBusinessCustomReport(data)
632
631
  }
633
632
  }
634
633
  },
635
634
  failFun(err) {
636
635
  console.log('fail', err);
637
636
  resolve({
638
637
  ok: false,
639
638
  msg: '加购失败,请稍后重试',
640
639
  ...err,
641
640
  });
642
641
  const data = {
643
642
  type: 'batchAddCart',
644
643
  subType: 'addCartFailByH5CallM',
645
644
  errMsg: 'H5调用M站加车失败',
646
645
  originData: err
647
646
  }
648
647
  draBusinessCustomReport(data)
649
648
  },
650
649
  });
651
650
  } else {
652
651
  resolve({
653
652
  ok: false,
654
653
  msg: '购物车方法检查异常',
655
654
  });
656
655
  const data = {
657
656
  type: 'batchAddCart',
658
657
  subType: 'addCartFailByH5CallM',
659
658
  errMsg: 'H5调用M站加车检查依赖方法异常',
660
659
  }
661
660
  draBusinessCustomReport(data)
662
661
  }
663
662
  });
664
663
  }
665
664
  bMallGetUserInfo = () => {
666
665
  return getBMallUserInfo();
667
666
  };
668
667
  async bMallAddCart(params = {}) {
669
668
  return await this.gatewayReq('bmall_cartAdd', params, {
670
669
  client: 'H5',
671
670
  clientVersion: '5.5.0',
672
671
  });
673
672
  }
674
673
  async bMallChangeCart(params = {}) {
675
674
  return await this.gatewayReq('bmall_cartChange', params, {
676
675
  client: 'H5',
677
676
  clientVersion: '5.5.0',
678
677
  });
679
678
  }
680
679
  async bMallRemoveCart(params = {}) {
681
680
  return await this.gatewayReq(
682
681
  'bmall_cartRemove',
683
682
  params,
684
683
  {
685
684
  client: 'H5',
686
685
  clientVersion: '5.5.0',
687
686
  },
688
687
  );
689
688
  }
690
689
  async bMallGetOmittedProduct(params = {}) {
691
690
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
692
691
  client: 'H5',
693
692
  clientVersion: '5.5.0',
694
693
  });
695
694
  }
696
695
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
697
696
  const params = await getParams({ ...data, skuId, bMallTag, num });
698
697
  return await this.bMallAddCart(params);
699
698
  }
700
699
  async bMallGetSkuNumService(bMallTag = 1) {
701
700
  const params = await getParams({ bMallTag });
702
701
  delete params.operations;
703
702
  return await this.bMallGetOmittedProduct(params);
704
703
  }
705
704
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
706
705
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
707
706
  return await this.bMallRemoveCart(params);
708
707
  }
709
708
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
710
709
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
711
710
  return await this.bMallChangeCart(params);
712
711
  }
713
712
 
714
713
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
715
714
  if (!needRequest && isH5 && window?.bMallCartData) {
716
715
  return window?.bMallCartData;
717
716
  }
718
717
  const cartData = await this.bMallGetSkuNumService(bMallTag);
719
718
  let items;
720
719
  if (cartData.ok && cartData.result) {
721
720
  items = cartData?.result?.items || {};
722
721
  }
723
722
  if (isH5) {
724
723
  window.bMallCartData = items;
725
724
  }
726
725
  return items;
727
726
  }
728
727
 
729
728
  async bMallCartHandle(goodItem, num) {
730
729
  try {
731
730
  const {
732
731
  skuUuid,
733
732
  limitUpper,
734
733
  limitLower,
735
734
  } = goodItem;
736
735
  let cartNum = Number(num);
737
736
  if (limitLower && cartNum && cartNum < limitLower) {
738
737
  cartNum = limitLower;
739
738
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
740
739
  cartNum = limitUpper;
741
740
  }
742
741
  if (skuUuid && cartNum > 0) {
743
742
  return this.bMallChangeCartService({
744
743
  ...goodItem,
745
744
  skuUuid,
746
745
  num: cartNum,
747
746
  });
748
747
  } else if (!skuUuid && cartNum > 0) {
749
748
  return this.bMallAddCartService({ ...goodItem, num: cartNum });
750
749
  } else if (skuUuid && !cartNum) {
751
750
  return this.bMallRemoveCartService({
752
751
  ...goodItem,
753
752
  skuUuid,
754
753
  num: cartNum,
755
754
  });
756
755
  } else {
757
756
  console.error('参数不全');
758
757
  return false;
759
758
  }
760
759
  } catch (e) {
761
760
  console.error(e);
762
761
  }
763
762
  }
763
+ import Taro from '@tarojs/taro';
764
764
  APPID,
765
765
  JshopxColorFunctionIdList,
766
766
  PagesColorFunctionIdList,
767
767
  PAGES_DOMAIN,
768
768
  B2BColorFunctionIdList,
769
769
  MobileVerifyColorList,
770
770
  AppVerifyColorList,
771
771
  JshopxVerifyColorList,
772
772
  BMallVerifyColorList,
773
773
  shopMemberColorFunctionIdList,
774
774
  draBusinessCustomReport,
775
775
  isJdApp,
776
776
  isIosDevice,
777
777
  isAndroidDevice,
778
778
  showSuccessToast,
779
779
  showFailToast,
780
780
  isH5,
781
781
  isWxMinAndWxapp,
782
782
  isMin,
783
783
  isPc,
784
784
  draInterfaceCustomReport,
785
785
  isHarmonyDevice,
786
786
  isAscfApp,
787
787
  callRouterIOS,
788
788
  callRouterAndroid,
789
789
  callRouterHarmony,
790
790
  sendNativePageToShowCartFloatBtn,
791
791
  cookiesStr: '',
792
792
  requestHeaderContentType: {
793
793
  jsonHeader: {
794
794
  'content-type': 'application/json;charset=utf-8',
795
795
  },
796
796
  formDataHeader: {
797
797
  'content-type': 'application/x-www-form-urlencoded',
798
798
  },
799
799
  },
800
800
  requestBaseParam: {
801
801
  data: null,
802
802
  header: {
803
803
  'content-type': 'application/json;charset=utf-8',
804
804
  },
805
805
  },
806
806
  timeOut: 7000,
807
807
  apiClientParams: {
808
808
  clientVersion: isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
809
809
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
810
810
  area: '1_72_2799_0',
811
811
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
812
812
  window.screen?.height * devicePixelRatio,
813
813
  )}`,
814
814
  uuid: UUID,
815
815
  },
816
816
  window.shopGlobalSwitch?.useNativeHarmonyAddCartJdAppVersion;
817
817
  nativeHarmonyAddCartJdAppVersion && jdAppVersionCompare(nativeHarmonyAddCartJdAppVersion) >= 0;
818
818
  public addressFetchInfo: {
819
819
  reqState: boolean;
820
820
  promiseInstance: null | Promise<any>;
821
821
  };
822
822
  public getPromotionConfig: {
823
823
  projectId: null | string | number;
824
824
  pageId: null | string | number;
825
825
  };
826
826
  public resInfo: ServiceInterFace.HttpRequestInfo;
827
827
  public api: ServiceInterFace.HttpApi;
828
828
  public isPageDomain: boolean;
829
829
  public verifyColorList: string[];
830
830
  private isShowJdShopCartFloatBtn: boolean;
831
831
  constructor(opt) {
832
832
  this._init();
833
833
  this.addressFetchInfo = {
834
834
  reqState: false,
835
835
  promiseInstance: null,
836
836
  };
837
837
  this.getPromotionConfig = {
838
838
  projectId: null,
839
839
  pageId: null,
840
840
  };
841
841
  this._userAreaUpdateListen();
842
842
  this.resInfo = this._getResConfig(opt);
843
843
  this.api = api;
844
844
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
845
845
  this.verifyColorList = [
846
846
  ...MobileVerifyColorList,
847
847
  ...AppVerifyColorList,
848
848
  ...JshopxVerifyColorList,
849
849
  ...BMallVerifyColorList,
850
850
  ];
851
851
  this.isShowJdShopCartFloatBtn =
852
852
  jdAppVersionCompare(isJdAndIosDevice ? '13.8.6' : '13.6.2') >= 0;
853
853
  }
854
854
  _init(): void {
855
855
  httpInterceptors.forEach((item) => {
856
856
  Taro.addInterceptor((chain) => item(chain));
857
857
  });
858
858
  }
859
859
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
860
860
  return Object.assign({}, DefaultConfig, opt);
861
861
  }
862
862
 
863
863
  _userAreaUpdateListen() {
864
864
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
865
865
  this.updateApiClientParamsResInfo(areaInfo);
866
866
  console.log(
867
867
  'cone-render收到原生端获取传来的四级地址信息',
868
868
  areaInfo,
869
869
  '更新后的接口底层信息',
870
870
  this.resInfo.apiClientParams,
871
871
  );
872
872
  });
873
873
  }
874
874
  updateApiClientParamsResInfo(opt = {}) {
875
875
  const { area, realTimeArea, ...others } = opt;
876
876
  this.resInfo.apiClientParams = {
877
877
  ...this.resInfo.apiClientParams,
878
878
  ...others,
879
879
  };
880
880
  area && area !== '' && (this.resInfo.apiClientParams.area = area);
881
881
  realTimeArea &&
882
882
  realTimeArea !== '' &&
883
883
  (this.resInfo.apiClientParams.realTimeArea = realTimeArea);
884
884
  }
885
885
 
886
886
  checkFunctionIdToReturnAppId(functionId) {
887
887
  if (JshopxColorFunctionIdList.includes(functionId)) {
888
888
  return APPID.JSHOPX_COLOR_APPID;
889
889
  } else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
890
890
  return APPID.PAGES_COLOR_APPID;
891
891
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
892
892
  return APPID.SHOP_MEMBER_COLOR_APPID;
893
893
  } else if (B2BColorFunctionIdList.includes(functionId)) {
894
894
  return APPID.B2B_COLOR_APPID;
895
895
  } else if (isPc) {
896
896
  return APPID.MALL_COLOR_APPID;
897
897
  } else {
898
898
  return APPID.SHOP_COLOR_APPID;
899
899
  }
900
900
  }
901
901
 
902
902
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
903
903
  if (
904
904
  functionId === 'receiveShopCoupon' &&
905
905
  ((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
906
906
  isWxMinAndWxapp)
907
907
  ) {
908
908
  clientParams = Object.assign(
909
909
  {},
910
910
  {
911
911
  loginType: isAscfApp ? '2' : '1',
912
912
  loginWQBiz: WXAPP_BIZ_KEY,
913
913
  },
914
914
  clientParams,
915
915
  );
916
916
  }
917
917
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
918
918
  typeof apiClientParams.appid === 'undefined' &&
919
919
  (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
920
920
  const isColorVerify = this.verifyColorList.includes(functionId);
921
921
  const getReqData = {
922
922
  functionId: functionId,
923
923
  body: JSON.stringify(bodyParams),
924
924
  t: Date.now(),
925
925
  ...apiClientParams,
926
926
  };
927
927
  return http
928
928
  .request({
929
929
  url: this.api.apiFunc,
930
930
  data: getReqData,
931
931
  isColorVerify,
932
932
  })
933
933
  .then((res: ServiceInterFace.RequestPromiseRes) => {
934
934
  const { statusCode, data, status, msg } = res;
935
935
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
936
936
  ok: true,
937
937
  };
938
938
  if ((statusCode === 200 || status === '0') && data) {
939
939
  changeRes = this.dealResponseFormatRes(data);
940
940
  return changeRes;
941
941
  } else {
942
942
  changeRes = {
943
943
  ...data,
944
944
  statusCode,
945
945
  status,
946
946
  msg,
947
947
  ok: false,
948
948
  };
949
949
  return changeRes;
950
950
  }
951
951
  })
952
952
  .catch((res) => {
953
953
  const propertyNames = Object.getOwnPropertyNames(res);
954
954
  const resObject = {};
955
955
  propertyNames.forEach((propertyName) => {
956
956
  resObject[propertyName] = res[propertyName];
957
957
  });
958
958
  draInterfaceCustomReport({
959
959
  eventName: 'apiStatusCode',
960
960
  errorName: `shop_${functionId}_error`,
961
961
  errorMessage: `接口返回statusCode为${res?.statusCode || res?.status}`,
962
962
  url: this.api.apiFunc,
963
963
  source: 'remote',
964
964
  requestType: res?.requestType,
965
965
  functionId: getReqData?.functionId,
966
966
  appid: getReqData?.appid,
967
967
  client: getReqData?.client,
968
968
  clientVersion: getReqData?.clientVersion,
969
969
  statusCode: res?.statusCode,
970
970
  status: res?.status,
971
971
  statusText: res?.statusText,
972
972
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
973
973
  originReqDataStr: JSON.stringify(getReqData),
974
974
  });
975
975
  return {
976
976
  ...resObject,
977
977
  ok: false,
978
978
  } as ServiceInterFace.RequestResponseFormatRes;
979
979
  });
980
980
  }
981
981
 
982
982
  dealResponseFormatRes(data) {
983
983
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
984
984
  ok: true,
985
985
  };
986
986
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
987
987
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
988
988
  ? Number(data.subCode)
989
989
  : -1;
990
990
  if (
991
991
  data.success === true ||
992
992
  data.isSuccess ||
993
993
  resCode === 0 ||
994
994
  resCode === 200 ||
995
995
  subCode === 0
996
996
  ) {
997
997
  changeRes = {
998
998
  result: Object.prototype.hasOwnProperty.call(data, 'result')
999
999
  ? data.result
1000
1000
  : Object.prototype.hasOwnProperty.call(data, 'data')
1001
1001
  ? data.data
1002
1002
  : data,
1003
1003
  code: data.code ?? 200,
1004
1004
  ok: true,
1005
1005
  source: data,
1006
1006
  };
1007
1007
  return changeRes;
1008
1008
  } else {
1009
1009
  changeRes = {
1010
1010
  ...data,
1011
1011
  ok: false,
1012
1012
  };
1013
1013
  return changeRes;
1014
1014
  }
1015
1015
  }
1016
1016
 
1017
1017
  async receiveCoupon(param = {}, clientParams) {
1018
1018
  const loginType = isPc ? { loginType: 3 } : {};
1019
1019
  return await this.gatewayReq(
1020
1020
  'receiveShopCoupon',
1021
1021
  {
1022
1022
  operation: '3',
1023
1023
  ...param,
1024
1024
  },
1025
1025
  { ...loginType, ...clientParams },
1026
1026
  );
1027
1027
  }
1028
1028
 
1029
1029
  getCustomerCenterDispatch(params = {}) {
1030
1030
  return this.gatewayReq('customerCenterDispatch', params, {
1031
1031
  clientVersion: '9.2.0',
1032
1032
  client: 'H5',
1033
1033
  uuid: 88888,
1034
1034
  appid: 'shopmember_m_jd_com',
1035
1035
  });
1036
1036
  }
1037
1037
 
1038
1038
  batchAddCart(...args) {
1039
1039
  let skuIds, num, showToast, giftCard, extFlag, extQuery;
1040
1040
  let skipNativeCartFloatBtn = false;
1041
1041
  if (['number', 'string'].includes(typeof args[0])) {
1042
1042
  [skuIds, num = 1, showToast = true, giftCard = false] = args;
1043
1043
  } else if (typeof args[0] === 'object' && args[0] !== null) {
1044
1044
  const params = args[0];
1045
1045
  skuIds = params.skuIds;
1046
1046
  num = params.num || 1;
1047
1047
  showToast = params.showToast !== undefined ? params.showToast : true;
1048
1048
  giftCard = params.giftCard !== undefined ? params.giftCard : false;
1049
1049
  extFlag = params.extFlag !== undefined ? params.extFlag : null;
1050
1050
  extQuery = params.extQuery !== undefined ? params.extQuery : null;
1051
1051
  skipNativeCartFloatBtn = params.skipNativeCartFloatBtn === true;
1052
1052
  } else {
1053
1053
  try {
1054
1054
  const data = {
1055
1055
  eventName: 'business',
1056
1056
  errorName: 'shop_batchAddCart_error',
1057
1057
  errorMessage: '入参不合法',
1058
1058
  extraData: JSON.stringify(args),
1059
1059
  };
1060
1060
  draBusinessCustomReport(data);
1061
1061
  } catch (e) {
1062
1062
  console.error('draBusinessCustomReport error:', e);
1063
1063
  }
1064
1064
  const msg = global?.languageJsonData?.failAddCart || '加入购物车失败,请稍后重试';
1065
1065
  showFailToast({
1066
1066
  title: msg,
1067
1067
  });
1068
1068
  return Promise.resolve({
1069
1069
  ok: false,
1070
1070
  msg,
1071
1071
  });
1072
1072
  }
1073
1073
  const successMsg = giftCard
1074
1074
  ? global?.languageJsonData?.successAddShopList || '加入购物清单成功'
1075
1075
  : global?.languageJsonData?.successAddCart || '加入购物车成功';
1076
1076
  const failMsg = giftCard
1077
1077
  ? global?.languageJsonData?.failAddShopList || '加入购物清单失败,请稍后重试'
1078
1078
  : global?.languageJsonData?.failAddCart || '加入购物车失败,请稍后重试';
1079
1079
  if (skuIds) {
1080
1080
  return this._addShopGoodCart(`${skuIds}`, `${num}`, {
1081
1081
  giftCard,
1082
1082
  extFlag,
1083
1083
  extQuery,
1084
1084
  })
1085
1085
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
1086
1086
  if (res?.ok) {
1087
1087
  showToast &&
1088
1088
  !res?.isOpenApp &&
1089
1089
  showSuccessToast({
1090
1090
  title: successMsg,
1091
1091
  });
1092
1092
  !skipNativeCartFloatBtn &&
1093
1093
  this.isShowJdShopCartFloatBtn &&
1094
1094
  sendNativePageToShowCartFloatBtn({
1095
1095
  isShow: true,
1096
1096
  });
1097
1097
  } else {
1098
1098
  showToast &&
1099
1099
  showFailToast({
1100
1100
  title: res?.errMsg || failMsg,
1101
1101
  });
1102
1102
  }
1103
1103
  return Promise.resolve(res);
1104
1104
  })
1105
1105
  .catch((e) => {
1106
1106
  console.log('调用加购方法异常=======>', e);
1107
1107
  return Promise.resolve({
1108
1108
  ok: false,
1109
1109
  msg: failMsg,
1110
1110
  });
1111
1111
  });
1112
1112
  } else {
1113
1113
  try {
1114
1114
  const data = {
1115
1115
  eventName: 'business',
1116
1116
  errorName: 'shop_batchAddCart_error',
1117
1117
  errorMessage: '没有传入合法的skuIds',
1118
1118
  };
1119
1119
  draBusinessCustomReport(data);
1120
1120
  } catch (e) {
1121
1121
  console.error('draBusinessCustomReport error:', e);
1122
1122
  }
1123
1123
  return Promise.resolve({
1124
1124
  ok: false,
1125
1125
  msg: failMsg,
1126
1126
  });
1127
1127
  }
1128
1128
  }
1129
1129
 
1130
1130
  async giftCardAddCart(skuList, num) {
1131
1131
  const loginType = isPc ? { loginType: 3 } : {};
1132
1132
  return this.gatewayReq(
1133
1133
  'giftCardAddCart',
1134
1134
  {
1135
1135
  skuList,
1136
1136
  num: Number(num),
1137
1137
  },
1138
1138
  { ...loginType },
1139
1139
  );
1140
1140
  }
1141
1141
 
1142
1142
  _addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard, extFlag, extQuery }) {
1143
1143
  return new Promise((resolve) => {
1144
1144
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
1145
1145
  if (productIdsArr.length > 0) {
1146
1146
  if (giftCard) {
1147
1147
  this.giftCardAddCart(productIdsArr, addCardNum)
1148
1148
  .then((res) => {
1149
1149
  if (res?.code === '0' && res?.result?.value) {
1150
1150
  resolve({
1151
1151
  ok: true,
1152
1152
  });
1153
1153
  } else {
1154
1154
  try {
1155
1155
  const data = {
1156
1156
  eventName: 'business',
1157
1157
  errorName: 'shop_batchAddCart_error',
1158
1158
  errorMessage: '礼品卡加车接口返回加车失败标识',
1159
1159
  };
1160
1160
  draBusinessCustomReport(data);
1161
1161
  } catch (e) {
1162
1162
  console.error('draBusinessCustomReport error:', e);
1163
1163
  }
1164
1164
  resolve({
1165
1165
  ok: false,
1166
1166
  msg: '加购失败,请稍后重试',
1167
1167
  });
1168
1168
  }
1169
1169
  })
1170
1170
  .catch((e) => {
1171
1171
  console.error('礼品卡加车失败: ', e);
1172
1172
  resolve({
1173
1173
  ok: false,
1174
1174
  msg: '加购失败,请稍后重试',
1175
1175
  });
1176
1176
  });
1177
1177
  } else if (
1178
1178
  isJdApp &&
1179
1179
  (!isHarmonyDevice || (isHarmonyDevice && useNativeHarmonyAddCartJd))
1180
1180
  ) {
1181
1181
  const nativeAddCartCallBack = `nativeBatchAddCart${
1182
1182
  Date.now() + Number(productIdsArr[0]) + Number(addCardNum)
1183
1183
  }`;
1184
1184
  console.log(
1185
1185
  '==========>',
1186
1186
  '使用原生批量加车, 回调方法保证唯一添加skuid和数量,nativeAddCartCallBack',
1187
1187
  nativeAddCartCallBack,
1188
1188
  );
1189
1189
  if (!window[nativeAddCartCallBack]) {
1190
1190
  window[nativeAddCartCallBack] = (res) => {
1191
1191
  const getMessageJsonData = typeof res === 'string' ? JSON.parse(res) : res;
1192
1192
  console.info(
1193
1193
  '获取批量加车原始数据',
1194
1194
  res,
1195
1195
  '====转换后的json数据为===',
1196
1196
  getMessageJsonData,
1197
1197
  );
1198
1198
  try {
1199
1199
  if (isAndroidDevice) {
1200
1200
  const isOk = getMessageJsonData?.status === '0';
1201
1201
  isOk
1202
1202
  ? resolve({
1203
1203
  ok: true,
1204
1204
  msg: '已加入购物车!',
1205
1205
  cartNum: getMessageJsonData?.data?.response?.cartNum || 0,
1206
1206
  })
1207
1207
  : resolve({
1208
1208
  ok: false,
1209
1209
  msg: '加购失败,请稍后重试',
1210
1210
  errMsg: getMessageJsonData?.data?.message ?? '',
1211
1211
  });
1212
1212
  if (!isOk) {
1213
1213
  const data = {
1214
1214
  eventName: 'business',
1215
1215
  errorName: 'shop_batchAddCart_error',
1216
1216
  errorMessage: 'H5调用Android原生加车失败',
1217
1217
  };
1218
1218
  draBusinessCustomReport(data);
1219
1219
  }
1220
1220
  } else if (isIosDevice) {
1221
1221
  const isOk =
1222
1222
  getMessageJsonData?.status === '0' && getMessageJsonData?.data?.code === 0;
1223
1223
  isOk
1224
1224
  ? resolve({
1225
1225
  ok: true,
1226
1226
  msg: '已加入购物车!',
1227
1227
  cartNum: getMessageJsonData?.data?.response?.cartNum || 0,
1228
1228
  })
1229
1229
  : resolve({
1230
1230
  ok: false,
1231
1231
  msg: '批量加车失败,请稍后重试',
1232
1232
  errMsg: getMessageJsonData?.data?.message ?? '',
1233
1233
  });
1234
1234
  if (!isOk) {
1235
1235
  const data = {
1236
1236
  eventName: 'business',
1237
1237
  errorName: 'shop_batchAddCart_error',
1238
1238
  errorMessage: 'H5调用IOS原生加车失败',
1239
1239
  };
1240
1240
  draBusinessCustomReport(data);
1241
1241
  }
1242
1242
  } else if (isHarmonyDevice) {
1243
1243
  const isOk =
1244
1244
  getMessageJsonData?.data?.code === 0 &&
1245
1245
  getMessageJsonData?.data?.response?.resultCode === 0;
1246
1246
  isOk
1247
1247
  ? resolve({
1248
1248
  ok: true,
1249
1249
  msg: '已加入购物车!',
1250
1250
  cartNum: getMessageJsonData?.data?.response?.cartNum || 0,
1251
1251
  })
1252
1252
  : resolve({
1253
1253
  ok: false,
1254
1254
  msg: '加购失败,请稍后重试',
1255
1255
  errMsg: getMessageJsonData?.data?.message ?? '',
1256
1256
  });
1257
1257
  if (!isOk) {
1258
1258
  const data = {
1259
1259
  eventName: 'business',
1260
1260
  errorName: 'shop_batchAddCart_error',
1261
1261
  errorMessage: 'H5调用Harmony原生加车失败',
1262
1262
  };
1263
1263
  draBusinessCustomReport(data);
1264
1264
  }
1265
1265
  } else {
1266
1266
  resolve({
1267
1267
  ok: false,
1268
1268
  msg: '加购失败,请稍后重试',
1269
1269
  });
1270
1270
  const data = {
1271
1271
  eventName: 'business',
1272
1272
  errorName: 'shop_batchAddCart_error',
1273
1273
  errorMessage: 'H5调用未知原生加车失败',
1274
1274
  };
1275
1275
  draBusinessCustomReport(data);
1276
1276
  }
1277
1277
  } catch (e) {
1278
1278
  resolve({
1279
1279
  ok: false,
1280
1280
  msg: '加购失败,请稍后重试',
1281
1281
  });
1282
1282
  console.warn('批量加车转换数据异常', e);
1283
1283
  const data = {
1284
1284
  eventName: 'business',
1285
1285
  errorName: 'shop_batchAddCart_error',
1286
1286
  errorMessage: '批量加车转换数据异常',
1287
1287
  };
1288
1288
  draBusinessCustomReport(data);
1289
1289
  }
1290
1290
  window[nativeAddCartCallBack] = null;
1291
1291
  };
1292
1292
  }
1293
1293
  const productsAddCartList = productIdsArr.map((skuItem) => {
1294
1294
  const adInfos = getAdInfoBySkuId(skuItem);
1295
1295
  let allExtFlag = typeof extFlag === 'object' ? extFlag : {};
1296
1296
  if (adInfos) {
1297
1297
  allExtFlag = Object.assign({}, allExtFlag, { adInfos });
1298
1298
  }
1299
1299
  let item: any = null;
1300
1300
  if (isAndroidDevice) {
1301
1301
  item = {
1302
1302
  sku: skuItem,
1303
1303
  num: addCardNum,
1304
1304
  extFlag: allExtFlag,
1305
1305
  };
1306
1306
  } else if (isIosDevice) {
1307
1307
  item = {
1308
1308
  productCode: skuItem,
1309
1309
  buyCount: addCardNum,
1310
1310
  extFlag: allExtFlag,
1311
1311
  };
1312
1312
  } else if (isHarmonyDevice) {
1313
1313
  item = {
1314
1314
  sourceType: 'native',
1315
1315
  sourceValue: 'shop',
1316
1316
  productCode: skuItem,
1317
1317
  buyCount: addCardNum,
1318
1318
  extFlag: allExtFlag,
1319
1319
  };
1320
1320
  }
1321
1321
  return item;
1322
1322
  });
1323
1323
  if (isAndroidDevice) {
1324
1324
  const androidProductsStr = JSON.stringify(productsAddCartList);
1325
1325
  let routerURL = `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`;
1326
1326
  if (extQuery) {
1327
1327
  routerURL += `&${extQuery}`;
1328
1328
  }
1329
1329
  callRouterAndroid({
1330
1330
  routerURL,
1331
1331
  routerParam: {
1332
1332
  wareList: productsAddCartList,
1333
1333
  },
1334
1334
  callBackName: nativeAddCartCallBack,
1335
1335
  });
1336
1336
  } else if (isIosDevice) {
1337
1337
  if (isLowAppVer) {
1338
1338
  const lowVersionAppList = productIdsArr.map((skuItem) => {
1339
1339
  return {
1340
1340
  sku: skuItem,
1341
1341
  num: addCardNum,
1342
1342
  };
1343
1343
  });
1344
1344
  const lowVersionAppListStr = JSON.stringify(lowVersionAppList);
1345
1345
  const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`;
1346
1346
  jump.side.jdJumpToWeb(url, {});
1347
1347
  resolve({
1348
1348
  ok: true,
1349
1349
  isOpenApp: true,
1350
1350
  msg: '加购完成, 加购结果请点击购物车确认',
1351
1351
  });
1352
1352
  } else {
1353
1353
  callRouterIOS({
1354
1354
  routerURL: 'router://JDCartModule/batchAddService',
1355
1355
  routerParam: {
1356
1356
  sourceType: 'h5',
1357
1357
  sourceValue: '店铺批量加购',
1358
1358
  businessName: 'storeModel',
1359
1359
  isNewMode: '1',
1360
1360
  NotPassWebview: '1',
1361
1361
  products: productsAddCartList,
1362
1362
  },
1363
1363
  callBackName: nativeAddCartCallBack,
1364
1364
  });
1365
1365
  }
1366
1366
  } else if (isHarmonyDevice) {
1367
1367
  callRouterHarmony({
1368
1368
  routerURL: 'router://JDCartModule/batchAddService',
1369
1369
  routerParam: {
1370
1370
  sourceType: 'native',
1371
1371
  sourceValue: 'shop',
1372
1372
  products: productsAddCartList,
1373
1373
  },
1374
1374
  callBackName: nativeAddCartCallBack,
1375
1375
  });
1376
1376
  }
1377
1377
  } else if (isMin) {
1378
1378
  console.log('==========>', '京购批量加车!');
1379
1379
  const productsAddCartList = productIdsArr.map((skuItem) => {
1380
1380
  return {
1381
1381
  skuId: skuItem,
1382
1382
  buyNum: addCardNum,
1383
1383
  };
1384
1384
  });
1385
1385
  global.wxAppBizInstance
1386
1386
  .addCart({ commArr: productsAddCartList })
1387
1387
  .then((res) => {
1388
1388
  console.log('dealCartSuccess: ', res);
1389
1389
  resolve({
1390
1390
  ok: true,
1391
1391
  msg: '已加入购物车!',
1392
1392
  data: res,
1393
1393
  });
1394
1394
  })
1395
1395
  .catch((e) => {
1396
1396
  console.log('京购小程序批量加车失败dealCartFail: ', e);
1397
1397
  resolve({
1398
1398
  ok: false,
1399
1399
  msg: '加购失败,请稍后重试',
1400
1400
  });
1401
1401
  const data = {
1402
1402
  eventName: 'business',
1403
1403
  errorName: 'shop_batchAddCart_error',
1404
1404
  errorMessage: 'H5调用小程序加车失败',
1405
1405
  };
1406
1406
  draBusinessCustomReport(data);
1407
1407
  });
1408
1408
  } else {
1409
1409
  console.log('==========>', '使用M站批量加车!');
1410
1410
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
1411
1411
  }
1412
1412
  } else {
1413
1413
  resolve({
1414
1414
  ok: false,
1415
1415
  msg: '加购sku不能为空',
1416
1416
  });
1417
1417
  const data = {
1418
1418
  eventName: 'business',
1419
1419
  errorName: 'shop_batchAddCart_error',
1420
1420
  errorMessage: '加购sku不能为空',
1421
1421
  };
1422
1422
  draBusinessCustomReport(data);
1423
1423
  }
1424
1424
  });
1425
1425
  }
1426
1426
 
1427
1427
  productAddToCart(skuIdsStr, num) {
1428
1428
  return new Promise((resolve) => {
1429
1429
  if (window.AddcartToolObj) {
1430
1430
  window.AddcartToolObj.addCart({
1431
1431
  skuId: skuIdsStr,
1432
1432
  num,
1433
1433
  source: 'sjdpyw',
1434
1434
  actId: '1',
1435
1435
  loginType: isAscfApp ? '2' : window?.isJingGouMiniViewState ? '11' : isPc ? '3' : '2',
1436
1436
  sucFun(res) {
1437
1437
  console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
1438
1438
  if (res.errId === '0' && res.cartJson) {
1439
1439
  resolve({
1440
1440
  ok: true,
1441
1441
  msg: '已加入购物车!',
1442
1442
  ...res,
1443
1443
  });
1444
1444
  } else {
1445
1445
  if (res.errId === '13') {
1446
1446
  global.doLogin();
1447
1447
  } else {
1448
1448
  resolve({
1449
1449
  ok: false,
1450
1450
  msg: '加购失败,请稍后重试',
1451
1451
  ...res,
1452
1452
  });
1453
1453
  const data = {
1454
1454
  eventName: 'business',
1455
1455
  errorName: 'shop_batchAddCart_error',
1456
1456
  errorMessage: 'H5调用M站加车失败',
1457
1457
  };
1458
1458
  draBusinessCustomReport(data);
1459
1459
  }
1460
1460
  }
1461
1461
  },
1462
1462
  failFun(err) {
1463
1463
  console.log('fail', err);
1464
1464
  resolve({
1465
1465
  ok: false,
1466
1466
  msg: '加购失败,请稍后重试',
1467
1467
  ...err,
1468
1468
  });
1469
1469
  const data = {
1470
1470
  eventName: 'business',
1471
1471
  errorName: 'shop_batchAddCart_error',
1472
1472
  errorMessage: 'H5调用M站加车失败',
1473
1473
  };
1474
1474
  draBusinessCustomReport(data);
1475
1475
  },
1476
1476
  });
1477
1477
  } else {
1478
1478
  resolve({
1479
1479
  ok: false,
1480
1480
  msg: '购物车方法检查异常',
1481
1481
  });
1482
1482
  const data = {
1483
1483
  eventName: 'business',
1484
1484
  errorName: 'shop_batchAddCart_error',
1485
1485
  errorMessage: 'H5调用M站加车检查依赖方法异常',
1486
1486
  };
1487
1487
  draBusinessCustomReport(data);
1488
1488
  }
1489
1489
  });
1490
1490
  }
1491
1491
  bMallGetUserInfo = () => {
1492
1492
  return getBMallUserInfo();
1493
1493
  };
1494
1494
  async bMallAddCart(params = {}) {
1495
1495
  return await this.gatewayReq('bmall_cartAdd', params, {
1496
1496
  client: 'H5',
1497
1497
  clientVersion: '5.5.0',
1498
1498
  });
1499
1499
  }
1500
1500
  async bMallChangeCart(params = {}) {
1501
1501
  return await this.gatewayReq('bmall_cartChange', params, {
1502
1502
  client: 'H5',
1503
1503
  clientVersion: '5.5.0',
1504
1504
  });
1505
1505
  }
1506
1506
  async bMallRemoveCart(params = {}) {
1507
1507
  return await this.gatewayReq(
1508
1508
  'bmall_cartRemove',
1509
1509
  params,
1510
1510
  {
1511
1511
  client: 'H5',
1512
1512
  clientVersion: '5.5.0',
1513
1513
  },
1514
1514
  );
1515
1515
  }
1516
1516
  async bMallGetOmittedProduct(params = {}) {
1517
1517
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
1518
1518
  client: 'H5',
1519
1519
  clientVersion: '5.5.0',
1520
1520
  });
1521
1521
  }
1522
1522
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
1523
1523
  const params = await getParams({ ...data, skuId, bMallTag, num });
1524
1524
  return await this.bMallAddCart(params);
1525
1525
  }
1526
1526
  async bMallGetSkuNumService(bMallTag = 1) {
1527
1527
  const params = await getParams({ bMallTag });
1528
1528
  delete params.operations;
1529
1529
  return await this.bMallGetOmittedProduct(params);
1530
1530
  }
1531
1531
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
1532
1532
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
1533
1533
  return await this.bMallRemoveCart(params);
1534
1534
  }
1535
1535
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
1536
1536
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
1537
1537
  return await this.bMallChangeCart(params);
1538
1538
  }
1539
1539
 
1540
1540
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
1541
1541
  if (!needRequest && isH5 && window?.bMallCartData) {
1542
1542
  return window?.bMallCartData;
1543
1543
  }
1544
1544
  const cartData = await this.bMallGetSkuNumService(bMallTag);
1545
1545
  let items;
1546
1546
  if (cartData.ok && cartData.result) {
1547
1547
  items = cartData?.result?.items || {};
1548
1548
  }
1549
1549
  if (isH5) {
1550
1550
  window.bMallCartData = items;
1551
1551
  }
1552
1552
  return items;
1553
1553
  }
1554
1554
 
1555
1555
  async bMallCartHandle(goodItem, num) {
1556
1556
  try {
1557
1557
  const {
1558
1558
  skuUuid,
1559
1559
  limitUpper,
1560
1560
  limitLower,
1561
1561
  } = goodItem;
1562
1562
  let cartNum = Number(num);
1563
1563
  if (limitLower && cartNum && cartNum < limitLower) {
1564
1564
  cartNum = limitLower;
1565
1565
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
1566
1566
  cartNum = limitUpper;
1567
1567
  }
1568
1568
  if (skuUuid && cartNum > 0) {
1569
1569
  return this.bMallChangeCartService({
1570
1570
  ...goodItem,
1571
1571
  skuUuid,
1572
1572
  num: cartNum,
1573
1573
  });
1574
1574
  } else if (!skuUuid && cartNum > 0) {
1575
1575
  return this.bMallAddCartService({ ...goodItem, num: cartNum });
1576
1576
  } else if (skuUuid && !cartNum) {
1577
1577
  return this.bMallRemoveCartService({
1578
1578
  ...goodItem,
1579
1579
  skuUuid,
1580
1580
  num: cartNum,
1581
1581
  });
1582
1582
  } else {
1583
1583
  console.error('参数不全');
1584
1584
  return false;
1585
1585
  }
1586
1586
  } catch (e) {
1587
1587
  console.error(e);
1588
1588
  }
1589
1589
  }