@conecli/cone-render 0.10.1-shop3.2 → 0.10.1-shop3.4

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 (32) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  5. package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
  6. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  7. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  8. package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
  9. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  10. package/dist/interface/jumpEventReport.ts +1 -1
  11. package/dist/interface/service.ts +1 -1
  12. package/dist/jumpEventReport/base.ts +1 -1
  13. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  14. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  15. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  16. package/dist/jumpEventReport/web/report.ts +1 -1
  17. package/dist/jumpEventReport/web.base.ts +1 -1
  18. package/dist/jumpEventReport/web.jd.ts +1 -1
  19. package/dist/modules/ContainerFloorList/index.h5.module.scss +3 -0
  20. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  21. package/dist/open/api/util.ts +1 -1
  22. package/dist/service/http/colorSign.ts +1 -1
  23. package/dist/service/http/const.ts +1 -1
  24. package/dist/service/requestServer.h5.ts +1 -1
  25. package/dist/utils/connectNativeJsBridge.ts +1 -1
  26. package/dist/utils/h5Utils.ts +1 -1
  27. package/dist/utils/index.h5.ts +1 -1
  28. package/dist/utils/index.ts +1 -1
  29. package/dist/utils/index.weapp.ts +1 -1
  30. package/dist/utils/sColor.js +1 -0
  31. package/dist/utils/utils.ts +1 -1
  32. package/package.json +1 -1
@@ -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
  isJdApp,
13
12
  isIosDevice,
14
13
  isAndroidDevice,
15
14
  showSuccessToast,
16
15
  showFailToast,
17
16
  isH5,
18
17
  isWxMinAndWxapp,
19
18
  isMin,
20
19
  isPc,
21
20
  sgmCustomReport,
22
21
  getSgmCustomCode,
23
22
  draInterfaceCustomReport,
24
23
  callRouterIOS,
25
24
  callRouterAndroid,
26
25
  cookiesStr: '',
27
26
  requestHeaderContentType: {
28
27
  jsonHeader: {
29
28
  'content-type': 'application/json;charset=utf-8',
30
29
  },
31
30
  formDataHeader: {
32
31
  'content-type': 'application/x-www-form-urlencoded',
33
32
  },
34
33
  },
35
34
  requestBaseParam: {
36
35
  data: null,
37
36
  header: {
38
37
  'content-type': 'application/json;charset=utf-8',
39
38
  },
40
39
  },
41
40
  timeOut: 7000,
