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

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 (115) hide show
  1. package/README.md +1 -1
  2. package/dist/api/index.ts +1 -1
  3. package/dist/common/accessibility.h5.ts +1 -0
  4. package/dist/common/accessibility.ts +1 -0
  5. package/dist/common/const.ts +1 -1
  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.weapp.tsx +1 -0
  11. package/dist/common/jssdk.ts +1 -1
  12. package/dist/common/jssdk.weapp.ts +1 -0
  13. package/dist/common/pageType.ts +1 -1
  14. package/dist/common/token/index.h5.ts +1 -1
  15. package/dist/common/token/token.jd.ts +1 -1
  16. package/dist/common/wxappApi.ascf.ts +1 -0
  17. package/dist/common/wxappApi.ts +1 -1
  18. package/dist/components/ErrorBoundary.tsx +1 -1
  19. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  20. package/dist/components/base/CountDown/index.tsx +1 -1
  21. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  22. package/dist/components/base/CustomVideo/index.tsx +1 -1
  23. package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
  24. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  25. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  26. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  27. package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
  28. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  29. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  30. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  31. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  32. package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
  33. package/dist/components/base/NetworkDataError/const.ts +1 -1
  34. package/dist/components/base/NetworkDataError/index.module.scss +118 -72
  35. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  36. package/dist/components/base/Price/Base/index.module.scss +12 -0
  37. package/dist/components/base/Price/Base/index.tsx +1 -1
  38. package/dist/components/base/Price/Double/index.module.scss +25 -1
  39. package/dist/components/base/Price/Double/index.tsx +1 -1
  40. package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
  41. package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
  42. package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
  43. package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
  44. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  45. package/dist/components/floorItem.tsx +1 -1
  46. package/dist/components/isv/Floor/index.tsx +1 -1
  47. package/dist/components/remoteFloorItem.tsx +1 -1
  48. package/dist/config/env.ts +1 -1
  49. package/dist/interface/common.ts +1 -1
  50. package/dist/interface/component.ts +1 -1
  51. package/dist/interface/jumpEventReport.ts +1 -1
  52. package/dist/interface/service.ts +1 -1
  53. package/dist/jumpEventReport/base.ts +1 -1
  54. package/dist/jumpEventReport/const.ts +1 -1
  55. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  56. package/dist/jumpEventReport/index.h5.ts +1 -1
  57. package/dist/jumpEventReport/index.jd.ts +1 -1
  58. package/dist/jumpEventReport/index.weapp.ts +1 -1
  59. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  60. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  61. package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
  62. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  63. package/dist/jumpEventReport/web/report.ts +1 -1
  64. package/dist/jumpEventReport/web.base.ts +1 -1
  65. package/dist/jumpEventReport/web.jd.ts +1 -1
  66. package/dist/jumpEventReport/web.pc.ts +1 -1
  67. package/dist/jumpEventReport/web.tjm.ts +1 -1
  68. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  69. package/dist/language/en_US.json +395 -0
  70. package/dist/language/zh_CN.json +395 -0
  71. package/dist/language/zh_HK.json +395 -0
  72. package/dist/libs/openShopBridge.js +161 -0
  73. package/dist/libs/openShopBridge.min.js +1 -0
  74. package/dist/libs/taroAppReport.js +2 -2
  75. package/dist/modules/ContainerFloorList/index.h5.module.scss +16 -2
  76. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  77. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  78. package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
  79. package/dist/open/api/environment.ts +1 -1
  80. package/dist/open/api/shopMember.ts +1 -1
  81. package/dist/open/api/shopMember.weapp.ts +1 -0
  82. package/dist/open/api/track.ts +1 -1
  83. package/dist/open/api/util.ts +1 -1
  84. package/dist/open/components/index.ts +1 -1
  85. package/dist/open/index.ts +1 -1
  86. package/dist/sass/app.h5.scss +19 -2
  87. package/dist/sass/base.scss +8 -4
  88. package/dist/service/fetchGateway.ts +1 -1
  89. package/dist/service/fetchGateway.weapp.ts +1 -1
  90. package/dist/service/fetchJsonp.weapp.ts +1 -0
  91. package/dist/service/http/const.ts +1 -1
  92. package/dist/service/http/h5Http.ts +1 -1
  93. package/dist/service/http/httpInterceptors.weapp.ts +1 -0
  94. package/dist/service/requestServer.h5.ts +1 -1
  95. package/dist/service/requestServer.ts +1 -1
  96. package/dist/service/requestServer.weapp.ts +1 -1
  97. package/dist/utils/connectNativeJsBridge.ts +1 -1
  98. package/dist/utils/h5Utils.ts +1 -1
  99. package/dist/utils/harmonyCallRouter.h5.ts +1 -0
  100. package/dist/utils/harmonyCallRouter.ts +0 -0
  101. package/dist/utils/index.h5.ts +1 -1
  102. package/dist/utils/index.ts +1 -1
  103. package/dist/utils/index.weapp.ts +1 -1
  104. package/dist/utils/jumpExtMapUtil.ts +1 -0
  105. package/dist/utils/jumpExtMapUtil.weapp.ts +1 -0
  106. package/dist/utils/log.ts +1 -0
  107. package/dist/utils/{sColor.js → sColor.ts} +1 -1
  108. package/dist/utils/sColor.weapp.ts +1 -0
  109. package/dist/utils/utils.ts +1 -1
  110. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  111. package/dist/wxapp/common/user_info.js +1 -1
  112. package/package.json +165 -141
  113. package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
  114. package/dist/utils/priceUtils.js +0 -1
  115. /package/dist/utils/{jumpExtMapUtil.js → jumpExtMapUtil.h5.ts} +0 -0
