@conecli/cone-render 0.10.1-isv2.2 → 0.10.1-isv2.4
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/jssdk.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-back.tsx +1 -0
- 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/InViewRender/index.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/debug/DebugLayout/index.module.scss +2 -2
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/interface/common.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.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/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 +273 -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/log.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- 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 +158 -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
|
const {
|
|
311
311
|
scrollX,
|
|
312
312
|
children,
|
|
313
313
|
style = {},
|
|
314
314
|
iosNeedDisableVertical,
|
|
315
315
|
dispatchTouchMove,
|
|
316
316
|
className,
|
|
317
317
|
...otherProps
|
|
318
318
|
} = props;
|
|
319
319
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null;
|
|
320
320
|
const needShowHighVersion =
|
|
321
321
|
isH5AndJdShopViewH5Scroll &&
|
|
322
322
|
!(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
|
|
323
323
|
const mLastClientPosRef = useRef({
|
|
324
324
|
mLastClientX: 0,
|
|
325
325
|
mLastClientY: 0,
|
|
326
326
|
});
|
|
327
327
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
|
|
328
328
|
|
|
329
329
|
const touchstartEventBubbleFunc = (e) => {
|
|
330
330
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
331
331
|
if (!isH5SwiperCustomEle) {
|
|
332
332
|
const hasCustomEle = e
|
|
333
333
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
334
334
|
: false;
|
|
335
335
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
336
336
|
window?.JdAndroid &&
|
|
337
337
|
window?.JdAndroid?.requestEvent &&
|
|
338
338
|
window.JdAndroid.requestEvent(false);
|
|
339
339
|
}
|
|
340
340
|
!hasCustomEle &&
|
|
341
341
|
rootEleNode &&
|
|
342
342
|
rootEleNode.classList.contains('over-hidden') &&
|
|
343
343
|
rootEleNode.classList.remove('over-hidden');
|
|
344
344
|
console.log(
|
|
345
345
|
'customScrollView所在页面document touch start事件是否有J_customScroll元素',
|
|
346
346
|
hasCustomEle,
|
|
347
347
|
'根元素是否有over-hidden',
|
|
348
348
|
rootEleNode.classList,
|
|
349
349
|
);
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
const touchstartEventCaptureFunc = (e) => {
|
|
353
353
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
|
|
354
354
|
rootEleNode &&
|
|
355
355
|
rootEleNode.classList.contains('over-hidden') &&
|
|
356
356
|
rootEleNode.classList.remove('over-hidden');
|
|
357
357
|
console.log(
|
|
358
358
|
'customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden',
|
|
359
359
|
rootEleNode.classList,
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
};
|
|
363
363
|
useEffect(() => {
|
|
364
364
|
isJdApp &&
|
|
365
365
|
!window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
366
366
|
nativePageGetScaledTouchSlop((res) => {
|
|
367
367
|
console.log('获取安卓系统滑动阈值', res);
|
|
368
368
|
window.JDJshopViewInfo.androidTouchSlop = res;
|
|
369
369
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true;
|
|
370
370
|
});
|
|
371
371
|
if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
|
|
372
372
|
global?.removeJdAndroidRquestEventForTouchStart &&
|
|
373
373
|
global.removeJdAndroidRquestEventForTouchStart();
|
|
374
374
|
rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
375
375
|
|
|
376
376
|
rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
377
377
|
rootEleAddEventListenerState = true;
|
|
378
378
|
console.log('customScrollView 初始化document监听完成');
|
|
379
379
|
}
|
|
380
380
|
return () => {
|
|
381
381
|
if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
|
|
382
382
|
console.log('customScrollView document监听取消完成');
|
|
383
383
|
rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
384
384
|
rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
385
385
|
}
|
|
386
386
|
};
|
|
387
387
|
}, []);
|
|
388
388
|
|
|
389
389
|
const androidDeviceStopNativeScrollEvent = (touchType) => {
|
|
390
390
|
isJdApp &&
|
|
391
391
|
isAndroidDevice &&
|
|
392
392
|
window?.JdAndroid &&
|
|
393
393
|
window?.JdAndroid?.requestEvent &&
|
|
394
394
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
395
395
|
console.log('触发window?.JdAndroid.requestEvent', touchType === TouchType.START, touchType);
|
|
396
396
|
};
|
|
397
397
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
398
398
|
sendIosState && iosDeviceSendRouter(touchType);
|
|
399
399
|
};
|
|
400
400
|
|
|
401
401
|
const iosDeviceSendRouter = (state: string) => {
|
|
402
402
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
403
403
|
method: 'callRouterModuleWithParams',
|
|
404
404
|
params: {
|
|
405
405
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
406
406
|
routerParam: {
|
|
407
407
|
slideDirection: 'horizontal',
|
|
408
408
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
409
409
|
state,
|
|
410
410
|
},
|
|
411
411
|
callBackId: new Date().getTime(),
|
|
412
412
|
},
|
|
413
413
|
});
|
|
414
414
|
};
|
|
415
415
|
const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
|
|
416
416
|
if (isJdApp) {
|
|
417
417
|
isIosDevice &&
|
|
418
418
|
!isAppClassifyPage &&
|
|
419
419
|
iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
|
|
420
420
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
|
|
424
424
|
const GetSlideAngle = (dx, dy) => {
|
|
425
425
|
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
426
426
|
};
|
|
427
427
|
|
|
428
428
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
429
429
|
const dy = startY - endY;
|
|
430
430
|
const dx = endX - startX;
|
|
431
431
|
let result = 0;
|
|
432
432
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
433
433
|
return result;
|
|
434
434
|
}
|
|
435
435
|
const angle = GetSlideAngle(dx, dy);
|
|
436
436
|
if (angle >= -45 && angle < 45) {
|
|
437
437
|
result = 4;
|
|
438
438
|
} else if (angle >= 45 && angle < 135) {
|
|
439
439
|
result = 1;
|
|
440
440
|
} else if (angle >= -135 && angle < -45) {
|
|
441
441
|
result = 2;
|
|
442
442
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
443
443
|
result = 3;
|
|
444
444
|
}
|
|
445
445
|
return result;
|
|
446
446
|
};
|
|
447
447
|
const changeTouchStart = (e) => {
|
|
448
448
|
if (isJdApp) {
|
|
449
449
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
|
|
450
450
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
451
451
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
452
452
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
453
453
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
|
|
454
454
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
458
|
const changeTouchEnd = (e) => {
|
|
459
459
|
stopNativeScrollEvent(e, TouchType.END);
|
|
460
460
|
mLastClientPosRef.current.mLastClientX = 0;
|
|
461
461
|
mLastClientPosRef.current.mLastClientY = 0;
|
|
462
462
|
};
|
|
463
463
|
const triggerIosTouchMove = () => {
|
|
464
464
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
|
|
465
465
|
};
|
|
466
466
|
|
|
467
467
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
|
|
468
468
|
|
|
469
469
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
470
470
|
const direction = GetSlideDirection(
|
|
471
471
|
mLastClientPosRef.current.mLastClientX,
|
|
472
472
|
mLastClientPosRef.current.mLastClientY,
|
|
473
473
|
touchEvent.clientX,
|
|
474
474
|
touchEvent.clientY,
|
|
475
475
|
);
|
|
476
476
|
if (direction === 1 || direction === 2) {
|
|
477
477
|
rootEleNode &&
|
|
478
478
|
rootEleNode.classList.contains('over-hidden') &&
|
|
479
479
|
rootEleNode.classList.remove('over-hidden');
|
|
480
480
|
}
|
|
481
481
|
};
|
|
482
482
|
const changeTouchMove = (e) => {
|
|
483
483
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
484
484
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
485
485
|
const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
|
|
486
486
|
2,
|
|
487
487
|
);
|
|
488
488
|
const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
|
|
489
489
|
2,
|
|
490
490
|
);
|
|
491
491
|
if (isJdApp) {
|
|
492
492
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
493
493
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
|
|
494
494
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
495
495
|
console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
|
|
496
496
|
stopNativeScrollEvent(e, TouchType.END);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
|
|
500
500
|
}
|
|
501
501
|
if (!dispatchTouchMove) {
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
504
504
|
const parentNode = e.target?.parentNode;
|
|
505
505
|
if (!parentNode) {
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
508
508
|
const event = new TouchEvent('touchmove', e);
|
|
509
509
|
parentNode.dispatchEvent(event);
|
|
510
510
|
};
|
|
511
511
|
if (scrollX && isJdApp && !isIgnorePreventNative) {
|
|
512
512
|
return (
|
|
513
513
|
<ScrollView
|
|
514
514
|
scrollX
|
|
515
515
|
onTouchStart={changeTouchStart}
|
|
516
516
|
onTouchEnd={changeTouchEnd}
|
|
517
517
|
onTouchCancel={changeTouchEnd}
|
|
518
518
|
onTouchMove={changeTouchMove}
|
|
519
519
|
enhanced
|
|
520
520
|
showScrollbar={false}
|
|
521
521
|
style={style}
|
|
522
522
|
className={classNames(
|
|
523
523
|
className,
|
|
524
524
|
{
|
|
525
525
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
526
526
|
},
|
|
527
527
|
'J_customScroll',
|
|
528
528
|
)}
|
|
529
529
|
{...otherProps}
|
|
530
530
|
>
|
|
531
531
|
{children}
|
|
532
532
|
</ScrollView>
|
|
533
533
|
);
|
|
534
534
|
} else {
|
|
535
535
|
return (
|
|
536
536
|
<ScrollView
|
|
537
537
|
scrollX
|
|
538
538
|
enhanced
|
|
539
539
|
showScrollbar={false}
|
|
540
540
|
{...otherProps}
|
|
541
541
|
className={classNames(
|
|
542
542
|
className,
|
|
543
543
|
{
|
|
544
544
|
[customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
|
|
545
545
|
isIosDevice && isWxMin && scrollX && style['borderRadius'],
|
|
546
546
|
},
|
|
547
547
|
{
|
|
548
548
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
549
549
|
},
|
|
550
550
|
{
|
|
551
551
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
|
|
552
552
|
},
|
|
553
553
|
)}
|
|
554
554
|
style={style}
|
|
555
555
|
>
|
|
556
556
|
{children}
|
|
557
557
|
</ScrollView>
|
|
558
558
|
);
|
|
559
559
|
}
|
|
560
560
|
style: {},
|
|
561
561
|
scrollX: false,
|
|
562
562
|
scrollY: false,
|
|
563
563
|
scrollWithAnimation: true,
|
|
564
564
|
iosNeedDisableVertical: false,
|
|
565
565
|
className: null,
|
|
566
566
|
dispatchTouchMove: true,
|
|
@@ -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
|
+
|