42
41
  apiClientParams: {
43
42
  clientVersion:
44
43
  isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
45
44
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
46
45
  area: '1_72_2799_0',
47
46
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
48
47
  window.screen?.height * devicePixelRatio,
49
48
  )}`,
50
49
  uuid: UUID,
51
50
  },
52
51
  public addressFetchInfo: {
53
52
  reqState: boolean
54
53
  promiseInstance: null | Promise<any>
55
54
  }
56
55
  public getPromotionConfig: {
57
56
  projectId: null | string | number
58
57
  pageId: null | string | number
59
58
  }
60
59
  public resInfo: ServiceInterFace.HttpRequestInfo
61
60
  public api: ServiceInterFace.HttpApi
62
61
  public isPageDomain: boolean
63
62
  public verifyColorList: string[]
64
63
  constructor(opt) {
65
64
  this._init()
66
65
  this.addressFetchInfo = {
67
66
  reqState: false,
68
67
  promiseInstance: null,
69
68
  }
70
69
  this.getPromotionConfig = {
71
70
  projectId: null,
72
71
  pageId: null,
73
72
  }
74
73
  this._userAreaUpdateListen()
75
74
  this.resInfo = this._getResConfig(opt)
76
75
  this.api = api
77
76
  this.isPageDomain = isH5
78
77
  ? window?.location?.hostname === PAGES_DOMAIN
79
78
  : false
80
79
  this.verifyColorList = [
81
80
  ...MobileVerifyColorList,
82
81
  ...AppVerifyColorList,
83
82
  ...JshopxVerifyColorList,
84
83
  ...BMallVerifyColorList,
85
84
  ]
86
85
  }
87
86
  _init(): void {
88
87
  httpInterceptors.forEach((item) => {
89
88
  Taro.addInterceptor((chain) => item(chain))
90
89
  })
91
90
  }
92
91
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
93
92
  return Object.assign({}, DefaultConfig, opt)
94
93
  }
95
94
 
96
95
  _userAreaUpdateListen() {
97
96
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
98
97
  area && area !== "" && this.updateApiClientParamsResInfo({
99
98
  area,
100
99
  })
101
100
  console.log("cone-render收到原生端获取传来的四级地址信息",area,"更新后的接口底层信息", this.resInfo.apiClientParams)
102
101
  })
103
102
  }
104
103
  updateApiClientParamsResInfo(opt = {}) {
105
104
  const { area, ...others} = opt
106
105
  this.resInfo.apiClientParams = {
107
106
  ...this.resInfo.apiClientParams,
108
107
  ...others
109
108
  }
110
109
  if(area){
111
110
  this.resInfo.apiClientParams.area = area
112
111
  }
113
112
  }
114
113
 
115
114
  checkFunctionIdToReturnAppId(functionId) {
116
115
  if (JshopxColorFunctionIdList.includes(functionId)) {
117
116
  return APPID.JSHOPX_COLOR_APPID
118
117
  } else if (
119
118
  this.isPageDomain &&
120
119
  PagesColorFunctionIdList.includes(functionId)
121
120
  ) {
122
121
  return APPID.PAGES_COLOR_APPID
123
122
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
124
123
  return APPID.SHOP_MEMBER_COLOR_APPID
125
124
  } else if (B2BColorFunctionIdList.includes(functionId)) {
126
125
  return APPID.B2B_COLOR_APPID
127
126
  } else if (isPc) {
128
127
  return APPID.MALL_COLOR_APPID
129
128
  } else {
130
129
  return APPID.SHOP_COLOR_APPID
131
130
  }
132
131
  }
133
132
 
134
133
  gatewayReq(
135
134
  functionId: string,
136
135
  bodyParams = {},
137
136
  clientParams = {},
138
137
  ): Promise<any> {
139
138
  if (
140
139
  functionId === 'receiveShopCoupon' &&
141
140
  ((isH5 &&
142
141
  (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
143
142
  isWxMinAndWxapp)
144
143
  ) {
145
144
  clientParams = Object.assign(
146
145
  {},
147
146
  {
148
147
  loginType: '1',
149
148
  loginWQBiz: WXAPP_BIZ_KEY,
150
149
  },
151
150
  clientParams,
152
151
  )
153
152
  }
154
153
  const apiClientParams = Object.assign(
155
154
  {},
156
155
  this.resInfo.apiClientParams,
157
156
  clientParams,
158
157
  )
159
158
  typeof apiClientParams.appid === 'undefined' &&
160
159
  (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
161
160
  const isColorVerify = this.verifyColorList.includes(functionId)
162
161
  const getReqData = {
163
162
  functionId: functionId,
164
163
  body: JSON.stringify(bodyParams),
165
164
  t: Date.now(),
166
165
  ...apiClientParams,
167
166
  }
168
167
  return http
169
168
  .request({
170
169
  url: this.api.apiFunc,
171
170
  data: getReqData,
172
171
  isColorVerify,
173
172
  })
174
173
  .then((res: ServiceInterFace.RequestPromiseRes) => {
175
174
  const { statusCode, data, status, msg } = res
176
175
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
177
176
  ok: true,
178
177
  }
179
178
  if ((statusCode === 200 || status === '0') && data) {
180
179
  changeRes = this.dealResponseFormatRes(data)
181
180
  return changeRes
182
181
  } else {
183
182
  changeRes = {
184
183
  ...data,
185
184
  statusCode,
186
185
  status,
187
186
  msg,
188
187
  ok: false,
189
188
  }
190
189
  return changeRes
191
190
  }
192
191
  })
193
192
  .catch((res) => {
194
193
  const propertyNames = Object.getOwnPropertyNames(res);
195
194
  const resObject = {};
196
195
  propertyNames.forEach((propertyName) => {
197
196
  resObject[propertyName] = res[propertyName];
198
197
  });
199
198
  draInterfaceCustomReport({
200
199
  subMsg:
201
200
  '接口请求异常,进入catch逻辑,例如h5请求神盾(反爬、小号、风控)或加固拦截返回status为403等',
202
201
  url: this.api.apiFunc,
203
202
  source: 'remote',
204
203
  requestType: res?.requestType,
205
204
  errorType: 'catchError',
206
205
  functionId: getReqData?.functionId,
207
206
  appid: getReqData?.appid,
208
207
  client: getReqData?.client,
209
208
  clientVersion: getReqData?.clientVersion,
210
209
  statusCode: res?.statusCode,
211
210
  status: res?.status,
212
211
  statusText: res?.statusText,
213
212
  code: res?.data?.code || res?.data?.subCode,
214
213
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
215
214
  originReqDataStr: JSON.stringify(getReqData),
216
215
  originResDataStr: JSON.stringify(res, propertyNames),
217
216
  });
218
217
  return {
219
218
  ...resObject,
220
219
  ok: false,
221
220
  } as ServiceInterFace.RequestResponseFormatRes;
222
221
  })
223
222
  }
224
223
 
225
224
  dealResponseFormatRes(data) {
226
225
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
227
226
  ok: true,
228
227
  }
229
228
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
230
229
  ? Number(data.code)
231
230
  : -1
232
231
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
233
232
  ? Number(data.subCode)
234
233
  : -1
235
234
  if (
236
235
  data.success === true ||
237
236
  data.isSuccess ||
238
237
  resCode === 0 ||
239
238
  resCode === 200 ||
240
239
  subCode === 0
241
240
  ) {
242
241
  changeRes = {
243
242
  result: Object.prototype.hasOwnProperty.call(data, 'result')
244
243
  ? data.result
245
244
  : Object.prototype.hasOwnProperty.call(data, 'data')
246
245
  ? data.data
247
246
  : data,
248
247
  code: data.code ?? 200,
249
248
  ok: true,
250
249
  source: data,
251
250
  }
252
251
  return changeRes
253
252
  } else {
254
253
  changeRes = {
255
254
  ...data,
256
255
  ok: false,
257
256
  }
258
257
  return changeRes
259
258
  }
260
259
  }
261
260
 
262
261
  async receiveCoupon(param = {}, clientParams) {
263
262
  const loginType = isPc ? { loginType: 3 } : {}
264
263
  return await this.gatewayReq(
265
264
  'receiveShopCoupon',
266
265
  {
267
266
  operation: '3',
268
267
  ...param,
269
268
  },
270
269
  { ...loginType, ...clientParams },
271
270
  )
272
271
  }
273
272
 
274
273
  getCustomerCenterDispatch(params = {}) {
275
274
  return this.gatewayReq('customerCenterDispatch', params, {
276
275
  clientVersion: '9.2.0',
277
276
  client: 'H5',
278
277
  uuid: 88888,
279
278
  appid: 'shopmember_m_jd_com',
280
279
  })
281
280
  }
282
281
 
283
282
  batchAddCart(skuIdsStr, num = 1, showToast = true) {
284
283
  if (skuIdsStr) {
285
284
  return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
286
285
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
287
286
  if (res?.ok) {
288
287
  if (showToast && !res?.isOpenApp)
289
288
  showSuccessToast({
290
289
  title: '加入购物车成功',
291
290
  })
292
291
  } else {
293
292
  showToast &&
294
293
  showFailToast({
295
294
  title: res?.errMsg || '加入购物车失败,请稍后重试!',
296
295
  })
297
296
  }
298
297
  return Promise.resolve(res)
299
298
  })
300
299
  .catch((e) => {
301
300
  console.log('调用加购方法异常=======>', e)
302
301
  return Promise.resolve({
303
302
  ok: false,
304
303
  msg: '加入购物车失败,请稍后重试!',
305
304
  })
306
305
  })
307
306
  } else {
308
307
  return Promise.resolve({
309
308
  ok: false,
310
309
  msg: '加入购物车失败,请稍后重试!',
311
310
  })
312
311
  }
313
312
  }
314
313
 
315
314
  _addShopGoodCart(skuIdsStr, addCardNum = '1') {
316
315
  return new Promise((resolve) => {
317
316
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
318
317
  if (productIdsArr.length > 0) {
319
318
  if (isJdApp) {
320
319
  console.log('==========>', '原生批量加车!')
321
320
  const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
322
321
  if (!window[nativeAddCartCallBack]) {
323
322
  window[nativeAddCartCallBack] = (res) => {
324
323
  const getMessageJsonData =
325
324
  typeof res === 'string' ? JSON.parse(res) : res
326
325
  console.info(
327
326
  '获取批量加车原始数据',
328
327
  res,
329
328
  '====转换后的json数据为===',
330
329
  getMessageJsonData,
331
330
  )
332
331
  try {
333
332
  if (isAndroidDevice) {
334
333
  getMessageJsonData?.status === '0'
335
334
  ? resolve({
336
335
  ok: true,
337
336
  msg: '已加入购物车!',
338
337
  })
339
338
  : resolve({
340
339
  ok: false,
341
340
  msg: '加购失败,请稍后重试',
342
341
  })
343
342
  } else if (isIosDevice) {
344
343
  getMessageJsonData?.status === '0' &&
345
344
  getMessageJsonData?.data?.code === 0
346
345
  ? resolve({
347
346
  ok: true,
348
347
  msg: '已加入购物车!',
349
348
  })
350
349
  : resolve({
351
350
  ok: false,
352
351
  msg: '批量加车失败,请稍后重试',
353
352
  })
354
353
  } else {
355
354
  resolve({
356
355
  ok: false,
357
356
  msg: '加购失败,请稍后重试',
358
357
  })
359
358
  }
360
359
  } catch (e) {
361
360
  resolve({
362
361
  ok: false,
363
362
  msg: '加购失败,请稍后重试',
364
363
  })
365
364
  console.warn('批量加车转换数据异常', e)
366
365
  }
367
366
  window[nativeAddCartCallBack] = null
368
367
  }
369
368
  }
370
369
  const productsAddCartList = productIdsArr.map((skuItem) => {
371
370
  return isAndroidDevice
372
371
  ? {
373
372
  sku: skuItem,
374
373
  num: addCardNum,
375
374
  }
376
375
  : {
377
376
  productCode: skuItem,
378
377
  buyCount: addCardNum,
379
378
  }
380
379
  })
381
380
  if (isAndroidDevice) {
382
381
  const androidProductsStr = JSON.stringify(productsAddCartList)
383
382
  callRouterAndroid({
384
383
  routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
385
384
  routerParam: {
386
385
  wareList: productsAddCartList,
387
386
  },
388
387
  callBackName: nativeAddCartCallBack,
389
388
  })
390
389
  } else if (isIosDevice) {
391
390
  if (isLowAppVer) {
392
391
  const lowVersionAppList = productIdsArr.map((skuItem) => {
393
392
  return {
394
393
  sku: skuItem,
395
394
  num: addCardNum,
396
395
  }
397
396
  })
398
397
  const lowVersionAppListStr = JSON.stringify(lowVersionAppList)
399
398
  const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`
