@conecli/cone-render 0.8.20-shop.21 → 0.8.20-shop.211

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 (163) hide show
  1. package/README.md +7 -1
  2. package/dist/api/index.ts +1 -1
  3. package/dist/assets/icon_blue_info.svg +1 -0
  4. package/dist/common/const.ts +1 -1
  5. package/dist/common/environmentType.ts +1 -0
  6. package/dist/common/index.h5.ts +1 -1
  7. package/dist/common/index.jd.ts +1 -1
  8. package/dist/common/index.ts +1 -1
  9. package/dist/common/index.weapp.ts +1 -1
  10. package/dist/common/jdplayerSdk.ts +1 -0
  11. package/dist/common/jssdk.ts +1 -0
  12. package/dist/common/pageType.ts +1 -0
  13. package/dist/common/sgmCustomCode.ts +1 -0
  14. package/dist/common/token/index.h5.ts +1 -1
  15. package/dist/common/token/token.jd.ts +1 -1
  16. package/dist/common/token/token.ts +1 -1
  17. package/dist/common/wxappApi.jd.ts +1 -0
  18. package/dist/common/wxappApi.ts +1 -1
  19. package/dist/components/ErrorBoundary.tsx +1 -1
  20. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  21. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  22. package/dist/components/base/CountDown/index.module.scss +49 -44
  23. package/dist/components/base/CountDown/index.tsx +1 -1
  24. package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
  25. package/dist/components/base/CustomScrollView/index.module.scss +7 -0
  26. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  27. package/dist/components/base/CustomVideo/common.ts +1 -0
  28. package/dist/components/base/CustomVideo/index.module.scss +1 -1
  29. package/dist/components/base/CustomVideo/index.tsx +1 -1
  30. package/dist/components/base/Dialog/index.module.scss +16 -0
  31. package/dist/components/base/Dialog/index.tsx +1 -1
  32. package/dist/components/base/Exposure/index.h5.tsx +1 -1
  33. package/dist/components/base/ExposureSmart/const.ts +1 -0
  34. package/dist/components/base/ExposureSmart/index.h5.module.scss +30 -6
  35. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  36. package/dist/components/base/ExposureSmart/index.module.scss +20 -9
  37. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  38. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  39. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  40. package/dist/components/base/InViewRender/index.tsx +1 -1
  41. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  42. package/dist/components/base/ItemViewExposureSmart/index.module.scss +8 -0
  43. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -0
  44. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  45. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  46. package/dist/components/base/LazyLoadImage/const.ts +1 -1
  47. package/dist/components/base/LazyLoadImage/index.h5.module.scss +24 -20
  48. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  49. package/dist/components/base/MobileCommonHeader/index.module.scss +17 -0
  50. package/dist/components/base/MobileCommonHeader/index.tsx +1 -0
  51. package/dist/components/base/NetworkDataError/const.ts +1 -1
  52. package/dist/components/base/NetworkDataError/index.module.scss +125 -69
  53. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  54. package/dist/components/base/Price/Base/index.module.scss +12 -0
  55. package/dist/components/base/Price/Base/index.tsx +1 -1
  56. package/dist/components/base/Price/Double/index.module.scss +32 -0
  57. package/dist/components/base/Price/Double/index.tsx +1 -1
  58. package/dist/components/base/Price/index.tsx +1 -1
  59. package/dist/components/base/Skeleton/index.tsx +1 -1
  60. package/dist/components/debug/DebugLayout/index.module.scss +67 -0
  61. package/dist/components/debug/DebugLayout/index.tsx +1 -0
  62. package/dist/components/debug/DebugLayout/utils.ts +1 -0
  63. package/dist/components/decorate/DecorateFloorModule/index.module.scss +32 -2
  64. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  65. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  66. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  67. package/dist/components/floorItem.jd.tsx +1 -1
  68. package/dist/components/floorItem.tsx +1 -1
  69. package/dist/components/floorItem.weapp.tsx +1 -1
  70. package/dist/components/isv/Floor/index.tsx +1 -1
  71. package/dist/components/remoteFloorItem.tsx +1 -0
  72. package/dist/interface/common.ts +1 -1
  73. package/dist/interface/component.ts +1 -1
  74. package/dist/interface/jumpEventReport.ts +1 -1
  75. package/dist/interface/service.ts +1 -1
  76. package/dist/interface/utils.ts +1 -1
  77. package/dist/jumpEventReport/base.ts +1 -1
  78. package/dist/jumpEventReport/const.ts +1 -1
  79. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  80. package/dist/jumpEventReport/index.h5.ts +1 -1
  81. package/dist/jumpEventReport/index.jd.ts +1 -1
  82. package/dist/jumpEventReport/index.ts +1 -1
  83. package/dist/jumpEventReport/index.weapp.ts +1 -1
  84. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  85. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  86. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  87. package/dist/jumpEventReport/web/report.ts +1 -1
  88. package/dist/jumpEventReport/web.base.ts +1 -1
  89. package/dist/jumpEventReport/web.jd.ts +1 -1
  90. package/dist/jumpEventReport/web.jdb.ts +1 -1
  91. package/dist/jumpEventReport/web.jdjch.ts +1 -0
  92. package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
  93. package/dist/jumpEventReport/web.pc.ts +1 -0
  94. package/dist/jumpEventReport/web.tjapp.ts +1 -0
  95. package/dist/jumpEventReport/web.tjm.ts +1 -0
  96. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  97. package/dist/language/en_US.json +178 -0
  98. package/dist/language/zh_CN.json +178 -0
  99. package/dist/language/zh_HK.json +178 -0
  100. package/dist/libs/taroAppReport.js +2 -2
  101. package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -27
  102. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  103. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  104. package/dist/open/api/device.ts +1 -1
  105. package/dist/open/api/environment.ts +1 -1
  106. package/dist/open/api/index.ts +1 -1
  107. package/dist/open/api/jump/business.ts +1 -0
  108. package/dist/open/api/jump/index.ts +1 -0
  109. package/dist/open/api/jump/minPath.ts +1 -0
  110. package/dist/open/api/jump/side.ts +1 -0
  111. package/dist/open/api/jump/webUrl.ts +1 -0
  112. package/dist/open/api/jump copy.ts +1 -0
  113. package/dist/open/api/request.ts +1 -1
  114. package/dist/open/api/shopMember.ts +1 -1
  115. package/dist/open/api/track.ts +1 -1
  116. package/dist/open/api/util.ts +1 -1
  117. package/dist/open/components/index.ts +1 -1
  118. package/dist/sass/app.h5.scss +289 -212
  119. package/dist/sass/base.scss +195 -137
  120. package/dist/service/bMallConst.ts +1 -1
  121. package/dist/service/fetchGateway.ts +1 -1
  122. package/dist/service/fetchGateway.weapp.ts +1 -0
  123. package/dist/service/http/colorSign.ts +1 -1
  124. package/dist/service/http/const.ts +1 -1
  125. package/dist/service/http/h5Http.ts +1 -0
  126. package/dist/service/http/index.h5.ts +1 -0
  127. package/dist/service/requestServer.h5.ts +1 -0
  128. package/dist/service/requestServer.ts +1 -1
  129. package/dist/service/requestServer.weapp.ts +1 -0
  130. package/dist/utils/connectNativeJsBridge.ts +1 -1
  131. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  132. package/dist/utils/draExceptionAndProfile.ts +1 -1
  133. package/dist/utils/h5Utils.ts +1 -1
  134. package/dist/utils/index.h5.ts +1 -1
  135. package/dist/utils/index.ts +1 -1
  136. package/dist/utils/index.weapp.ts +1 -1
  137. package/dist/utils/intersectionObserver.ts +1 -1
  138. package/dist/utils/jm-common.js +1 -1
  139. package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
  140. package/dist/utils/jumpExtMapUtil.ts +1 -0
  141. package/dist/utils/sColor.js +1 -0
  142. package/dist/utils/sgmCodeUtils.ts +1 -0
  143. package/dist/utils/taroRenderUtil.ts +1 -0
  144. package/dist/utils/utils.ts +1 -1
  145. package/dist/wxapp/api/helper.js +1 -0
  146. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  147. package/dist/wxapp/common/user_info.js +1 -1
  148. package/dist/wxapp/components/launch-app/index.js +1 -0
  149. package/dist/wxapp/components/launch-app/index.json +5 -0
  150. package/dist/wxapp/components/launch-app/index.wxml +0 -0
  151. package/dist/wxapp/components/launch-app/index.wxss +0 -0
  152. package/dist/wxapp/components/subscribe-guider/helper.js +1 -0
  153. package/dist/wxapp/components/subscribe-guider/index.js +1 -0
  154. package/dist/wxapp/components/subscribe-guider/index.json +5 -0
  155. package/dist/wxapp/components/subscribe-guider/index.wxml +0 -0
  156. package/dist/wxapp/components/subscribe-guider/index.wxss +0 -0
  157. package/package.json +148 -115
  158. package/dist/components/base/Skeleton/old.tsx +0 -1
  159. package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
  160. package/dist/open/api/jump.ts +0 -1
  161. package/dist/utils/memberFormatUtils.js +0 -1
  162. /package/dist/service/{bMallConst.wxapp.ts → bMallConst.weapp.ts} +0 -0
  163. /package/dist/service/http/{colorSign.wxapp.ts → colorSign.weapp.ts} +0 -0