@@ -1 +1 @@
1
- import React, { useRef, useEffect } from 'react';
2
1
  isH5AndJdShopView,
3
2
  isAndroidDevice,
4
3
  isJdAndAndroidDevice,
5
4
  isJdAndIosDevice,
6
5
  isIosDevice,
7
6
  isJdApp,
8
7
  isWxMin,
9
8
  isH5AndJdShopViewH5Scroll,
10
9
  isH5AndJdShopH5CustomScrollView,
11
10
  isH5,
12
11
  isAppClassifyPage,
13
12
  lodashThrottle,
14
13
  START: 'start',
15
14
  MOVE: 'move',
16
15
  END: 'end',
17
16
  const {
18
17
  scrollX,
19
18
  children,
20
19
  style = {},
21
20
  iosNeedDisableVertical,
22
21
  dispatchTouchMove,
23
22
  className,
24
23
  ...otherProps
25
24
  } = props;
26
25
  const rootEleNode = isH5 && document ? document.querySelector('body') : null;
27
26
  const needShowHighVersion =
28
27
  isH5AndJdShopViewH5Scroll &&
29
28
  !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
30
29
  const mLastClientPosRef = useRef({
31
30
  mLastClientX: 0,
32
31
  mLastClientY: 0,
33
32
  });
34
33
  const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
35
34
 
36
35
  const touchstartEventBubbleFunc = (e) => {
37
36
  const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
38
37
  if (!isH5SwiperCustomEle) {
39
38
  const hasCustomEle = e
40
39
  ? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
41
40
  : false;
42
41
  if (isJdAndAndroidDevice && !hasCustomEle) {
43
42
  window?.JdAndroid &&
44
43
  window?.JdAndroid?.requestEvent &&
45
44
  window.JdAndroid.requestEvent(false);
46
45
  }
47
46
  !hasCustomEle &&
48
47
  rootEleNode &&
49
48
  rootEleNode.classList.contains('over-hidden') &&
50
49
  rootEleNode.classList.remove('over-hidden');
51
50
  console.log(
52
51
  'customScrollView所在页面document touch start事件是否有J_customScroll元素',
53
52
  hasCustomEle,
54
53
  '根元素是否有over-hidden',
55
54
  rootEleNode.classList,
56
55
  );
57
56
  }
58
57
  };
59
58
  const touchstartEventCaptureFunc = (e) => {
60
59
  if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
61
60
  rootEleNode &&
62
61
  rootEleNode.classList.contains('over-hidden') &&
63
62
  rootEleNode.classList.remove('over-hidden');
64
63
  console.log(
65
64
  'customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden',
66
65
  rootEleNode.classList,
67
66
  );
68
67
  }
69
68
  };