400
399
  jump.side.jdJumpToWeb(url, {})
401
400
  resolve({
402
401
  ok: true,
403
402
  isOpenApp: true,
404
403
  msg: '加购完成, 加购结果请点击购物车确认',
405
404
  })
406
405
  } else {
407
406
  callRouterIOS({
408
407
  routerURL: 'router://JDCartModule/batchAddService',
409
408
  routerParam: {
410
409
  sourceType: 'h5',
411
410
  sourceValue: '店铺批量加购',
412
411
  businessName: 'storeModel',
413
412
  isNewMode: '1',
414
413
  NotPassWebview: '1',
415
414
  products: productsAddCartList,
416
415
  },
417
416
  callBackName: nativeAddCartCallBack,
418
417
  })
419
418
  }
420
419
  }
421
420
  } else if (isMin) {
422
421
  console.log('==========>', '京购批量加车!')
423
422
  const productsAddCartList = productIdsArr.map((skuItem) => {
424
423
  return {
425
424
  skuId: skuItem,
426
425
  buyNum: addCardNum,
427
426
  }
428
427
  })
429
428
  global.wxAppBizInstance
430
429
  .addCart({ commArr: productsAddCartList })
431
430
  .then((res) => {
432
431
  console.log('dealCartSuccess: ', res)
433
432
  resolve({
434
433
  ok: true,
435
434
  msg: '已加入购物车!',
436
435
  data: res,
437
436
  })
438
437
  })
439
438
  .catch((e) => {
440
439
  console.log('京购小程序批量加车失败dealCartFail: ', e)
441
440
  resolve({
442
441
  ok: false,
443
442
  msg: '加购失败,请稍后重试',
444
443
  })
445
444
  })
446
445
  } else {
447
446
  console.log('==========>', 'M站批量加车!')
448
447
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
449
448
  resolve(res),
450
449
  )