@@ -0,0 +1 @@
1
+ import Taro from '@tarojs/taro';
2
  APPID,
1
3
  JshopxColorFunctionIdList,
2
4
  PagesColorFunctionIdList,
3
5
  PAGES_DOMAIN,
4
6
  B2BColorFunctionIdList,
5
7
  MobileVerifyColorList,
6
8
  AppVerifyColorList,
7
9
  JshopxVerifyColorList,
8
10
  BMallVerifyColorList,
9
11
  shopMemberColorFunctionIdList,
10
12
  draBusinessCustomReport,
11
13
  isJdApp,
12
14
  isIosDevice,
13
15
  isAndroidDevice,
14
16
  isJdAndHarmonyDevice,
15
17
  showSuccessToast,
16
18
  showFailToast,
17
19
  isH5,
18
20
  isWxMinAndWxapp,
19
21
  isMin,
20
22
  isPc,
21
23
  draInterfaceCustomReport,
22
24
  callRouterIOS,
23
25
  callRouterAndroid,
24
26
  sendNativePageToShowCartFloatBtn,
25
27
  cookiesStr: '',
26
28
  requestHeaderContentType: {
27
29
  jsonHeader: {
28
30
  'content-type': 'application/json;charset=utf-8',
29
31
  },
30
32
  formDataHeader: {
31
33
  'content-type': 'application/x-www-form-urlencoded',
32
34
  },
33
35
  },
