@conecli/cone-render 0.10.1-isv2.2 → 0.10.1-isv3.1

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