@conecli/cone-render 0.10.1-beta.7 → 0.10.1-beta.9
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.
- package/dist/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/wxappApi.ts +1 -1
- package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +11 -0
- package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +4 -8
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -53
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/device.ts +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/sass/app.h5.scss +255 -224
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -1
- package/dist/service/requestServer.h5.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
- package/dist/utils/jumpExtMapUtil.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
- package/dist/wxapp/common/user_info.js +1 -1
- package/package.json +147 -141
|
@@ -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
|
isJdAndIosDevice,
|
|
299
299
|
isIosDevice,
|
|
300
300
|
isJdApp,
|
|
301
301
|
isWxMin,
|
|
302
302
|
isH5AndJdShopViewH5Scroll,
|
|
303
303
|
isH5AndJdShopH5CustomScrollView,
|
|
304
304
|
isH5,
|
|
305
305
|
isAppClassifyPage,
|
|
306
306
|
lodashThrottle,
|
|
307
307
|
START: 'start',
|
|
308
308
|
MOVE: 'move',
|
|
309
309
|
END: 'end',
|
|
310
310
|
'当前业务是否忽略原生阻止底层滚动',
|
|
311
311
|
isIgnorePreventNative,
|
|
312
312
|
ignoreBuildTypeList,
|
|
313
313
|
newBuildType,
|
|
314
314
|
const { scrollX, children, style = {}, iosNeedDisableVertical, className, ...otherProps } = props;
|
|
315
315
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null;
|
|
316
316
|
const needShowHighVersion =
|
|
317
317
|
isH5AndJdShopViewH5Scroll &&
|
|
318
318
|
!(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
|
|
319
319
|
const mLastClientPosRef = useRef({
|
|
320
320
|
mLastClientX: 0,
|
|
321
321
|
mLastClientY: 0,
|
|
322
322
|
});
|
|
323
323
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
|
|
324
324
|
|
|
325
325
|
const touchstartEventBubbleFunc = (e) => {
|
|
326
326
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
327
327
|
if (!isH5SwiperCustomEle) {
|
|
328
328
|
const hasCustomEle = e
|
|
329
329
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
330
330
|
: false;
|
|
331
331
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
332
332
|
window?.JdAndroid &&
|
|
333
333
|
window?.JdAndroid?.requestEvent &&
|
|
334
334
|
window.JdAndroid.requestEvent(false);
|
|
335
335
|
}
|
|
336
336
|
!hasCustomEle &&
|
|
337
337
|
rootEleNode &&
|
|
338
338
|
rootEleNode.classList.contains('over-hidden') &&
|
|
339
339
|
rootEleNode.classList.remove('over-hidden');
|
|
340
340
|
console.log(
|
|
341
341
|
'customScrollView所在页面document touch start事件是否有J_customScroll元素',
|
|
342
342
|
hasCustomEle,
|
|
343
343
|
'根元素是否有over-hidden',
|
|
344
344
|
rootEleNode.classList,
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
347
|
};
|
|
348
348
|
const touchstartEventCaptureFunc = (e) => {
|
|
349
349
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
|
|
350
350
|
rootEleNode &&
|
|
351
351
|
rootEleNode.classList.contains('over-hidden') &&
|
|
352
352
|
rootEleNode.classList.remove('over-hidden');
|
|
353
353
|
console.log(
|
|
354
354
|
'customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden',
|
|
355
355
|
rootEleNode.classList,
|
|
356
356
|
);
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
useEffect(() => {
|
|
360
360
|
isJdApp &&
|
|
361
361
|
!window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
362
362
|
nativePageGetScaledTouchSlop((res) => {
|
|
363
363
|
console.log('获取安卓系统滑动阈值', res);
|
|
364
364
|
window.JDJshopViewInfo.androidTouchSlop = res;
|
|
365
365
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true;
|
|
366
366
|
});
|
|
367
367
|
if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
|
|
368
368
|
global?.removeJdAndroidRquestEventForTouchStart &&
|
|
369
369
|
global.removeJdAndroidRquestEventForTouchStart();
|
|
370
370
|
rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
371
371
|
|
|
372
372
|
rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
373
373
|
rootEleAddEventListenerState = true;
|
|
374
374
|
console.warn('customScrollView 初始化document监听完成');
|
|
375
375
|
}
|
|
376
376
|
return () => {
|
|
377
377
|
if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
|
|
378
378
|
console.warn('customScrollView document监听取消完成');
|
|
379
379
|
rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
380
380
|
rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
383
|
}, []);
|
|
384
384
|
|
|
385
385
|
const androidDeviceStopNativeScrollEvent = (touchType) => {
|
|
386
386
|
isJdApp &&
|
|
387
387
|
isAndroidDevice &&
|
|
388
388
|
window?.JdAndroid &&
|
|
389
389
|
window?.JdAndroid?.requestEvent &&
|
|
390
390
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
391
391
|
console.log('触发window?.JdAndroid.requestEvent', touchType === TouchType.START, touchType);
|
|
392
392
|
};
|
|
393
393
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
394
394
|
e && e.stopPropagation();
|
|
395
395
|
sendIosState && iosDeviceSendRouter(touchType);
|
|
396
396
|
};
|
|
397
397
|
const iosDeviceSendRouter = (state) => {
|
|
398
398
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
399
399
|
method: 'callRouterModuleWithParams',
|
|
400
400
|
params: {
|
|
401
401
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
402
402
|
routerParam: {
|
|
403
403
|
slideDirection: 'horizontal',
|
|
404
404
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
405
405
|
state,
|
|
406
406
|
},
|
|
407
407
|
callBackId: new Date().getTime(),
|
|
408
408
|
},
|
|
409
409
|
});
|
|
410
410
|
};
|
|
411
411
|
const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
|
|
412
412
|
if (isJdApp) {
|
|
413
413
|
isIosDevice &&
|
|
414
414
|
!isAppClassifyPage &&
|
|
415
415
|
iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
|
|
416
416
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
|
|
417
417
|
console.log(
|
|
418
418
|
'当前customScrollView touch事件',
|
|
419
419
|
touchType,
|
|
420
420
|
e,
|
|
421
421
|
'是否是e instanceof CustomEvent',
|
|
422
422
|
e instanceof CustomEvent,
|
|
423
423
|
);
|
|
424
424
|
}
|
|
425
425
|
};
|
|
426
426
|
const GetSlideAngle = (dx, dy) => {
|
|
427
427
|
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
428
428
|
};
|
|
429
429
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
430
430
|
const dy = startY - endY;
|
|
431
431
|
const dx = endX - startX;
|
|
432
432
|
let result = 0;
|
|
433
433
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
434
434
|
return result;
|
|
435
435
|
}
|
|
436
436
|
const angle = GetSlideAngle(dx, dy);
|
|
437
437
|
if (angle >= -45 && angle < 45) {
|
|
438
438
|
result = 4;
|
|
439
439
|
} else if (angle >= 45 && angle < 135) {
|
|
440
440
|
result = 1;
|
|
441
441
|
} else if (angle >= -135 && angle < -45) {
|
|
442
442
|
result = 2;
|
|
443
443
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
444
444
|
result = 3;
|
|
445
445
|
}
|
|
446
446
|
return result;
|
|
447
447
|
};
|
|
448
448
|
const changeTouchStart = (e) => {
|
|
449
449
|
if (isJdApp) {
|
|
450
450
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
|
|
451
451
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
452
452
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
453
453
|
console.info(
|
|
454
454
|
'customScrollView touchstart 当前根元素是否添加还是删除over-hidden',
|
|
455
455
|
TouchType.START,
|
|
456
456
|
rootEleNode.classList,
|
|
457
457
|
);
|
|
458
458
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
459
459
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
|
|
460
460
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
|
|
461
461
|
console.log('ustomScrollView touchstart 获取mLastClientPosRef', mLastClientPosRef);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
};
|
|
465
465
|
const changeTouchEnd = (e) => {
|
|
466
466
|
stopNativeScrollEvent(e, TouchType.END);
|
|
467
467
|
mLastClientPosRef.current.mLastClientX = 0;
|
|
468
468
|
mLastClientPosRef.current.mLastClientY = 0;
|
|
469
469
|
console.log('ustomScrollView touchend 获取mLastClientPosRef', mLastClientPosRef);
|
|
470
470
|
};
|
|
471
471
|
const triggerIosTouchMove = () => {
|
|
472
472
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
|
|
473
473
|
};
|
|
474
474
|
|
|
475
475
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
|
|
476
476
|
|
|
477
477
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
478
478
|
const direction = GetSlideDirection(
|
|
479
479
|
mLastClientPosRef.current.mLastClientX,
|
|
480
480
|
mLastClientPosRef.current.mLastClientY,
|
|
481
481
|
touchEvent.clientX,
|
|
482
482
|
touchEvent.clientY,
|
|
483
483
|
);
|
|
484
484
|
if (direction === 1 || direction === 2) {
|
|
485
485
|
rootEleNode &&
|
|
486
486
|
rootEleNode.classList.contains('over-hidden') &&
|
|
487
487
|
rootEleNode.classList.remove('over-hidden');
|
|
488
488
|
}
|
|
489
489
|
console.log(
|
|
490
490
|
'获取当前滚动方向,向上向下1、2',
|
|
491
491
|
direction,
|
|
492
492
|
'根元素的classList',
|
|
493
493
|
rootEleNode.classList,
|
|
494
494
|
'mLastClientPosRef.current.mLastClientX',
|
|
495
495
|
mLastClientPosRef.current.mLastClientX,
|
|
496
496
|
);
|
|
497
497
|
};
|
|
498
498
|
const changeTouchMove = (e) => {
|
|
499
499
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
500
500
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
501
501
|
const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
|
|
502
502
|
2,
|
|
503
503
|
);
|
|
504
504
|
const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
|
|
505
505
|
2,
|
|
506
506
|
);
|
|
507
507
|
if (isJdApp) {
|
|
508
508
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
509
509
|
console.log(
|
|
510
510
|
'横向滚动触发',
|
|
511
511
|
xDiff,
|
|
512
512
|
touchEvent,
|
|
513
513
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
514
514
|
'iosNeedDisableVertical',
|
|
515
515
|
iosNeedDisableVertical,
|
|
516
516
|
);
|
|
517
517
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
|
|
518
518
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
519
519
|
console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
|
|
520
520
|
stopNativeScrollEvent(e, TouchType.END);
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
526
|
if (scrollX && isJdApp && !isIgnorePreventNative) {
|
|
527
527
|
return (
|
|
528
528
|
<ScrollView
|
|
529
529
|
scrollX
|
|
530
530
|
onTouchStart={changeTouchStart}
|
|
531
531
|
onTouchEnd={changeTouchEnd}
|
|
532
532
|
onTouchCancel={changeTouchEnd}
|
|
533
533
|
onTouchMove={changeTouchMove}
|
|
534
534
|
enhanced
|
|
535
535
|
showScrollbar={false}
|
|
536
536
|
style={style}
|
|
537
537
|
className={classNames(
|
|
538
538
|
className,
|
|
539
539
|
{
|
|
540
540
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
541
541
|
},
|
|
542
542
|
'J_customScroll',
|
|
543
543
|
)}
|
|
544
544
|
{...otherProps}
|
|
545
545
|
>
|
|
546
546
|
{children}
|
|
547
547
|
</ScrollView>
|
|
548
548
|
);
|
|
549
549
|
} else {
|
|
550
550
|
return (
|
|
551
551
|
<ScrollView
|
|
552
552
|
scrollX
|
|
553
553
|
enhanced
|
|
554
554
|
showScrollbar={false}
|
|
555
555
|
{...otherProps}
|
|
556
556
|
className={classNames(
|
|
557
557
|
className,
|
|
558
558
|
{
|
|
559
559
|
[customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
|
|
560
560
|
isIosDevice && isWxMin && scrollX && style['borderRadius'],
|
|
561
561
|
},
|
|
562
562
|
{
|
|
563
563
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
564
564
|
},
|
|
565
565
|
{
|
|
566
566
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
|
|
567
567
|
},
|
|
568
568
|
)}
|
|
569
569
|
style={style}
|
|
570
570
|
>
|
|
571
571
|
{children}
|
|
572
572
|
</ScrollView>
|
|
573
573
|
);
|
|
574
574
|
}
|
|
575
575
|
style: {},
|
|
576
576
|
scrollX: false,
|
|
577
577
|
scrollY: false,
|
|
578
578
|
scrollWithAnimation: true,
|
|
579
579
|
iosNeedDisableVertical: false,
|
|
580
580
|
className: null,
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
left: 0;
|
|
7
7
|
right: 0;
|
|
8
8
|
bottom: 0;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
opacity: 0;
|
|
10
|
+
pointer-events: none;
|
|
11
11
|
z-index: -1;
|
|
12
12
|
}
|
|
13
13
|
//楼层曝光
|
|
@@ -20,3 +20,13 @@
|
|
|
20
20
|
pointer-events: none;
|
|
21
21
|
z-index: -1;
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
:global{
|
|
25
|
+
.d-report-exposure-jd-point{
|
|
26
|
+
&:not(:empty){
|
|
27
|
+
opacity: 1;
|
|
28
|
+
z-index: 20;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|