34
36
  requestBaseParam: {
35
37
  data: null,
36
38
  header: {
37
39
  'content-type': 'application/json;charset=utf-8',
38
40
  },
39
41
  },
40
42
  timeOut: 7000,
41
43
  apiClientParams: {
42
44
  clientVersion: isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
43
45
  client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
44
46
  area: '1_72_2799_0',
45
47
  screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
46
48
  window.screen?.height * devicePixelRatio,
47
49
  )}`,
48
50
  uuid: UUID,
49
51
  },
50
52
  public addressFetchInfo: {
51
53
  reqState: boolean;
52
54
  promiseInstance: null | Promise<any>;
53
55
  };
54
56
  public getPromotionConfig: {
55
57
  projectId: null | string | number;
56
58
  pageId: null | string | number;
57
59
  };
58
60
  public resInfo: ServiceInterFace.HttpRequestInfo;
59
61
  public api: ServiceInterFace.HttpApi;
60
62
  public isPageDomain: boolean;
61
63
  public verifyColorList: string[];
62
64
  private isShowJdShopCartFloatBtn: boolean;
63
65
  constructor(opt) {
64
66
  this._init();
65
67
  this.addressFetchInfo = {
66
68
  reqState: false,
67
69
  promiseInstance: null,
68
70
  };
69
71
  this.getPromotionConfig = {
70
72
  projectId: null,
71
73
  pageId: null,
72
74
  };
73
75
  this._userAreaUpdateListen();
74
76
  this.resInfo = this._getResConfig(opt);
75
77
  this.api = api;
76
78
  this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
77
79
  this.verifyColorList = [
78
80
  ...MobileVerifyColorList,
79
81
  ...AppVerifyColorList,
80
82
  ...JshopxVerifyColorList,
81
83
  ...BMallVerifyColorList,
82
84
  ];
83
85
  this.isShowJdShopCartFloatBtn =
84
86
  jdAppVersionCompare(isJdAndIosDevice ? '13.8.6' : '13.6.2') >= 0;
85
87
  }
86
88
  _init(): void {
87
89
  httpInterceptors.forEach((item) => {
88
90
  Taro.addInterceptor((chain) => item(chain));
89
91
  });
90
92
  }
91
93
  _getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
92
94
  return Object.assign({}, DefaultConfig, opt);
93
95
  }
94
96
 
95
97
  _userAreaUpdateListen() {
96
98
  Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
97
99
  this.updateApiClientParamsResInfo(areaInfo);
98
100
  console.log(
99
101
  'cone-render收到原生端获取传来的四级地址信息',
100
102
  areaInfo,
101
103
  '更新后的接口底层信息',
102
104
  this.resInfo.apiClientParams,
103
105
  );
104
106
  });
105
107
  }
106
108
  updateApiClientParamsResInfo(opt = {}) {
107
109
  const { area, realTimeArea, ...others } = opt;
108
110
  this.resInfo.apiClientParams = {
109
111
  ...this.resInfo.apiClientParams,
110
112
  ...others,
111
113
  };
112
114
  area && area !== '' && (this.resInfo.apiClientParams.area = area);
113
115
  realTimeArea &&
114
116
  realTimeArea !== '' &&
115
117
  (this.resInfo.apiClientParams.realTimeArea = realTimeArea);
116
118
  }
117
119
 
118
120
  checkFunctionIdToReturnAppId(functionId) {
119
121
  if (JshopxColorFunctionIdList.includes(functionId)) {
120
122
  return APPID.JSHOPX_COLOR_APPID;
121
123
  } else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
122
124
  return APPID.PAGES_COLOR_APPID;
123
125
  } else if (shopMemberColorFunctionIdList.includes(functionId)) {
124
126
  return APPID.SHOP_MEMBER_COLOR_APPID;
125
127
  } else if (B2BColorFunctionIdList.includes(functionId)) {
126
128
  return APPID.B2B_COLOR_APPID;
127
129
  } else if (isPc) {
128
130
  return APPID.MALL_COLOR_APPID;
129
131
  } else {
130
132
  return APPID.SHOP_COLOR_APPID;
131
133
  }
132
134
  }
133
135
 
134
136
  gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
135
137
  if (
136
138
  functionId === 'receiveShopCoupon' &&
137
139
  ((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
138
140
  isWxMinAndWxapp)
139
141
  ) {
140
142
  clientParams = Object.assign(
141
143
  {},
142
144
  {
143
145
  loginType: '1',
144
146
  loginWQBiz: WXAPP_BIZ_KEY,
145
147
  },
146
148
  clientParams,
147
149
  );
148
150
  }
149
151
  const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
150
152
  typeof apiClientParams.appid === 'undefined' &&
151
153
  (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
152
154
  const isColorVerify = this.verifyColorList.includes(functionId);
153
155
  const getReqData = {
154
156
  functionId: functionId,
155
157
  body: JSON.stringify(bodyParams),
156
158
  t: Date.now(),
157
159
  ...apiClientParams,
158
160
  };
159
161
  return http
160
162
  .request({
161
163
  url: this.api.apiFunc,
162
164
  data: getReqData,
163
165
  isColorVerify,
164
166
  })
165
167
  .then((res: ServiceInterFace.RequestPromiseRes) => {
166
168
  const { statusCode, data, status, msg } = res;
167
169
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
168
170
  ok: true,
169
171
  };
170
172
  if ((statusCode === 200 || status === '0') && data) {
171
173
  changeRes = this.dealResponseFormatRes(data);
172
174
  return changeRes;
173
175
  } else {
174
176
  changeRes = {
175
177
  ...data,
176
178
  statusCode,
177
179
  status,
178
180
  msg,
179
181
  ok: false,
180
182
  };
181
183
  return changeRes;
182
184
  }
183
185
  })
184
186
  .catch((res) => {
185
187
  const propertyNames = Object.getOwnPropertyNames(res);
186
188
  const resObject = {};
187
189
  propertyNames.forEach((propertyName) => {
188
190
  resObject[propertyName] = res[propertyName];
189
191
  });
190
192
  draInterfaceCustomReport({
191
193
  subMsg:
192
194
  '接口请求异常,进入catch逻辑,例如h5请求神盾(反爬、小号、风控)或加固拦截返回status为403等',
193
195
  url: this.api.apiFunc,
194
196
  source: 'remote',
195
197
  requestType: res?.requestType,
196
198
  errorType: 'catchError',
197
199
  functionId: getReqData?.functionId,
198
200
  appid: getReqData?.appid,
199
201
  client: getReqData?.client,
200
202
  clientVersion: getReqData?.clientVersion,
201
203
  statusCode: res?.statusCode,
202
204
  status: res?.status,
203
205
  statusText: res?.statusText,
204
206
  code: res?.data?.code || res?.data?.subCode,
205
207
  errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
206
208
  originReqDataStr: JSON.stringify(getReqData),
207
209
  originResDataStr: JSON.stringify(res, propertyNames),
208
210
  });
209
211
  return {
210
212
  ...resObject,
211
213
  ok: false,
212
214
  } as ServiceInterFace.RequestResponseFormatRes;
213
215
  });
214
216
  }
215
217
 
216
218
  dealResponseFormatRes(data) {
217
219
  let changeRes: ServiceInterFace.RequestResponseFormatRes = {
218
220
  ok: true,
219
221
  };
220
222
  const resCode = Object.prototype.hasOwnProperty.call(data, 'code') ? Number(data.code) : -1;
221
223
  const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
222
224
  ? Number(data.subCode)
223
225
  : -1;
224
226
  if (
225
227
  data.success === true ||
226
228
  data.isSuccess ||
227
229
  resCode === 0 ||
228
230
  resCode === 200 ||
229
231
  subCode === 0
230
232
  ) {
231
233
  changeRes = {
232
234
  result: Object.prototype.hasOwnProperty.call(data, 'result')
233
235
  ? data.result
234
236
  : Object.prototype.hasOwnProperty.call(data, 'data')
235
237
  ? data.data
236
238
  : data,
237
239
  code: data.code ?? 200,
238
240
  ok: true,
239
241
  source: data,
240
242
  };
241
243
  return changeRes;
242
244
  } else {
243
245
  changeRes = {
244
246
  ...data,
245
247
  ok: false,
246
248
  };
247
249
  return changeRes;
248
250
  }
249
251
  }
250
252
 
251
253
  async receiveCoupon(param = {}, clientParams) {
252
254
  const loginType = isPc ? { loginType: 3 } : {};
253
255
  return await this.gatewayReq(
254
256
  'receiveShopCoupon',
255
257
  {
256
258
  operation: '3',
257
259
  ...param,
258
260
  },
259
261
  { ...loginType, ...clientParams },
260
262
  );
261
263
  }
262
264
 
263
265
  getCustomerCenterDispatch(params = {}) {
264
266
  return this.gatewayReq('customerCenterDispatch', params, {
265
267
  clientVersion: '9.2.0',
266
268
  client: 'H5',
267
269
  uuid: 88888,
268
270
  appid: 'shopmember_m_jd_com',
269
271
  });
270
272
  }
271
273
 
272
274
  batchAddCart(...args) {
273
275
  let skuIds, num, showToast, giftCard;
274
276
  if (['number', 'string'].includes(typeof args[0])) {
275
277
  [skuIds, num = 1, showToast = true, giftCard = false] = args;
276
278
  } else if (typeof args[0] === 'object' && args[0] !== null) {
277
279
  const params = args[0];
278
280
  skuIds = params.skuIds;
279
281
  num = params.num || 1;
280
282
  showToast = params.showToast !== undefined ? params.showToast : true;
281
283
  giftCard = params.giftCard !== undefined ? params.giftCard : false;
282
284
  } else {
283
285
  console.error('batchAddCart() Invalid arguments!', args);
284
286
  try {
285
287
  const data = {
286
288
  type: 'batchAddCart',
287
289
  subType: 'invalidInputParameter',
288
290
  errMsg: '入参不合法',
289
291
  originData: args,
290
292
  };
291
293
  draBusinessCustomReport(data);
292
294
  } catch (e) {
293
295
  console.error('draBusinessCustomReport error:', e);
294
296
  }
295
297
  const msg = global?.languageJsonData?.failAddCart || '加入购物车失败,请稍后重试';
296
298
  showFailToast({
297
299
  title: msg,
298
300
  });
299
301
  return Promise.resolve({
300
302
  ok: false,
301
303
  msg,
302
304
  });
303
305
  }
304
306
  const successMsg = giftCard ? (global?.languageJsonData?.successAddShopList || '加入购物清单成功') : (global?.languageJsonData?.successAddCart || '加入购物车成功');
305
307
  const failMsg = giftCard ? (global?.languageJsonData?.failAddShopList || '加入购物清单失败,请稍后重试') : (global?.languageJsonData?.failAddCart || '加入购物车失败,请稍后重试');
306
308
  if (skuIds) {
307
309
  return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
308
310
  .then((res: ServiceInterFace.SkuToCartDataRes) => {
309
311
  if (res?.ok) {
310
312
  showToast &&
311
313
  !res?.isOpenApp &&
312
314
  showSuccessToast({
313
315
  title: successMsg,
314
316
  });
315
317
  this.isShowJdShopCartFloatBtn &&
316
318
  sendNativePageToShowCartFloatBtn({
317
319
  isShow: true,
318
320
  });
319
321
  } else {
320
322
  showToast &&
321
323
  showFailToast({
322
324
  title: res?.errMsg || failMsg,
323
325
  });
324
326
  }
325
327
  return Promise.resolve(res);
326
328
  })
327
329
  .catch((e) => {
328
330
  console.log('调用加购方法异常=======>', e);
329
331
  return Promise.resolve({
330
332
  ok: false,
331
333
  msg: failMsg,
332
334
  });
333
335
  });
334
336
  } else {
335
337
  try {
336
338
  const data = {
337
339
  type: 'batchAddCart',
338
340
  subType: 'invalidInputParameter',
339
341
  errMsg: '没有传入合法的skuIds',
340
342
  originData: skuIds,
341
343
  };
342
344
  draBusinessCustomReport(data);
343
345
  } catch (e) {
344
346
  console.error('draBusinessCustomReport error:', e);
345
347
  }
346
348
  return Promise.resolve({
347
349
  ok: false,
348
350
  msg: failMsg,
349
351
  });
350
352
  }
351
353
  }
352
354
 
353
355
  async giftCardAddCart(skuList, num) {
354
356
  const loginType = isPc ? { loginType: 3 } : {};
355
357
  return this.gatewayReq(
356
358
  'giftCardAddCart',
357
359
  {
358
360
  skuList,
359
361
  num: Number(num),
360
362
  },
361
363
  { ...loginType },
362
364
  );
363
365
  }
364
366
 
365
367
  _addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
366
368
  return new Promise((resolve) => {
367
369
  const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
368
370
  if (productIdsArr.length > 0) {
369
371
  if (giftCard) {
370
372
  this.giftCardAddCart(productIdsArr, addCardNum)
371
373
  .then((res) => {
372
374
  if (res?.code === '0' && res?.result?.value) {
373
375
  resolve({
374
376
  ok: true,
375
377
  });
376
378
  } else {
377
379
  try {
378
380
  const data = {
379
381
  type: 'batchAddCart',
380
382
  subType: 'addCartFailByGiftCard',
381
383
  errMsg: '礼品卡加车接口返回加车失败标识',
382
384
  originData: res,
383
385
  };
384
386
  draBusinessCustomReport(data);
385
387
  } catch (e) {
386
388
  console.error('draBusinessCustomReport error:', e);
387
389
  }
388
390
  resolve({
389
391
  ok: false,
390
392
  msg: '加购失败,请稍后重试',
391
393
  });
392
394
  }
393
395
  })
394
396
  .catch((e) => {
395
397
  console.error('礼品卡加车失败: ', e);
396
398
  resolve({
397
399
  ok: false,
398
400
  msg: '加购失败,请稍后重试',
399
401
  });
400
402
  });
401
403
  } else if (isJdApp && !isJdAndHarmonyDevice) {
402
404
  const nativeAddCartCallBack = `nativeBatchAddCart${Date.now() + Number(productIdsArr[0]) + Number(addCardNum)}`;
403
405
  console.log(
404
406
  '==========>',
405
407
  '原生批量加车, 回调方法保证唯一添加skuid和数量,nativeAddCartCallBack',
406
408
  nativeAddCartCallBack,
407
409
  );
408
410
  if (!window[nativeAddCartCallBack]) {
409
411
  window[nativeAddCartCallBack] = (res) => {
410
412
  const getMessageJsonData = typeof res === 'string' ? JSON.parse(res) : res;
411
413
  console.info(
412
414
  '获取批量加车原始数据',
413
415
  res,
414
416
  '====转换后的json数据为===',
415
417
  getMessageJsonData,
416
418
  );
417
419
  try {
418
420
  if (isAndroidDevice) {
419
421
  const isOk = getMessageJsonData?.status === '0';
420
422
  isOk
421
423
  ? resolve({
422
424
  ok: true,
423
425
  msg: '已加入购物车!',
424
426
  })
425
427
  : resolve({
426
428
  ok: false,
427
429
  msg: '加购失败,请稍后重试',
428
430
  errMsg: getMessageJsonData?.data?.message ?? '',
429
431
  });
430
432
  if (!isOk) {
431
433
  const data = {
432
434
  type: 'batchAddCart',
433
435
  subType: 'addCartFailByH5CallAndroidNative',
434
436
  errMsg: 'H5调用安卓原生加车失败',
435
437
  originData: getMessageJsonData,
436
438
  };
437
439
  draBusinessCustomReport(data);
438
440
  }
439
441
  } else if (isIosDevice) {
440
442
  const isOk =
441
443
  getMessageJsonData?.status === '0' && getMessageJsonData?.data?.code === 0;
442
444
  isOk
443
445
  ? resolve({
444
446
  ok: true,
445
447
  msg: '已加入购物车!',
446
448
  })
447
449
  : resolve({
448
450
  ok: false,
449
451
  msg: '批量加车失败,请稍后重试',
450
452
  errMsg: getMessageJsonData?.data?.message ?? '',
451
453
  });
452
454
  if (!isOk) {
453
455
  const data = {
454
456
  type: 'batchAddCart',
455
457
  subType: 'addCartFailByH5CallIosNative',
456
458
  errMsg: 'H5调用IOS原生加车失败',
457
459
  originData: getMessageJsonData,
458
460
  };
459
461
  draBusinessCustomReport(data);
460
462
  }
461
463
  } else {
462
464
  resolve({
463
465
  ok: false,
464
466
  msg: '加购失败,请稍后重试',
465
467
  });
466
468
  const data = {
467
469
  type: 'batchAddCart',
468
470
  subType: 'addCartFailByH5CallUnknownNative',
469
471
  errMsg: 'H5调用未知原生加车失败',
470
472
  };
471
473
  draBusinessCustomReport(data);
472
474
  }
473
475
  } catch (e) {
474
476
  resolve({
475
477
  ok: false,
476
478
  msg: '加购失败,请稍后重试',
477
479
  });
478
480
  console.warn('批量加车转换数据异常', e);
479
481
  const data = {
480
482
  type: 'batchAddCart',
481
483
  subType: 'addCartFailByTransformData',
482
484
  errMsg: '批量加车转换数据异常',
483
485
  originData: e,
484
486
  };
485
487
  draBusinessCustomReport(data);
486
488
  }
487
489
  window[nativeAddCartCallBack] = null;
488
490
  };
489
491
  }
490
492
  const productsAddCartList = productIdsArr.map((skuItem) => {
491
493
  const adInfos = getAdInfoBySkuId(skuItem);
492
494
  const extFlag = adInfos ? { adInfos } : {};
493
495
  return isAndroidDevice
494
496
  ? {
495
497
  sku: skuItem,
496
498
  num: addCardNum,
497
499
  extFlag,
498
500
  }
499
501
  : {
500
502
  productCode: skuItem,
501
503
  buyCount: addCardNum,
502
504
  extFlag,
503
505
  };
504
506
  });
505
507
  if (isAndroidDevice) {
506
508
  const androidProductsStr = JSON.stringify(productsAddCartList);
507
509
  callRouterAndroid({
508
510
  routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
509
511
  routerParam: {
510
512
  wareList: productsAddCartList,
511
513
  },
512
514
  callBackName: nativeAddCartCallBack,
513
515
  });
514
516
  } else if (isIosDevice) {
515
517
  if (isLowAppVer) {
516
518
  const lowVersionAppList = productIdsArr.map((skuItem) => {
517
519
  return {
518
520
  sku: skuItem,
519
521
  num: addCardNum,
520
522
  };
521
523
  });
522
524
  const lowVersionAppListStr = JSON.stringify(lowVersionAppList);
523
525
  const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`;