451
450
  }
452
451
  } else {
453
452
  resolve({
454
453
  ok: false,
455
454
  msg: '加购sku不能为空',
456
455
  })
457
456
  }
458
457
  })
459
458
  }
460
459
 
461
460
  productAddToCart(skuIdsStr, num) {
462
461
  return new Promise((resolve) => {
463
462
  if (window.AddcartToolObj) {
464
463
  window.AddcartToolObj.addCart({
465
464
  skuId: skuIdsStr,
466
465
  num,
467
466
  source: 'sjdpyw',
468
467
  actId: '1',
469
468
  loginType: window?.isJingGouMiniViewState ? '11' : '2',
470
469
  sucFun(res) {
471
470
  console.log(
472
471
  'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
473
472
  res,
474
473
  )
475
474
  if (res.errId === '0' && res.cartJson) {
476
475
  resolve({
477
476
  ok: true,
478
477
  msg: '已加入购物车!',
479
478
  ...res,
480
479
  })
481
480
  } else {
482
481
  if (res.errId === '13') {
483
482
  global.doLogin()
484
483
  } else {
485
484
  resolve({
486
485
  ok: false,
487
486
  msg: '加购失败,请稍后重试',
488
487
  ...res,
489
488
  })
490
489
  }
491
490
  }
492
491
  },
493
492
  failFun(err) {
494
493
  console.log('fail', err)
495
494
  resolve({
496
495
  ok: false,
497
496
  msg: '加购失败,请稍后重试',
498
497
  ...err,
499
498
  })
500
499
  },
501
500
  })
502
501
  } else {
503
502
  resolve({
504
503
  ok: false,
505
504
  msg: '购物车方法检查异常',
506
505
  })
507
506
  }
508
507
  })
509
508
  }
510
509
  bMallGetUserInfo = () => {
511
510
  return getBMallUserInfo()
512
511
  }
513
512
  async bMallAddCart(params = {}) {
514
513
  return await this.gatewayReq('bmall_cartAdd', params, {
515
514
  client: 'H5',
516
515
  clientVersion: '5.5.0',
517
516
  })
518
517
  }
519
518
  async bMallChangeCart(params = {}) {
520
519
  return await this.gatewayReq('bmall_cartChange', params, {
521
520
  client: 'H5',
522
521
  clientVersion: '5.5.0',
523
522
  })
524
523
  }
525
524
  async bMallRemoveCart(params = {}) {
526
525
  return await this.gatewayReq(
527
526
  'bmall_cartRemove',
528
527
  params,
529
528
  {
530
529
  client: 'H5',
531
530
  clientVersion: '5.5.0',
532
531
  },
533
532
  )
534
533
  }
535
534
  async bMallGetOmittedProduct(params = {}) {
536
535
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
537
536
  client: 'H5',
538
537
  clientVersion: '5.5.0',
539
538
  })
540
539
  }
541
540
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
542
541
  const params = await getParams({ ...data, skuId, bMallTag, num })
543
542
  return await this.bMallAddCart(params)
544
543
  }
545
544
  async bMallGetSkuNumService(bMallTag = 1) {
546
545
  const params = await getParams({ bMallTag })
547
546
  delete params.operations
548
547
  return await this.bMallGetOmittedProduct(params)
549
548
  }
550
549
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
551
550
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
552
551
  return await this.bMallRemoveCart(params)
553
552
  }
554
553
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
555
554
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
556
555
  return await this.bMallChangeCart(params)
557
556
  }
558
557
 
559
558
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
560
559
  if (!needRequest && isH5 && window?.bMallCartData) {
561
560
  return window?.bMallCartData
562
561
  }
563
562
  const cartData = await this.bMallGetSkuNumService(bMallTag)
564
563
  let items
565
564
  if (cartData.ok && cartData.result) {
566
565
  items = cartData?.result?.items || {}
567
566
  }
568
567
  if (isH5) {
569
568
  window.bMallCartData = items
570
569
  }
571
570
  return items
572
571
  }
573
572
 
574
573
  async bMallCartHandle(goodItem, num) {
575
574
  try {
576
575
  const {
577
576
  skuUuid,
578
577
  limitUpper,
579
578
  limitLower,
580
579
  } = goodItem
581
580
  let cartNum = Number(num)
582
581
  if (limitLower && cartNum && cartNum < limitLower) {
583
582
  cartNum = limitLower
584
583
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
585
584
  cartNum = limitUpper
586
585
  }
587
586
  if (skuUuid && cartNum > 0) {
588
587
  return this.bMallChangeCartService({
589
588
  ...goodItem,
590
589
  skuUuid,
591
590
  num: cartNum,
592
591
  })
593
592
  } else if (!skuUuid && cartNum > 0) {
594
593
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
595
594
  } else if (skuUuid && !cartNum) {
596
595
  return this.bMallRemoveCartService({
597
596
  ...goodItem,
598
597
  skuUuid,
599
598
  num: cartNum,
600
599
  })
601
600
  } else {
602
601
  console.error('参数不全')
603
602
  return false
604
603
  }
605
604
  } catch (e) {
606
605
  console.error(e)
607
606
  }
608
607
  }
608
+ import Taro from '@tarojs/taro';
609
609
  APPID,
610
610
  JshopxColorFunctionIdList,