70
69
  useEffect(() => {
71
70
  isJdApp &&
72
71
  !window.JDJshopViewInfo.getAndroidTouchSlopState &&
73
72
  nativePageGetScaledTouchSlop((res) => {
74
73
  console.log('获取安卓系统滑动阈值', res);
75
74
  window.JDJshopViewInfo.androidTouchSlop = res;
76
75
  window.JDJshopViewInfo.getAndroidTouchSlopState = true;
77
76
  });
78
77
  if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
79
78
  global?.removeJdAndroidRquestEventForTouchStart &&
80
79
  global.removeJdAndroidRquestEventForTouchStart();
81
80
  rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
82
81
 
83
82
  rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
84
83
  rootEleAddEventListenerState = true;
85
84
  console.log('customScrollView 初始化document监听完成');
86
85
  }
87
86
  return () => {
88
87
  if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
89
88
  console.log('customScrollView document监听取消完成');
90
89
  rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
91
90
  rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
92
91
  }
93
92
  };
94
93
  }, []);
95
94
 
96
95
  const androidDeviceStopNativeScrollEvent = (touchType) => {
97
96
  isJdApp &&
98
97
  isAndroidDevice &&
99
98
  window?.JdAndroid &&
100
99
  window?.JdAndroid?.requestEvent &&
101
100
  window.JdAndroid.requestEvent(touchType === TouchType.START);
102
101
  console.log('触发window?.JdAndroid.requestEvent', touchType === TouchType.START, touchType);
103
102
  };
104
103
  const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
105
104
  sendIosState && iosDeviceSendRouter(touchType);
106
105
  };
107
106
 
108
107
  const iosDeviceSendRouter = (state: string) => {
109
108
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
110
109
  method: 'callRouterModuleWithParams',
111
110
  params: {
112
111
  routerURL: 'router://JDShopModule/processShoph5SlideState',
113
112
  routerParam: {
114
113
  slideDirection: 'horizontal',
115
114
  needDisableVertical: `${iosNeedDisableVertical}`,
116
115
  state,
117
116
  },
118
117
  callBackId: new Date().getTime(),
119
118
  },
120
119
  });
121
120
  };
122
121
  const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
123
122
  if (isJdApp) {
124
123
  isIosDevice &&
125
124
  !isAppClassifyPage &&
126
125
  iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
127
126
  isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
128
127
  }
129
128
  };
130
129
 
131
130
  const GetSlideAngle = (dx, dy) => {
132
131
  return (Math.atan2(dy, dx) * 180) / Math.PI;
133
132
  };
134
133
 
135
134
  const GetSlideDirection = (startX, startY, endX, endY) => {
136
135
  const dy = startY - endY;
137
136
  const dx = endX - startX;
138
137
  let result = 0;
139
138
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
140
139
  return result;
141
140
  }
142
141
  const angle = GetSlideAngle(dx, dy);
143
142
  if (angle >= -45 && angle < 45) {
144
143
  result = 4;
145
144
  } else if (angle >= 45 && angle < 135) {
146
145
  result = 1;
147
146
  } else if (angle >= -135 && angle < -45) {
148
147
  result = 2;
149
148
  } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
150
149
  result = 3;
151
150
  }
152
151
  return result;
153
152
  };
154
153
  const changeTouchStart = (e) => {
155
154
  if (isJdApp) {
156
155
  stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
157
156
  if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
158
157
  isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
159
158
  const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
160
159
  mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
161
160
  mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
162
161
  }
163
162
  }
164
163
  };
165
164
  const changeTouchEnd = (e) => {
166
165
  stopNativeScrollEvent(e, TouchType.END);
167
166
  mLastClientPosRef.current.mLastClientX = 0;
168
167
  mLastClientPosRef.current.mLastClientY = 0;
169
168
  };
170
169
  const triggerIosTouchMove = () => {
171
170
  isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
172
171
  };
173
172
 
174
173
  const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
175
174
 
176
175
  const recoverRootEleVerticalScroll = (touchEvent) => {
177
176
  const direction = GetSlideDirection(
178
177
  mLastClientPosRef.current.mLastClientX,
179
178
  mLastClientPosRef.current.mLastClientY,
180
179
  touchEvent.clientX,
181
180
  touchEvent.clientY,
182
181
  );
183
182
  if (direction === 1 || direction === 2) {
184
183
  rootEleNode &&
185
184
  rootEleNode.classList.contains('over-hidden') &&
186
185
  rootEleNode.classList.remove('over-hidden');
187
186
  }
188
187
  };
