@conecli/cone-render 0.9.1-shop2.7 → 0.9.1-shop2.8

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 (40) hide show
  1. package/dist/common/const.ts +1 -1
  2. package/dist/common/index.h5.ts +1 -1
  3. package/dist/common/index.ts +1 -1
  4. package/dist/common/token/token.ts +1 -1
  5. package/dist/components/base/CountDown/index.tsx +1 -1
  6. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  7. package/dist/components/base/Dialog/index.module.scss +5 -0
  8. package/dist/components/base/Dialog/index.tsx +1 -1
  9. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  10. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  11. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  12. package/dist/components/remoteFloorItem.tsx +1 -1
  13. package/dist/interface/common.ts +1 -1
  14. package/dist/interface/component.ts +1 -1
  15. package/dist/interface/jumpEventReport.ts +1 -1
  16. package/dist/jumpEventReport/base.ts +1 -1
  17. package/dist/jumpEventReport/const.ts +1 -1
  18. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  19. package/dist/jumpEventReport/index.weapp.ts +1 -1
  20. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  21. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  22. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  23. package/dist/jumpEventReport/web/report.ts +1 -1
  24. package/dist/jumpEventReport/web.base.ts +1 -1
  25. package/dist/jumpEventReport/web.jd.ts +1 -1
  26. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  27. package/dist/open/api/jump copy.ts +1 -1
  28. package/dist/open/api/shopMember.ts +1 -1
  29. package/dist/open/api/track.ts +1 -1
  30. package/dist/open/api/util.ts +1 -1
  31. package/dist/sass/app.h5.scss +39 -3
  32. package/dist/service/requestServer.ts +1 -1
  33. package/dist/utils/connectNativeJsBridge.ts +1 -1
  34. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  35. package/dist/utils/h5Utils.ts +1 -1
  36. package/dist/utils/index.h5.ts +1 -1
  37. package/dist/utils/index.ts +1 -1
  38. package/dist/utils/index.weapp.ts +1 -1
  39. package/dist/utils/utils.ts +1 -1
  40. 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
  cookiesStr: '',
13
12
  requestHeaderContentType: {
14
13
  jsonHeader: {
15
14
  'content-type': 'application/json;charset=utf-8',
16
15
  },
17
16
  formDataHeader: {
18
17
  'content-type': 'application/x-www-form-urlencoded',
19
18
  },
20
19
  },
21
20
  requestBaseParam: {
22
21
  data: null,
23
22
  header: {
24
23
  'content-type': 'application/json;charset=utf-8',
25
24
  },
26
25
  },
27
26
  timeOut: 7000,
28
27
  apiClientParams: {
29
28
  clientVersion:
30
29
  isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
31
30
  client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
32
31
  area: '1_72_2799_0',
33
32
  uuid: UUID,
34
33
  },
35
34
  public addressFetchInfo: {
36
35
  reqState: boolean
37
36
  promiseInstance: null | Promise<any>
38
37
  }
39
38
  public getPromotionConfig: {
40
39
  projectId: null | string | number
41
40
  pageId: null | string | number
42
41
  }
43
42
  public resInfo: ServiceInterFace.HttpRequestInfo
44
43
  public api: ServiceInterFace.HttpApi
45
44
  public isPageDomain: boolean
46
45
  public verifyColorList: string[]
47
46
  constructor(opt) {
48
47
  this._init()
49
48
  this.addressFetchInfo = {
50
49
  reqState: false,
51
50
  promiseInstance: null,
52
51
  }
53
52
  this.getPromotionConfig = {
54
53
  projectId: null,
55
54
  pageId: null,
56
55
  }
57
56
  this._userAreaUpdateListen()
58
57
  this.resInfo = this._getResConfig(opt)
59
58
  this.api = api
60
59
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
61
60
  this.verifyColorList = [
62
61
  ...MobileVerifyColorList,
63
62
  ...AppVerifyColorList,
64
63
  ...JshopxVerifyColorList,
65
64
  ...BMallVerifyColorList,
66
65
  ]
67
66
  }
