@conecli/cone-render 0.9.1-shop2.8 → 0.10.1-beta.0

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