524
526
  jump.side.jdJumpToWeb(url, {});
525
527
  resolve({
526
528
  ok: true,
527
529
  isOpenApp: true,
528
530
  msg: '加购完成, 加购结果请点击购物车确认',
529
531
  });
530
532
  } else {
531
533
  callRouterIOS({
532
534
  routerURL: 'router://JDCartModule/batchAddService',
533
535
  routerParam: {
534
536
  sourceType: 'h5',
535
537
  sourceValue: '店铺批量加购',
536
538
  businessName: 'storeModel',
537
539
  isNewMode: '1',
538
540
  NotPassWebview: '1',
539
541
  products: productsAddCartList,
540
542
  },
541
543
  callBackName: nativeAddCartCallBack,
542
544
  });
543
545
  }
544
546
  }
545
547
  } else if (isMin) {
546
548
  console.log('==========>', '京购批量加车!');
547
549
  const productsAddCartList = productIdsArr.map((skuItem) => {
548
550
  return {
549
551
  skuId: skuItem,
550
552
  buyNum: addCardNum,
551
553
  };
552
554
  });
553
555
  global.wxAppBizInstance
554
556
  .addCart({ commArr: productsAddCartList })
555
557
  .then((res) => {
556
558
  console.log('dealCartSuccess: ', res);
557
559
  resolve({
558
560
  ok: true,
559
561
  msg: '已加入购物车!',
560
562
  data: res,
561
563
  });
562
564
  })
563
565
  .catch((e) => {
564
566
  console.log('京购小程序批量加车失败dealCartFail: ', e);
565
567
  resolve({
566
568
  ok: false,
567
569
  msg: '加购失败,请稍后重试',
568
570
  });
569
571
  const data = {
570
572
  type: 'batchAddCart',
571
573
  subType: 'addCartFailByH5CallMini',
572
574
  errMsg: 'H5调用小程序加车失败',
573
575
  originData: e,
574
576
  };
575
577
  draBusinessCustomReport(data);
576
578
  });
577
579
  } else {
578
580
  console.log('==========>', 'M站批量加车!');
579
581
  return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
580
582
  }