189
188
  const changeTouchMove = (e) => {
190
189
  if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
191
190
  const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
192
191
  const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
193
192
  2,
194
193
  );
195
194
  const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
196
195
  2,
197
196
  );
198
197
  if (isJdApp) {
199
198
  if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
200
199
  iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
201
200
  } else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
202
201
  console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
203
202
  stopNativeScrollEvent(e, TouchType.END);
204
203
  }
205
204
  }
206
205
  isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
207
206
  }
208
207
  if (!dispatchTouchMove) {
209
208
  return;
210
209
  }
211
210
  const parentNode = e.target?.parentNode;
212
211
  if (!parentNode) {
213
212
  return;
214
213
  }
215
214
  const event = new TouchEvent('touchmove', e);
216
215
  parentNode.dispatchEvent(event);
217
216
  };
218
217
  if (scrollX && isJdApp && !isIgnorePreventNative) {
219
218
  return (
220
219
  <ScrollView
221
220
  scrollX
222
221
  onTouchStart={changeTouchStart}
223
222
  onTouchEnd={changeTouchEnd}
224
223
  onTouchCancel={changeTouchEnd}
225
224
  onTouchMove={changeTouchMove}
226
225
  enhanced
227
226
  showScrollbar={false}
228
227
  style={style}
229
228
  className={classNames(
230
229
  className,
231
230
  {
232
231
  [customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
233
232
  },
234
233
  'J_customScroll',
235
234
  )}
236
235
  {...otherProps}
237
236
  >
238
237
  {children}
239
238
  </ScrollView>
240
239
  );
241
240
  } else {
242
241
  return (
243
242
  <ScrollView
244
243
  scrollX
245
244
  enhanced
246
245
  showScrollbar={false}
247
246
  {...otherProps}
248
247
  className={classNames(
249
248
  className,
250
249
  {
251
250
  [customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
252
251
  isIosDevice && isWxMin && scrollX && style['borderRadius'],
253
252
  },
254
253
  {
255
254
  [customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
256
255
  },
257
256
  {
258
257
  [customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
259
258
  },
260
259
  )}
261
260
  style={style}
262
261
  >
263
262
  {children}
264
263
  </ScrollView>
265
264
  );
266
265
  }
267
266
  style: {},
268
267
  scrollX: false,
269
268
  scrollY: false,
270
269
  scrollWithAnimation: true,
271
270
  iosNeedDisableVertical: false,
272
271
  className: null,
273
272
  dispatchTouchMove: true,
273
+ import React, { useRef, useEffect } from 'react';
274
274
  isH5AndJdShopView,
275
275
  isAndroidDevice,
276
276
  isJdAndAndroidDevice,
277
277
  isJdAndHarmonyDevice,
278
278
  isJdAndIosDevice,
279
279
  isIosDevice,
280
280
  isJdApp,
281
281
  isWxMin,
282
282
  isH5AndJdShopViewH5Scroll,
283
283
  isH5AndJdShopH5CustomScrollView,
284
284
  isH5,
285
285
  isAppClassifyPage,
286
286
  lodashThrottle,
287
287
  START: 'start',
288
288
  MOVE: 'move',
289
289
  END: 'end',
290
290
  const {
291
291
  scrollX,
292
292
  children,
293
293
  style = {},
294
294
  iosNeedDisableVertical,
295
295
  dispatchTouchMove,
296
296
  className,
297
297
  ...otherProps
298
298
  } = props;
299
299
  const rootEleNode = isH5 && document ? document.querySelector('body') : null;
300
300
  const needShowHighVersion =
301
301
  isH5AndJdShopViewH5Scroll &&
302
302
  !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
303
303
  const mLastClientPosRef = useRef({
304
304
  mLastClientX: 0,
305
305
  mLastClientY: 0,
306
306
  });
307
307
  const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
308
308
 
309
309
  const touchstartEventBubbleFunc = (e) => {
310
310
  const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
311
311
  if (!isH5SwiperCustomEle) {
312
312
  const hasCustomEle = e
313
313
  ? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
314
314
  : false;
315
315
  if (isJdAndAndroidDevice && !hasCustomEle) {
316
316
  window?.JdAndroid &&
317
317
  window?.JdAndroid?.requestEvent &&
318
318
  window.JdAndroid.requestEvent(false);
319
319
  }
320
320
  !hasCustomEle &&
321
321
  rootEleNode &&
322
322
  rootEleNode.classList.contains('over-hidden') &&
323
323
  rootEleNode.classList.remove('over-hidden');
324
324
  console.log(
325
325
  'customScrollView所在页面document touch start事件是否有J_customScroll元素',
326
326
  hasCustomEle,
327
327
  '根元素是否有over-hidden',
328
328
  rootEleNode.classList,
329
329
  );
330
330
  }
331
331
  };
332
332
  const touchstartEventCaptureFunc = (e) => {
333
333
  if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
334
334
  rootEleNode &&
335
335
  rootEleNode.classList.contains('over-hidden') &&
336
336
  rootEleNode.classList.remove('over-hidden');
337
337
  console.log(
338
338
  'customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden',
339
339
  rootEleNode.classList,
340
340
  );
341
341
  }
342
342
  };
343
343
  useEffect(() => {
344
344
  isJdApp &&
345
345
  !window.JDJshopViewInfo.getAndroidTouchSlopState &&
346
346
  nativePageGetScaledTouchSlop((res) => {
347
347
  console.log('获取安卓系统滑动阈值', res);
348
348
  window.JDJshopViewInfo.androidTouchSlop = res;
349
349
  window.JDJshopViewInfo.getAndroidTouchSlopState = true;
350
350
  });
351
351
  if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
352
352
  global?.removeJdAndroidRquestEventForTouchStart &&
353
353
  global.removeJdAndroidRquestEventForTouchStart();
354
354
  rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
355
355
 
356
356
  rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
357
357
  rootEleAddEventListenerState = true;
358
358
  console.log('customScrollView 初始化document监听完成');
359
359
  }
360
360
  return () => {
361
361
  if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
362
362
  rootEleNode.classList.contains('over-hidden') &&
363
363
  rootEleNode.classList.remove('over-hidden');
364
364
  rootEleAddEventListenerState = false;
365
365
  console.log('customScrollView document监听取消完成');
366
366
  rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
367
367
  rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
368
368
  }
369
369
  };
370
370
  }, []);
371
371
 
372
372
  const androidDeviceStopNativeScrollEvent = (touchType) => {
373
373
  isJdApp &&
374
374
  isAndroidDevice &&
375
375
  window?.JdAndroid &&
376
376
  window?.JdAndroid?.requestEvent &&
377
377
  window.JdAndroid.requestEvent(touchType === TouchType.START);
378
378
  console.log('触发window?.JdAndroid.requestEvent', touchType === TouchType.START, touchType);
379
379
  };
380
380
  const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
381
381
  sendIosState && iosDeviceSendRouter(touchType);
382
382
  };
