@conecli/cone-render 0.10.1-shop3.1 → 0.10.1-shop3.11

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