611
611
  PagesColorFunctionIdList,
612
612
  PAGES_DOMAIN,
613
613
  B2BColorFunctionIdList,
614
614
  MobileVerifyColorList,
615
615
  AppVerifyColorList,
616
616
  JshopxVerifyColorList,
617
617
  BMallVerifyColorList,
618
618
  shopMemberColorFunctionIdList,
619
619
  isJdApp,
620
620
  isIosDevice,
621
621
  isAndroidDevice,
622
622
  isJdAndHarmonyDevice,
623
623
  showSuccessToast,
624
624
  showFailToast,
625
625
  isH5,
626
626
  isWxMinAndWxapp,
627
627
  isMin,
628
628
  isPc,
629
629
  draInterfaceCustomReport,
630
630
  callRouterIOS,
631
631
  callRouterAndroid,
632
632
  sendNativePageToShowCartFloatBtn,
633
633
  cookiesStr: '',
634
634
  requestHeaderContentType: {
635
635
  jsonHeader: {
636
636
  'content-type': 'application/json;charset=utf-8',
637
637
  },
638
638
  formDataHeader: {
639
639
  'content-type': 'application/x-www-form-urlencoded',
640
640
  },
641
641
  },
642
642
  requestBaseParam: {
643
643
  data: null,
644
644
  header: {
645
645
  'content-type': 'application/json;charset=utf-8',
646
646
  },
647
647
  },
648
648
  timeOut: 7000,