383
383
 
384
384
  const iosDeviceSendRouter = (state: string) => {
385
385
  window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
386
386
  method: 'callRouterModuleWithParams',
387
387
  params: {
388
388
  routerURL: 'router://JDShopModule/processShoph5SlideState',
389
389
  routerParam: {
390
390
  slideDirection: 'horizontal',
391
391
  needDisableVertical: `${iosNeedDisableVertical}`,
392
392
  state,
393
393
  },
394
394
  callBackId: new Date().getTime(),
395
395
  },
396
396
  });
397
397
  };
398
398
  const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
399
399
  if (isJdApp) {
400
400
  isIosDevice &&
401
401
  !isAppClassifyPage &&
402
402
  iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
403
403
  isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
404
404
  }
405
405
  };
406
406
 
407
407
  const GetSlideAngle = (dx, dy) => {
408
408
  return (Math.atan2(dy, dx) * 180) / Math.PI;
409
409
  };
410
410
 
411
411
  const GetSlideDirection = (startX, startY, endX, endY) => {
412
412
  const dy = startY - endY;
413
413
  const dx = endX - startX;
414
414
  let result = 0;
415
415
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
416
416
  return result;
417
417
  }
418
418
  const angle = GetSlideAngle(dx, dy);
419
419
  if (angle >= -45 && angle < 45) {
420
420
  result = 4;
421
421
  } else if (angle >= 45 && angle < 135) {
422
422
  result = 1;
423
423
  } else if (angle >= -135 && angle < -45) {
424
424
  result = 2;
425
425
  } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