68
67
  _init(): void {
69
68
  httpInterceptors.forEach((item) => {
70
69
  Taro.addInterceptor((chain) => item(chain))
71
70
  })
72
71
  }
73
72
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
74
73
  return Object.assign({}, DefaultConfig, opt)
75
74
  }
76
75
 
77
76
  _userAreaUpdateListen() {
78
77
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
79
78
  this.updateApiClientParamsResInfo({
80
79
  area,
81
80
  })
82
81
  })
83
82
  }
84
83
  updateApiClientParamsResInfo(opt = {}) {
85
84
  this.resInfo.apiClientParams = {
86
85
  ...this.resInfo.apiClientParams,
87
86
  ...opt,
88
87
  }
89
88
  }
90
89
 
91
90
  checkFunctionIdToReturnAppId(functionId) {
92
91
  if (JshopxColorFunctionIdList.includes(functionId)) {
93
92
  return APPID.JSHOPX_COLOR_APPID
94
93
  } else if (
95
94
  this.isPageDomain &&
96
95
  PagesColorFunctionIdList.includes(functionId)
97
96
  ) {
98
97
  return APPID.PAGES_COLOR_APPID
99
98
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
100
99
  return APPID.SHOP_MEMBER_COLOR_APPID
101
100
  }else if (B2BColorFunctionIdList.includes(functionId)) {
102
101
  return APPID.B2B_COLOR_APPID
103
102
  } else if (isPc) {
104
103
  return APPID.MALL_COLOR_APPID
105
104
  } else {
106
105
  return APPID.SHOP_COLOR_APPID
107
106
  }
108
107
  }
109
108
 
