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