426
426
  result = 3;
427
427
  }
428
428
  return result;
429
429
  };
430
430
  const changeTouchStart = (e) => {
431
431
  if (isJdApp) {
432
432
  stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
433
433
  if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
434
434
  isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
435
435
  const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
436
436
  mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
437
437
  mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
438
438
  }
439
439
  }
440
440
  };
441
441
  const changeTouchEnd = (e) => {
442
442
  stopNativeScrollEvent(e, TouchType.END);
443
443
  mLastClientPosRef.current.mLastClientX = 0;
444
444
  mLastClientPosRef.current.mLastClientY = 0;
445
445
  };
446
446
  const triggerIosTouchMove = () => {
447
447
  isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
448
448
  };
449
449
 
450
450
  const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
451
451
 
452
452
  const recoverRootEleVerticalScroll = (touchEvent) => {
453
453
  const direction = GetSlideDirection(
454
454
  mLastClientPosRef.current.mLastClientX,
455
455
  mLastClientPosRef.current.mLastClientY,
456
456
  touchEvent.clientX,
457
457
  touchEvent.clientY,
458
458
  );
459
459
  if (direction === 1 || direction === 2) {
460
460
  rootEleNode &&
461
461
  rootEleNode.classList.contains('over-hidden') &&
462
462
  rootEleNode.classList.remove('over-hidden');
463
463
  }
464
464
  };
465
465
  const changeTouchMove = (e) => {
466
466
  if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
467
467
  const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
468
468
  const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
469
469
  2,
470
470
  );
471
471
  const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
472
472
  2,
473
473
  );
474
474
  if (isJdApp) {
475
475
  if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
476
476
  iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
477
477
  } else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
478
478
  console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
479
479
  stopNativeScrollEvent(e, TouchType.END);
480
480
  }
481
481
  }
482
482
  isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
483
483
  }
484
484
  if (!dispatchTouchMove) {
485
485
  return;
486
486
  }
487
487
  const parentNode = e.target?.parentNode;
488
488
  if (!parentNode) {
489
489
  return;
490
490
  }
491
491
  const event = new TouchEvent('touchmove', e);
492
492
  parentNode.dispatchEvent(event);
493
493
  };
494
494
  if (scrollX && isJdApp && !isIgnorePreventNative) {
495
495
  return (
496
496
  <ScrollView
497
497
  scrollX
498
498
  onTouchStart={changeTouchStart}
499
499
  onTouchEnd={changeTouchEnd}
500
500
  onTouchCancel={changeTouchEnd}
501
501
  onTouchMove={changeTouchMove}
502
502
  enhanced
503
503
  showScrollbar={false}
504
504
  style={style}
505
505
  className={classNames(
506
506
  className,
507
507
  {
508
508
  [customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
509
509
  },
510
510
  'J_customScroll',
511
511
  )}
512
512
  {...otherProps}
513
513
  >
514
514
  {children}
515
515
  </ScrollView>
516
516
  );
517
517
  } else {
518
518
  return (
519
519
  <ScrollView
520
520
  scrollX
521
521
  enhanced
522
522
  showScrollbar={false}
523
523
  {...otherProps}
524
524
  className={classNames(
525
525
  className,
526
526
  {
527
527
  [customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
528
528
  isIosDevice && isWxMin && scrollX && style['borderRadius'],
529
529
  },
530
530
  {
531
531
  [customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
532
532
  },
533
533
  {
534
534
  [customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
535
535
  },
536
536
  )}
537
537
  style={style}
538
538
  >
539
539
  {children}
540
540
  </ScrollView>
541
541
  );
542
542
  }
543
543
  style: {},
544
544
  scrollX: false,
545
545
  scrollY: false,
546
546
  scrollWithAnimation: true,
547
547
  iosNeedDisableVertical: false,
548
548
  className: null,
549
549
  dispatchTouchMove: true,