110
109
  gatewayReq(
111
110
  functionId: string,
112
111
  bodyParams = {},
113
112
  clientParams = {},
114
113
  ): Promise<any> {
115
114
  if (
116
115
  functionId === 'receiveShopCoupon' &&
117
116
  ((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
118
117
  ) {
119
118
  clientParams = Object.assign(
120
119
  {},
121
120
  {
122
121
  loginType: '1',
123
122
  loginWQBiz: WXAPP_BIZ_KEY,
124
123
  },
125
124
  clientParams,
126
125
  )
127
126
  }
128
127
  const apiClientParams = Object.assign(
129
128
  {},
130
129
  this.resInfo.apiClientParams,
131
130
  clientParams,
132
131
  )
133
132
  typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
134
133
  const isColorVerify = this.verifyColorList.includes(functionId)
135
134
  const getReqData = {
136
135
  functionId: functionId,
137
136
  body: JSON.stringify(bodyParams),
138
137
  t: Date.now(),
139
138
  ...apiClientParams,
140
139
  }
141
140
  return http
142
141
  .request({
143
142
  url: this.api.apiFunc,
144
143
  data: getReqData,
145
144
  isColorVerify,
146
145
  })
147
146
  .then((res: ServiceInterFace.RequestPromiseRes) => {
148
147
  const { statusCode, data } = res
149
148
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
150
149
  ok: true,
151
150
  }
152
151
  if (statusCode === 200 && data) {
153
152
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
154
153
  ? Number(res.data.code)
155
154
  : -1
156
155
  const subCode = Object.prototype.hasOwnProperty.call(
157
156
  res.data,
158
157
  'subCode',
159
158
  )
160
159
  ? Number(res.data.subCode)
161
160
  : -1
162
161
  if (
163
162
  data.success === true ||
164
163
  data.isSuccess ||
165
164
  resCode === 0 ||
166
165
  resCode === 200 ||
167
166
  subCode === 0
168
167
  ) {
169
168
  changeRes = {
170
169
  result: Object.prototype.hasOwnProperty.call(data, 'result')
171
170
  ? data.result
172
171
  : Object.prototype.hasOwnProperty.call(data, 'data')
173
172
  ? data.data
174
173
  : data,
175
174
  code: data.code || 200,
176
175
  ok: true,
177
176
  source: data,
178
177
  }
179
178
  return changeRes
180
179
  } else {
181
180
  changeRes = {
182
181
  ...data,
183
182
  ok: false,
184
183
  statusCode: res.statusCode,
185
184
  }
186
185
  return changeRes
187
186
  }
188
187
  } else {
189
188
  changeRes = {
190
189
  ...data,
191
190
  ok: false,
192
191
  statusCode: res.statusCode,
193
192
  }
194
193
  return changeRes
195
194
  }
196
195
  })
197
196
  .catch((res) => {
198
197
  return {
199
198
  ...res,
200
199
  ok: false,
201
200
  } as ServiceInterFace.RequestResponseFormatRes
202
201
  })
203
202
  }
204
203
 
205
204
  async receiveCoupon(param = {}, clientParams) {
206
205
  const loginType = isPc ? { loginType: 3 } : {}
207
206
  return await this.gatewayReq(
208
207
  'receiveShopCoupon',
209
208
  {
210
209
  operation: '3',
211
210
  ...param,
212
211
  },
213
212
  { ...loginType, ...clientParams },
214
213
  )
215
214
  }
216
215
 
217
216
  getCustomerCenterDispatch(params = {}) {
218
217
  return this.gatewayReq('customerCenterDispatch', params, {
219
218
  clientVersion: '9.2.0',
220
219
  client: 'H5',
221
220
  uuid: 88888,
222
221
  appid: 'shopmember_m_jd_com',
223
222
  })
224
223
  }
225
224
  bMallGetUserInfo = () => {
226
225
  return getBMallUserInfo()
227
226
  }
228
227
  async bMallAddCart(params = {}) {
229
228
  return await this.gatewayReq('bmall_cartAdd', params, {
230
229
  client: 'H5',
231
230
  clientVersion: '5.5.0'
232
231
  })
233
232
  }
234
233
  async bMallChangeCart(params = {}) {
235
234
  return await this.gatewayReq('bmall_cartChange', params, {
236
235
  client: 'H5',
237
236
  clientVersion: '5.5.0'
238
237
  })
239
238
  }
240
239
  async bMallRemoveCart(params = {}) {
241
240
  return await this.gatewayReq(
242
241
  'bmall_cartRemove',
243
242
  params,
244
243
  {
245
244
  client: 'H5',
246
245
  clientVersion: '5.5.0'
247
246
  },
248
247
  )
249
248
  }
250
249
  async bMallGetOmittedProduct(params = {}) {
251
250
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
252
251
  client: 'H5',
253
252
  clientVersion: '5.5.0'
254
253
  })
255
254
  }
256
255
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
257
256
  const params = await getParams({ ...data, skuId, bMallTag, num })
258
257
  return await this.bMallAddCart(params)
259
258
  }
260
259
  async bMallGetSkuNumService(bMallTag = 1) {
261
260
  const params = await getParams({ bMallTag })
262
261
  delete params.operations
263
262
  return await this.bMallGetOmittedProduct(params)
264
263
  }
265
264
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
266
265
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
267
266
  return await this.bMallRemoveCart(params)
268
267
  }
269
268
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
270
269
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
271
270
  return await this.bMallChangeCart(params)
272
271
  }
273
272
 
274
273
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
275
274
  if (!needRequest && isH5 && window?.bMallCartData) {
276
275
  return window?.bMallCartData
277
276
  }
278
277
  const cartData = await this.bMallGetSkuNumService(bMallTag)
279
278
  let items
280
279
  if (cartData.ok && cartData.result) {
281
280
  items = cartData?.result?.items || {}
282
281
  }
283
282
  if (isH5) {
284
283
  window.bMallCartData = items
285
284
  }
286
285
  return items
287
286
  }
288
287
 