649
649
  apiClientParams: {
650
650
  clientVersion: isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
651
651
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
652
652
  area: '1_72_2799_0',
653
653
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
654
654
  window.screen?.height * devicePixelRatio,
655
655
  )}`,
656
656
  uuid: UUID,
657
657
  },
658
658
  public addressFetchInfo: {
659
659
  reqState: boolean;
660
660
  promiseInstance: null | Promise<any>;
661
661
  };
662
662
  public getPromotionConfig: {
663
663
  projectId: null | string | number;
664
664
  pageId: null | string | number;
665
665
  };
666
666
  public resInfo: ServiceInterFace.HttpRequestInfo;
667
667
  public api: ServiceInterFace.HttpApi;
668
668
  public isPageDomain: boolean;
669
669
  public verifyColorList: string[];
670
670
  private isShowJdShopCartFloatBtn: boolean;
671
671
  constructor(opt) {
672
672
  this._init();
673
673
  this.addressFetchInfo = {
674
674
  reqState: false,
675
675
  promiseInstance: null,
676
676
  };
677
677
  this.getPromotionConfig = {
678
678
  projectId: null,
679
679
  pageId: null,
680
680
  };
681
681
  this._userAreaUpdateListen();
682
682
  this.resInfo = this._getResConfig(opt);
683
683
  this.api = api;
684
684
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
685
685
  this.verifyColorList = [
686
686
  ...MobileVerifyColorList,
687
687
  ...AppVerifyColorList,
688
688
  ...JshopxVerifyColorList,
689
689
  ...BMallVerifyColorList,
690
690
  ];
691
691
  this.isShowJdShopCartFloatBtn =
692
692
  jdAppVersionCompare(isJdAndIosDevice ? '13.8.6' : '13.6.2') >= 0;
693
693
  }
694
694
  _init(): void {
695
695
  httpInterceptors.forEach((item) => {
696
696
  Taro.addInterceptor((chain) => item(chain));
697
697
  });
698
698
  }
699
699
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
700
700
  return Object.assign({}, DefaultConfig, opt);
701
701
  }
702
702
 
703
703
  _userAreaUpdateListen() {
704
704
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
705
705
  area &&
706
706
  area !== '' &&
707
707
  this.updateApiClientParamsResInfo({
708
708
  area,
709
709
  });
710
710
  console.log(
711
711
  'cone-render收到原生端获取传来的四级地址信息',
712
712
  area,
713
713
  '更新后的接口底层信息',
714
714
  this.resInfo.apiClientParams,
715
715
  );
716
716
  });
717
717
  }
718
718
  updateApiClientParamsResInfo(opt = {}) {
719
719
  const { area, ...others } = opt;
720
720
  this.resInfo.apiClientParams = {
721
721
  ...this.resInfo.apiClientParams,
722
722
  ...others,
723
723
  };
724
724
  if (area) {
725
725
  this.resInfo.apiClientParams.area = area;
726
726
  }
727
727
  }
728
728
 
729
729
  checkFunctionIdToReturnAppId(functionId) {
730
730
  if (JshopxColorFunctionIdList.includes(functionId)) {
731
731
  return APPID.JSHOPX_COLOR_APPID;
732
732
  } else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
733
733
  return APPID.PAGES_COLOR_APPID;
734
734
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
735
735
  return APPID.SHOP_MEMBER_COLOR_APPID;
736
736
  } else if (B2BColorFunctionIdList.includes(functionId)) {
737
737
  return APPID.B2B_COLOR_APPID;
738
738
  } else if (isPc) {
739
739
  return APPID.MALL_COLOR_APPID;
740
740
  } else {
741
741
  return APPID.SHOP_COLOR_APPID;
742
742
  }
743
743
  }
744
744
 
745
745
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
746
746
  if (
747
747
  functionId === 'receiveShopCoupon' &&
748
748
  ((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
749
749
  isWxMinAndWxapp)
750
750
  ) {
751
751
  clientParams = Object.assign(
752
752
  {},
753
753
  {
754
754
  loginType: '1',
755
755
  loginWQBiz: WXAPP_BIZ_KEY,
756
756
  },
757
757
  clientParams,
758
758
  );
759
759
  }
760
760
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
761
761
  typeof apiClientParams.appid === 'undefined' &&
762
762
  (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
763
763
  const isColorVerify = this.verifyColorList.includes(functionId);
764
764
  const getReqData = {
765
765
  functionId: functionId,
766
766
  body: JSON.stringify(bodyParams),
767
767
  t: Date.now(),
768
768
  ...apiClientParams,
769
769
  };
770
770
  return http
771
771
  .request({
772
772
  url: this.api.apiFunc,
773
773
  data: getReqData,
774
774
  isColorVerify,
775
775
  })
776
776
  .then((res: ServiceInterFace.RequestPromiseRes) => {
777
777
  const { statusCode, data, status, msg } = res;
778
778
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
779
779
  ok: true,
780
780
  };
781
781
  if ((statusCode === 200 || status === '0') && data) {
782
782
  changeRes = this.dealResponseFormatRes(data);
783
783
  return changeRes;
784
784
  } else {
785
785
  changeRes = {
786
786
  ...data,
787
787
  statusCode,
788
788
  status,
789
789
  msg,
790
790
  ok: false,
791
791
  };
792
792
  return changeRes;
793
793
  }
794
794
  })
795
795
  .catch((res) => {
796
796
  const propertyNames = Object.getOwnPropertyNames(res);
797
797
  const resObject = {};
798
798
  propertyNames.forEach((propertyName) => {
799
799
  resObject[propertyName] = res[propertyName];
800
800
  });
801
801
  draInterfaceCustomReport({
802
802
  subMsg:
803
803
  '接口请求异常,进入catch逻辑,例如h5请求神盾(反爬、小号、风控)或加固拦截返回status为403等',
804
804
  url: this.api.apiFunc,
805
805
  source: 'remote',
806
806
  requestType: res?.requestType,
807
807
  errorType: 'catchError',
808
808
  functionId: getReqData?.functionId,
809
809
  appid: getReqData?.appid,
810
810
  client: getReqData?.client,
811
811
  clientVersion: getReqData?.clientVersion,
812
812
  statusCode: res?.statusCode,
813
813
  status: res?.status,
814
814
  statusText: res?.statusText,
815
815
  code: res?.data?.code || res?.data?.subCode,
816
816
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
817
817
  originReqDataStr: JSON.stringify(getReqData),
818
818
  originResDataStr: JSON.stringify(res, propertyNames),
819
819
  });
820
820
  return {
821
821
  ...resObject,
822
822
  ok: false,
823
823
  } as ServiceInterFace.RequestResponseFormatRes;
824
824
  });
825
825
  }
826
826
 
827
827
  dealResponseFormatRes(data) {
828
828
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
829
829
  ok: true,
830
830
  };
831
831
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
832
832
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
833
833
  ? Number(data.subCode)
834
834
  : -1;
835
835
  if (
836
836
  data.success === true ||
837
837
  data.isSuccess ||
838
838
  resCode === 0 ||
839
839
  resCode === 200 ||
840
840
  subCode === 0
841
841
  ) {
842
842
  changeRes = {
843
843
  result: Object.prototype.hasOwnProperty.call(data, 'result')
844
844
  ? data.result
845
845
  : Object.prototype.hasOwnProperty.call(data, 'data')
846
846
  ? data.data
847
847
  : data,
848
848
  code: data.code ?? 200,
849
849
  ok: true,
850
850
  source: data,
851
851
  };
852
852
  return changeRes;
853
853
  } else {
854
854
  changeRes = {
855
855
  ...data,
856
856
  ok: false,
857
857
  };
858
858
  return changeRes;
859
859
  }
860
860
  }
861
861
 
862
862
  async receiveCoupon(param = {}, clientParams) {
863
863
  const loginType = isPc ? { loginType: 3 } : {};
864
864
  return await this.gatewayReq(
865
865
  'receiveShopCoupon',
866
866
  {
867
867
  operation: '3',
868
868
  ...param,
869
869
  },
870
870
  { ...loginType, ...clientParams },
871
871
  );
872
872
  }
873
873
 
874
874
  getCustomerCenterDispatch(params = {}) {
875
875
  return this.gatewayReq('customerCenterDispatch', params, {
876
876
  clientVersion: '9.2.0',
877
877
  client: 'H5',
878
878
  uuid: 88888,
879
879
  appid: 'shopmember_m_jd_com',
880
880
  });
881
881
  }
882
882
 
883
883
  batchAddCart(skuIdsStr, num = 1, showToast = true) {
884
884
  if (skuIdsStr) {
885
885
  return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
886
886
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
887
887
  if (res?.ok) {
888
888
  showToast &&
889
889
  !res?.isOpenApp &&
890
890
  showSuccessToast({
891
891
  title: '加入购物车成功',
892
892
  });
893
893
  this.isShowJdShopCartFloatBtn &&
894
894
  sendNativePageToShowCartFloatBtn({
895
895
  isShow: true,
896
896
  });
897
897
  } else {
898
898
  showToast &&
899
899
  showFailToast({
900
900
  title: res?.errMsg || '加入购物车失败,请稍后重试!',
901
901
  });
902
902
  }
903
903
  return Promise.resolve(res);
904
904
  })
905
905
  .catch((e) => {
906
906
  console.log('调用加购方法异常=======>', e);
907
907
  return Promise.resolve({
908
908
  ok: false,
909
909
  msg: '加入购物车失败,请稍后重试!',
910
910
  });
911
911
  });
912
912
  } else {
913
913
  return Promise.resolve({
914
914
  ok: false,
915
915
  msg: '加入购物车失败,请稍后重试!',
916
916
  });
917
917
  }
918
918
  }
919
919
 
920
920
  _addShopGoodCart(skuIdsStr, addCardNum = '1') {
921
921
  return new Promise((resolve) => {
922
922
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
923
923
  if (productIdsArr.length > 0) {
924
924
  if (isJdApp && !isJdAndHarmonyDevice) {
925
925
  console.log('==========>', '原生批量加车!');
926
926
  const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`;