581
583
  } else {
582
584
  resolve({
583
585
  ok: false,
584
586
  msg: '加购sku不能为空',
585
587
  });
586
588
  const data = {
587
589
  type: 'batchAddCart',
588
590
  subType: 'addCartFailNoSku',
589
591
  errMsg: '加购sku不能为空',
590
592
  originData: skuIdsStr,
591
593
  };
592
594
  draBusinessCustomReport(data);
593
595
  }
594
596
  });
595
597
  }
596
598
 
597
599
  productAddToCart(skuIdsStr, num) {
598
600
  return new Promise((resolve) => {
599
601
  if (window.AddcartToolObj) {
600
602
  window.AddcartToolObj.addCart({
601
603
  skuId: skuIdsStr,
602
604
  num,
603
605
  source: 'sjdpyw',
604
606
  actId: '1',
605
607
  loginType: window?.isJingGouMiniViewState ? '11' : '2',
606
608
  sucFun(res) {
607
609
  console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
608
610
  if (res.errId === '0' && res.cartJson) {
609
611
  resolve({
610
612
  ok: true,
611
613
  msg: '已加入购物车!',
612
614
  ...res,
613
615
  });
614
616
  } else {
615
617
  if (res.errId === '13') {
616
618
  global.doLogin();
617
619
  } else {
618
620
  resolve({
619
621
  ok: false,
620
622
  msg: '加购失败,请稍后重试',
621
623
  ...res,
622
624
  });
623
625
  const data = {
624
626
  type: 'batchAddCart',
625
627
  subType: 'addCartFailByH5CallM',
626
628
  errMsg: 'H5调用M站加车失败',
627
629
  originData: res,
628
630
  };
629
631
  draBusinessCustomReport(data);
630
632
  }
631
633
  }
632
634
  },
633
635
  failFun(err) {
634
636
  console.log('fail', err);
635
637
  resolve({
636
638
  ok: false,
637
639
  msg: '加购失败,请稍后重试',
638
640
  ...err,
639
641
  });
640
642
  const data = {
641
643
  type: 'batchAddCart',
642
644
  subType: 'addCartFailByH5CallM',
643
645
  errMsg: 'H5调用M站加车失败',
644
646
  originData: err,
645
647
  };
646
648
  draBusinessCustomReport(data);
647
649
  },
648
650
  });
649
651
  } else {
650
652
  resolve({
651
653
  ok: false,
652
654
  msg: '购物车方法检查异常',
653
655
  });
654
656
  const data = {
655
657
  type: 'batchAddCart',
656
658
  subType: 'addCartFailByH5CallM',
657
659
  errMsg: 'H5调用M站加车检查依赖方法异常',
658
660
  };
659
661
  draBusinessCustomReport(data);
660
662
  }
661
663
  });
662
664
  }