289
288
  async bMallCartHandle(goodItem, num) {
290
289
  try {
291
290
  const {
292
291
  skuUuid,
293
292
  limitUpper,
294
293
  limitLower,
295
294
  } = goodItem
296
295
  let cartNum = Number(num)
297
296
  if (limitLower && cartNum && cartNum < limitLower) {
298
297
  cartNum = limitLower
299
298
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
300
299
  cartNum = limitUpper
301
300
  }
302
301
  if (skuUuid && cartNum > 0) {
303
302
  return this.bMallChangeCartService({
304
303
  ...goodItem,
305
304
  skuUuid,
306
305
  num: cartNum,
307
306
  })
308
307
  } else if (!skuUuid && cartNum > 0) {
309
308
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
310
309
  } else if (skuUuid && !cartNum) {
311
310
  return this.bMallRemoveCartService({
312
311
  ...goodItem,
313
312
  skuUuid,
314
313
  num: cartNum,
315
314
  })
316
315
  } else {
317
316
  console.error('参数不全')
318
317
  return false
319
318
  }
320
319
  } catch (e) {
321
320
  console.error(e)
322
321
  }
323
322
  }
323
+ import Taro from '@tarojs/taro'
324
324
  APPID,
325
325
  JshopxColorFunctionIdList,
326
326
  PagesColorFunctionIdList,
327
327
  PAGES_DOMAIN,
328
328
  B2BColorFunctionIdList,
329
329
  MobileVerifyColorList,
330
330
  AppVerifyColorList,
331
331
  JshopxVerifyColorList,
332
332
  BMallVerifyColorList,
333
333
  shopMemberColorFunctionIdList
334
334
  cookiesStr: '',
335
335
  requestHeaderContentType: {
336
336
  jsonHeader: {
337
337
  'content-type': 'application/json;charset=utf-8',
338
338
  },
339
339
  formDataHeader: {
340
340
  'content-type': 'application/x-www-form-urlencoded',
341
341
  },
342
342
  },
343
343
  requestBaseParam: {
344
344
  data: null,
345
345
  header: {
346
346
  'content-type': 'application/json;charset=utf-8',
347
347
  },
348
348
  },
349
349
  timeOut: 7000,