927
927
  if (!window[nativeAddCartCallBack]) {
928
928
  window[nativeAddCartCallBack] = (res) => {
929
929
  const getMessageJsonData = typeof res === 'string' ? JSON.parse(res) : res;
930
930
  console.info(
931
931
  '获取批量加车原始数据',
932
932
  res,
933
933
  '====转换后的json数据为===',
934
934
  getMessageJsonData,
935
935
  );
936
936
  try {
937
937
  if (isAndroidDevice) {
938
938
  getMessageJsonData?.status === '0'
939
939
  ? resolve({
940
940
  ok: true,
941
941
  msg: '已加入购物车!',
942
942
  })
943
943
  : resolve({
944
944
  ok: false,
945
945
  msg: '加购失败,请稍后重试',
946
946
  errMsg: getMessageJsonData?.data?.message ?? '',
947
947
  });
948
948
  } else if (isIosDevice) {
949
949
  getMessageJsonData?.status === '0' && getMessageJsonData?.data?.code === 0
950
950
  ? resolve({
951
951
  ok: true,
952
952
  msg: '已加入购物车!',
953
953
  })
954
954
  : resolve({
955
955
  ok: false,
956
956
  msg: '批量加车失败,请稍后重试',
957
957
  errMsg: getMessageJsonData?.data?.message ?? '',
958
958
  });
959
959
  } else {
960
960
  resolve({
961
961
  ok: false,
962
962
  msg: '加购失败,请稍后重试',
963
963
  });
964
964
  }
965
965
  } catch (e) {
966
966
  resolve({
967
967
  ok: false,
968
968
  msg: '加购失败,请稍后重试',
969
969
  });
970
970
  console.warn('批量加车转换数据异常', e);
971
971
  }
972
972
  window[nativeAddCartCallBack] = null;
973
973
  };
974
974
  }
975
975
  const productsAddCartList = productIdsArr.map((skuItem) => {
976
976
  return isAndroidDevice
977
977
  ? {
978
978
  sku: skuItem,
979
979
  num: addCardNum,
980
980
  }
981
981
  : {
982
982
  productCode: skuItem,
983
983
  buyCount: addCardNum,
984
984
  };
985
985
  });