663
665
  bMallGetUserInfo = () => {
664
666
  return getBMallUserInfo();
665
667
  };
666
668
  async bMallAddCart(params = {}) {
667
669
  return await this.gatewayReq('bmall_cartAdd', params, {
668
670
  client: 'H5',
669
671
  clientVersion: '5.5.0',
670
672
  });
671
673
  }
672
674
  async bMallChangeCart(params = {}) {
673
675
  return await this.gatewayReq('bmall_cartChange', params, {
674
676
  client: 'H5',
675
677
  clientVersion: '5.5.0',
676
678
  });
677
679
  }
678
680
  async bMallRemoveCart(params = {}) {
679
681
  return await this.gatewayReq(
680
682
  'bmall_cartRemove',
681
683
  params,
682
684
  {
683
685
  client: 'H5',
684
686
  clientVersion: '5.5.0',
685
687
  },
686
688
  );
687
689
  }
688
690
  async bMallGetOmittedProduct(params = {}) {
689
691
  return await this.gatewayReq('bmall_getOmittedProduct', params, {
690
692
  client: 'H5',
691
693
  clientVersion: '5.5.0',
692
694
  });
693
695
  }
694
696
  async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
695
697
  const params = await getParams({ ...data, skuId, bMallTag, num });
696
698
  return await this.bMallAddCart(params);