350
350
  apiClientParams: {
351
351
  clientVersion:
352
352
  isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
353
353
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
354
354
  area: '1_72_2799_0',
355
355
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(window.screen?.height * devicePixelRatio)}`,
356
356
  uuid: UUID,
357
357
  },
358
358
  public addressFetchInfo: {
359
359
  reqState: boolean
360
360
  promiseInstance: null | Promise<any>
361
361
  }
362
362
  public getPromotionConfig: {
363
363
  projectId: null | string | number
364
364
  pageId: null | string | number
365
365
  }
366
366
  public resInfo: ServiceInterFace.HttpRequestInfo
367
367
  public api: ServiceInterFace.HttpApi
368
368
  public isPageDomain: boolean
369
369
  public verifyColorList: string[]
370
370
  constructor(opt) {
371
371
  this._init()
372
372
  this.addressFetchInfo = {
373
373
  reqState: false,
374
374
  promiseInstance: null,
375
375
  }
376
376
  this.getPromotionConfig = {
377
377
  projectId: null,
378
378
  pageId: null,
379
379
  }
380
380
  this._userAreaUpdateListen()
381
381
  this.resInfo = this._getResConfig(opt)
382
382
  this.api = api
383
383
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
384
384
  this.verifyColorList = [
385
385
  ...MobileVerifyColorList,
386
386
  ...AppVerifyColorList,
387
387
  ...JshopxVerifyColorList,
388
388
  ...BMallVerifyColorList,
389
389
  ]
390
390
  }
391
391
  _init(): void {
392
392
  httpInterceptors.forEach((item) => {
393
393
  Taro.addInterceptor((chain) => item(chain))
394
394
  })
395
395
  }
396
396
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
397
397
  return Object.assign({}, DefaultConfig, opt)
398
398
  }
399
399
 
400
400
  _userAreaUpdateListen() {
401
401
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
402
402
  this.updateApiClientParamsResInfo({
403
403
  area,
404
404
  })
405
405
  })
406
406
  }
407
407
  updateApiClientParamsResInfo(opt = {}) {
408
408
  this.resInfo.apiClientParams = {
409
409
  ...this.resInfo.apiClientParams,
410
410
  ...opt,
411
411
  }
412
412
  }
413
413
 
414
414
  checkFunctionIdToReturnAppId(functionId) {
415
415
  if (JshopxColorFunctionIdList.includes(functionId)) {
416
416
  return APPID.JSHOPX_COLOR_APPID
417
417
  } else if (
418
418
  this.isPageDomain &&
419
419
  PagesColorFunctionIdList.includes(functionId)
420
420
  ) {
421
421
  return APPID.PAGES_COLOR_APPID
422
422
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
423
423
  return APPID.SHOP_MEMBER_COLOR_APPID
424
424
  }else if (B2BColorFunctionIdList.includes(functionId)) {
425
425
  return APPID.B2B_COLOR_APPID
426
426
  } else if (isPc) {
427
427
  return APPID.MALL_COLOR_APPID
428
428
  } else {
429
429
  return APPID.SHOP_COLOR_APPID
430
430
  }
431
431
  }
432
432
 
433
433
  gatewayReq(
434
434
  functionId: string,
435
435
  bodyParams = {},
436
436
  clientParams = {},
437
437
  ): Promise<any> {
438
438
  if (
439
439
  functionId === 'receiveShopCoupon' &&
440
440
  ((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
441
441
  ) {
442
442
  clientParams = Object.assign(
443
443
  {},
444
444
  {
445
445
  loginType: '1',
446
446
  loginWQBiz: WXAPP_BIZ_KEY,
447
447
  },
448
448
  clientParams,
449
449
  )
450
450
  }
451
451
  const apiClientParams = Object.assign(
452
452
  {},
453
453
  this.resInfo.apiClientParams,
454
454
  clientParams,
455
455
  )
456
456
  typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
457
457
  const isColorVerify = this.verifyColorList.includes(functionId)
458
458
  const getReqData = {
459
459
  functionId: functionId,
460
460
  body: JSON.stringify(bodyParams),
461
461
  t: Date.now(),
462
462
  ...apiClientParams,
463
463
  }
464
464
  return http
465
465
  .request({
466
466
  url: this.api.apiFunc,
467
467
  data: getReqData,
468
468
  isColorVerify,
469
469
  })
470
470
  .then((res: ServiceInterFace.RequestPromiseRes) => {
471
471
  const { statusCode, data } = res
472
472
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
473
473
  ok: true,
474
474
  }
475
475
  if (statusCode === 200 && data) {
476
476
  const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
477
477
  ? Number(res.data.code)
478
478
  : -1
479
479
  const subCode = Object.prototype.hasOwnProperty.call(
480
480
  res.data,
481
481
  'subCode',
482
482
  )
483
483
  ? Number(res.data.subCode)
484
484
  : -1
485
485
  if (
486
486
  data.success === true ||
487
487
  data.isSuccess ||
488
488
  resCode === 0 ||
489
489
  resCode === 200 ||
490
490
  subCode === 0
491
491
  ) {
492
492
  changeRes = {
493
493
  result: Object.prototype.hasOwnProperty.call(data, 'result')
494
494
  ? data.result
495
495
  : Object.prototype.hasOwnProperty.call(data, 'data')
496
496
  ? data.data
497
497
  : data,
498
498
  code: data.code || 200,
499
499
  ok: true,
500
500
  source: data,
501
501
  }
502
502
  return changeRes
503
503
  } else {
504
504
  changeRes = {
505
505
  ...data,
506
506
  ok: false,
507
507
  statusCode: res.statusCode,
508
508
  }
509
509
  return changeRes
510
510
  }
511
511
  } else {
512
512
  changeRes = {
513
513
  ...data,
514
514
  ok: false,
515
515
  statusCode: res.statusCode,
516
516
  }
517
517
  return changeRes
518
518
  }
519
519
  })
520
520
  .catch((res) => {
521
521
  return {
522
522
  ...res,
523
523
  ok: false,
524
524
  } as ServiceInterFace.RequestResponseFormatRes
525
525
  })
526
526
  }
527
527
 
528
528
  async receiveCoupon(param = {}, clientParams) {
529
529
  const loginType = isPc ? { loginType: 3 } : {}
530
530
  return await this.gatewayReq(
531
531
  'receiveShopCoupon',
532
532
  {
533
533
  operation: '3',
534
534
  ...param,
535
535
  },
536
536
  { ...loginType, ...clientParams },
537
537
  )
538
538
  }
539
539
 
540
540
  getCustomerCenterDispatch(params = {}) {
541
541
  return this.gatewayReq('customerCenterDispatch', params, {
542
542
  clientVersion: '9.2.0',
543
543
  client: 'H5',
544
544
  uuid: 88888,
545
545
  appid: 'shopmember_m_jd_com',
546
546
  })
547
547
  }
548
548
  bMallGetUserInfo = () => {
549
549
  return getBMallUserInfo()
550
550
  }
551
551
  async bMallAddCart(params = {}) {
552
552
  return await this.gatewayReq('bmall_cartAdd', params, {
553
553
  client: 'H5',
554
554
  clientVersion: '5.5.0'
555
555
  })
556
556
  }
557
557
  async bMallChangeCart(params = {}) {
558
558
  return await this.gatewayReq('bmall_cartChange', params, {
559
559
  client: 'H5',
560
560
  clientVersion: '5.5.0'
561
561
  })
562
562
  }
563
563
  async bMallRemoveCart(params = {}) {
564
564
  return await this.gatewayReq(
565
565
  'bmall_cartRemove',
566
566
  params,
567
567
  {
568
568
  client: 'H5',
569
569
  clientVersion: '5.5.0'
570
570
  },
571
571
  )
572
572
  }
573
573
  async bMallGetOmittedProduct(params = {}) {
574
574
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
575
575
  client: 'H5',
576
576
  clientVersion: '5.5.0'
577
577
  })
578
578
  }
579
579
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
580
580
  const params = await getParams({ ...data, skuId, bMallTag, num })
581
581
  return await this.bMallAddCart(params)
582
582
  }
583
583
  async bMallGetSkuNumService(bMallTag = 1) {
584
584
  const params = await getParams({ bMallTag })
585
585
  delete params.operations
586
586
  return await this.bMallGetOmittedProduct(params)
587
587
  }
588
588
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
589
589
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
590
590
  return await this.bMallRemoveCart(params)
591
591
  }
592
592
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
593
593
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
594
594
  return await this.bMallChangeCart(params)
595
595
  }
596
596
 
597
597
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
598
598
  if (!needRequest && isH5 && window?.bMallCartData) {
599
599
  return window?.bMallCartData
600
600
  }
601
601
  const cartData = await this.bMallGetSkuNumService(bMallTag)
602
602
  let items
603
603
  if (cartData.ok && cartData.result) {
604
604
  items = cartData?.result?.items || {}
605
605
  }
606
606
  if (isH5) {
607
607
  window.bMallCartData = items
608
608
  }
609
609
  return items
610
610
  }
611
611
 
612
612
  async bMallCartHandle(goodItem, num) {
613
613
  try {
614
614
  const {
615
615
  skuUuid,
616
616
  limitUpper,
617
617
  limitLower,
618
618
  } = goodItem
619
619
  let cartNum = Number(num)
620
620
  if (limitLower && cartNum && cartNum < limitLower) {
621
621
  cartNum = limitLower
622
622
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
623
623
  cartNum = limitUpper
624
624
  }
625
625
  if (skuUuid && cartNum > 0) {
626
626
  return this.bMallChangeCartService({
627
627
  ...goodItem,
628
628
  skuUuid,
629
629
  num: cartNum,
630
630
  })
631
631
  } else if (!skuUuid && cartNum > 0) {
632
632
  return this.bMallAddCartService({ ...goodItem, num: cartNum })
633
633
  } else if (skuUuid && !cartNum) {
634
634
  return this.bMallRemoveCartService({
635
635
  ...goodItem,
636
636
  skuUuid,
637
637
  num: cartNum,
638
638
  })
639
639
  } else {
640
640
  console.error('参数不全')
641
641
  return false
642
642
  }
643
643
  } catch (e) {
644
644
  console.error(e)
645
645
  }
646
646
  }