986
986
  if (isAndroidDevice) {
987
987
  const androidProductsStr = JSON.stringify(productsAddCartList);
988
988
  callRouterAndroid({
989
989
  routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
990
990
  routerParam: {
991
991
  wareList: productsAddCartList,
992
992
  },
993
993
  callBackName: nativeAddCartCallBack,
994
994
  });
995
995
  } else if (isIosDevice) {
996
996
  if (isLowAppVer) {
997
997
  const lowVersionAppList = productIdsArr.map((skuItem) => {
998
998
  return {
999
999
  sku: skuItem,
1000
1000
  num: addCardNum,
1001
1001
  };
1002
1002
  });
1003
1003
  const lowVersionAppListStr = JSON.stringify(lowVersionAppList);
1004
1004
  const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`;
1005
1005
  jump.side.jdJumpToWeb(url, {});
1006
1006
  resolve({
1007
1007
  ok: true,
1008
1008
  isOpenApp: true,
1009
1009
  msg: '加购完成, 加购结果请点击购物车确认',
1010
1010
  });
1011
1011
  } else {
1012
1012
  callRouterIOS({
1013
1013
  routerURL: 'router://JDCartModule/batchAddService',
1014
1014
  routerParam: {
1015
1015
  sourceType: 'h5',
1016
1016
  sourceValue: '店铺批量加购',
1017
1017
  businessName: 'storeModel',
1018
1018
  isNewMode: '1',
1019
1019
  NotPassWebview: '1',
1020
1020
  products: productsAddCartList,
1021
1021
  },
1022
1022
  callBackName: nativeAddCartCallBack,
1023
1023
  });
1024
1024
  }
1025
1025
  }
1026
1026
  } else if (isMin) {
1027
1027
  console.log('==========>', '京购批量加车!');
1028
1028
  const productsAddCartList = productIdsArr.map((skuItem) => {
1029
1029
  return {
1030
1030
  skuId: skuItem,
1031
1031
  buyNum: addCardNum,
1032
1032
  };
1033
1033
  });
1034
1034
  global.wxAppBizInstance
1035
1035
  .addCart({ commArr: productsAddCartList })
1036
1036
  .then((res) => {
1037
1037
  console.log('dealCartSuccess: ', res);
1038
1038
  resolve({
1039
1039
  ok: true,
1040
1040
  msg: '已加入购物车!',
1041
1041
  data: res,
1042
1042
  });
1043
1043
  })
1044
1044
  .catch((e) => {
1045
1045
  console.log('京购小程序批量加车失败dealCartFail: ', e);
1046
1046
  resolve({
1047
1047
  ok: false,
1048
1048
  msg: '加购失败,请稍后重试',
1049
1049
  });
1050
1050
  });
1051
1051
  } else {
1052
1052
  console.log('==========>', 'M站批量加车!');
1053
1053
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
1054
1054
  }
1055
1055
  } else {
1056
1056
  resolve({
1057
1057
  ok: false,
1058
1058
  msg: '加购sku不能为空',
1059
1059
  });
1060
1060
  }
1061
1061
  });
1062
1062
  }
1063
1063
 
1064
1064
  productAddToCart(skuIdsStr, num) {
1065
1065
  return new Promise((resolve) => {
1066
1066
  if (window.AddcartToolObj) {
1067
1067
  window.AddcartToolObj.addCart({
1068
1068
  skuId: skuIdsStr,
1069
1069
  num,
1070
1070
  source: 'sjdpyw',
1071
1071
  actId: '1',
1072
1072
  loginType: window?.isJingGouMiniViewState ? '11' : '2',
1073
1073
  sucFun(res) {
1074
1074
  console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
1075
1075
  if (res.errId === '0' && res.cartJson) {
1076
1076
  resolve({
1077
1077
  ok: true,
1078
1078
  msg: '已加入购物车!',
1079
1079
  ...res,
1080
1080
  });
1081
1081
  } else {
1082
1082
  if (res.errId === '13') {
1083
1083
  global.doLogin();
1084
1084
  } else {
1085
1085
  resolve({
1086
1086
  ok: false,
1087
1087
  msg: '加购失败,请稍后重试',
1088
1088
  ...res,
1089
1089
  });
1090
1090
  }
1091
1091
  }
1092
1092
  },
1093
1093
  failFun(err) {
1094
1094
  console.log('fail', err);
1095
1095
  resolve({
1096
1096
  ok: false,
1097
1097
  msg: '加购失败,请稍后重试',
1098
1098
  ...err,
1099
1099
  });
1100
1100
  },
1101
1101
  });
1102
1102
  } else {
1103
1103
  resolve({
1104
1104
  ok: false,
1105
1105
  msg: '购物车方法检查异常',
1106
1106
  });
1107
1107
  }
1108
1108
  });
1109
1109
  }
1110
1110
  bMallGetUserInfo = () => {
1111
1111
  return getBMallUserInfo();
1112
1112
  };
1113
1113
  async bMallAddCart(params = {}) {
1114
1114
  return await this.gatewayReq('bmall_cartAdd', params, {
1115
1115
  client: 'H5',
1116
1116
  clientVersion: '5.5.0',
1117
1117
  });
1118
1118
  }
1119
1119
  async bMallChangeCart(params = {}) {
1120
1120
  return await this.gatewayReq('bmall_cartChange', params, {
1121
1121
  client: 'H5',
1122
1122
  clientVersion: '5.5.0',
1123
1123
  });
1124
1124
  }
1125
1125
  async bMallRemoveCart(params = {}) {
1126
1126
  return await this.gatewayReq(
1127
1127
  'bmall_cartRemove',
1128
1128
  params,
1129
1129
  {
1130
1130
  client: 'H5',
1131
1131
  clientVersion: '5.5.0',
1132
1132
  },
1133
1133
  );
1134
1134
  }
1135
1135
  async bMallGetOmittedProduct(params = {}) {
1136
1136
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
1137
1137
  client: 'H5',
1138
1138
  clientVersion: '5.5.0',
1139
1139
  });
1140
1140
  }
1141
1141
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
1142
1142
  const params = await getParams({ ...data, skuId, bMallTag, num });
1143
1143
  return await this.bMallAddCart(params);
1144
1144
  }
1145
1145
  async bMallGetSkuNumService(bMallTag = 1) {
1146
1146
  const params = await getParams({ bMallTag });
1147
1147
  delete params.operations;
1148
1148
  return await this.bMallGetOmittedProduct(params);
1149
1149
  }
1150
1150
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
1151
1151
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
1152
1152
  return await this.bMallRemoveCart(params);
1153
1153
  }
1154
1154
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
1155
1155
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
1156
1156
  return await this.bMallChangeCart(params);
1157
1157
  }
1158
1158
 
1159
1159
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
1160
1160
  if (!needRequest && isH5 && window?.bMallCartData) {
1161
1161
  return window?.bMallCartData;
1162
1162
  }
1163
1163
  const cartData = await this.bMallGetSkuNumService(bMallTag);
1164
1164
  let items;
1165
1165
  if (cartData.ok && cartData.result) {
1166
1166
  items = cartData?.result?.items || {};
1167
1167
  }
1168
1168
  if (isH5) {
1169
1169
  window.bMallCartData = items;
1170
1170
  }
1171
1171
  return items;
1172
1172
  }
1173
1173
 
1174
1174
  async bMallCartHandle(goodItem, num) {
1175
1175
  try {
1176
1176
  const {
1177
1177
  skuUuid,
1178
1178
  limitUpper,
1179
1179
  limitLower,
1180
1180
  } = goodItem;
1181
1181
  let cartNum = Number(num);
1182
1182
  if (limitLower && cartNum && cartNum < limitLower) {
1183
1183
  cartNum = limitLower;
1184
1184
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
1185
1185
  cartNum = limitUpper;
1186
1186
  }
1187
1187
  if (skuUuid && cartNum > 0) {
1188
1188
  return this.bMallChangeCartService({
1189
1189
  ...goodItem,
1190
1190
  skuUuid,
1191
1191
  num: cartNum,
1192
1192
  });
1193
1193
  } else if (!skuUuid && cartNum > 0) {
1194
1194
  return this.bMallAddCartService({ ...goodItem, num: cartNum });
1195
1195
  } else if (skuUuid && !cartNum) {
1196
1196
  return this.bMallRemoveCartService({
1197
1197
  ...goodItem,
1198
1198
  skuUuid,
1199
1199
  num: cartNum,
1200
1200
  });
1201
1201
  } else {
1202
1202
  console.error('参数不全');
1203
1203
  return false;
1204
1204
  }
1205
1205
  } catch (e) {
1206
1206
  console.error(e);
1207
1207
  }
1208
1208
  }