697
699
  }
698
700
  async bMallGetSkuNumService(bMallTag = 1) {
699
701
  const params = await getParams({ bMallTag });
700
702
  delete params.operations;
701
703
  return await this.bMallGetOmittedProduct(params);
702
704
  }
703
705
  async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
704
706
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
705
707
  return await this.bMallRemoveCart(params);
706
708
  }
707
709
  async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
708
710
  let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
709
711
  return await this.bMallChangeCart(params);
710
712
  }
711
713
 
712
714
  async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
713
715
  if (!needRequest && isH5 && window?.bMallCartData) {
714
716
  return window?.bMallCartData;
715
717
  }
716
718
  const cartData = await this.bMallGetSkuNumService(bMallTag);
717
719
  let items;
718
720
  if (cartData.ok && cartData.result) {
719
721
  items = cartData?.result?.items || {};
720
722
  }
721
723
  if (isH5) {
722
724
  window.bMallCartData = items;
723
725
  }
724
726
  return items;
725
727
  }
726
728
 
727
729
  async bMallCartHandle(goodItem, num) {
728
730
  try {
729
731
  const {
730
732
  skuUuid,
731
733
  limitUpper,
732
734
  limitLower,
733
735
  } = goodItem;
734
736
  let cartNum = Number(num);
735
737
  if (limitLower && cartNum && cartNum < limitLower) {
736
738
  cartNum = limitLower;
737
739
  } else if (limitUpper && cartNum && cartNum > limitUpper) {
738
740
  cartNum = limitUpper;
739
741
  }
740
742
  if (skuUuid && cartNum > 0) {
741
743
  return this.bMallChangeCartService({
742
744
  ...goodItem,
743
745
  skuUuid,
744
746
  num: cartNum,
745
747
  });
746
748
  } else if (!skuUuid && cartNum > 0) {
747
749
  return this.bMallAddCartService({ ...goodItem, num: cartNum });
748
750
  } else if (skuUuid && !cartNum) {
749
751
  return this.bMallRemoveCartService({
750
752
  ...goodItem,
751
753
  skuUuid,
752
754
  num: cartNum,
753
755
  });
754
756
  } else {
755
757
  console.error('参数不全');
756
758
  return false;
757
759
  }
758
760
  } catch (e) {
759
761
  console.error(e);
760
762
  }
761
763
  }