@conecli/cone-render 0.8.44 → 0.8.46-beta.0
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/assets/icon_blue_info.svg +1 -0
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.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/pageType.ts +1 -1
- package/dist/common/sgmCustomCode.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/CountDown/index.module.scss +49 -44
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/common.ts +1 -0
- package/dist/components/base/CustomVideo/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/ItemViewExposureSmart/index.module.scss +2 -2
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +4 -0
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +8 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +67 -0
- package/dist/components/debug/DebugLayout/index.tsx +1 -0
- package/dist/components/debug/DebugLayout/utils.ts +1 -0
- 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/floorItem.weapp.tsx +1 -1
- package/dist/components/isv/Floor/index.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.jd.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.jdb.ts +1 -1
- package/dist/jumpEventReport/web.jdjch.ts +1 -1
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
- package/dist/jumpEventReport/web.pc.ts +1 -1
- package/dist/jumpEventReport/web.tjapp.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/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/sass/base.scss +183 -137
- 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 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- 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/connectNativeJsBridge.weapp.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/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 -123
- package/dist/utils/memberFormatUtils.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 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
|
console.log("触发window?.JdAndroid.requestEvent",touchType === TouchType.START,touchType)
|
|
78
77
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
79
78
|
e && e.stopPropagation()
|
|
80
79
|
sendIosState && iosDeviceSendRouter(touchType)
|
|
81
80
|
}
|
|
82
81
|
const iosDeviceSendRouter = (state) => {
|
|
83
82
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
84
83
|
method: 'callRouterModuleWithParams',
|
|
85
84
|
params: {
|
|
86
85
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
87
86
|
routerParam: {
|
|
88
87
|
slideDirection: 'horizontal',
|
|
89
88
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
90
89
|
state,
|
|
91
90
|
},
|
|
92
91
|
callBackId: new Date().getTime(),
|
|
93
92
|
},
|
|
94
93
|
})
|
|
95
94
|
}
|
|
96
95
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType)
|
|
97
96
|
console.log("当前customScrollView touch事件", touchType, e, "是否是e instanceof CustomEvent", e instanceof CustomEvent)
|
|
98
97
|
const GetSlideAngle = (dx,dy) => {
|
|
99
98
|
return Math.atan2(dy,dx) * 180 / Math.PI;
|
|
100
99
|
}
|
|
101
100
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
102
101
|
const dy = startY - endY
|
|
103
102
|
const dx = endX - startX
|
|
104
103
|
let result = 0
|
|
105
104
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
106
105
|
return result
|
|
107
106
|
}
|
|
108
107
|
const angle = GetSlideAngle(dx, dy)
|
|
109
108
|
if (angle >= -45 && angle < 45) {
|
|
110
109
|
result = 4
|
|
111
110
|
} else if (angle >= 45 && angle < 135) {
|
|
112
111
|
result = 1
|
|
113
112
|
} else if (angle >= -135 && angle < -45) {
|
|
114
113
|
result = 2
|
|
115
114
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
116
115
|
result = 3
|
|
117
116
|
}
|
|
118
117
|
return result
|
|
119
118
|
}
|
|
120
119
|
if(isJdApp){
|
|
121
120
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical)
|
|
122
121
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
123
122
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden')
|
|
124
123
|
console.info("customScrollView touchstart 当前根元素是否添加还是删除over-hidden",TouchType.START,rootEleNode.classList)
|
|
125
124
|
const touchEvent =
|
|
126
125
|
e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
|
|
127
126
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX
|
|
128
127
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY
|
|
129
128
|
console.log('ustomScrollView touchstart 获取mLastClientPosRef', mLastClientPosRef)
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
stopNativeScrollEvent(e,TouchType.END)
|
|
133
132
|
mLastClientPosRef.current.mLastClientX = 0
|
|
134
133
|
mLastClientPosRef.current.mLastClientY = 0
|
|
135
134
|
console.log('ustomScrollView touchend 获取mLastClientPosRef', mLastClientPosRef)
|
|
136
135
|
const triggerIosTouchMove = () => {
|
|
137
136
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null,TouchType.START, true)
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(
|
|
141
140
|
triggerIosTouchMove,
|
|
142
141
|
500,
|
|
143
142
|
)
|
|
144
143
|
|
|
145
144
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
146
145
|
const direction = GetSlideDirection(mLastClientPosRef.current.mLastClientX, mLastClientPosRef.current.mLastClientY, touchEvent.clientX, touchEvent.clientY)
|
|
147
146
|
if (direction === 1 || direction === 2) {
|
|
148
147
|
rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
|
|
149
148
|
}
|
|
150
149
|
console.log("获取当前滚动方向,向上向下1、2",direction,'根元素的classList',rootEleNode.classList,'mLastClientPosRef.current.mLastClientX',mLastClientPosRef.current.mLastClientX)
|
|
151
150
|
}
|
|
152
151
|
const touchEvent =
|
|
153
152
|
e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
|
|
154
153
|
const xDiff = Math.abs(
|
|
155
154
|
touchEvent.clientX - mLastClientPosRef.current.mLastClientX,
|
|
156
155
|
).toFixed(2)
|
|
157
156
|
const yDiff = Math.abs(
|
|
158
157
|
touchEvent.clientY - mLastClientPosRef.current.mLastClientY,
|
|
159
158
|
).toFixed(2)
|
|
160
159
|
if(isJdApp) {
|
|
161
160
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
162
161
|
console.log(
|
|
163
162
|
'横向滚动触发',
|
|
164
163
|
xDiff,
|
|
165
164
|
touchEvent,
|
|
166
165
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
167
166
|
"iosNeedDisableVertical",
|
|
168
167
|
iosNeedDisableVertical
|
|
169
168
|
)
|
|
170
169
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove()
|
|
171
170
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
172
171
|
console.log(
|
|
173
172
|
'纵向滚动触发',
|
|
174
173
|
yDiff,
|
|
175
174
|
touchEvent,
|
|
176
175
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
177
176
|
)
|
|
178
177
|
stopNativeScrollEvent(e,TouchType.END)
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
180
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent)
|
|
182
181
|
<ScrollView
|
|
183
182
|
scrollX
|
|
184
183
|
onTouchStart={changeTouchStart}
|
|
185
184
|
onTouchEnd={changeTouchEnd}
|
|
186
185
|
onTouchCancel={changeTouchEnd}
|
|
187
186
|
onTouchMove={changeTouchMove}
|
|
188
187
|
enhanced
|
|
189
188
|
showScrollbar={false}
|
|
190
189
|
style={style}
|
|
191
190
|
className={classNames(className, {
|
|
192
191
|
[customScrollViewStyle[
|
|
193
192
|
'd-custom-ios-h5-extend-border-radius'
|
|
194
193
|
]]: isIosDevice,
|
|
195
194
|
}, 'J_customScroll')}
|
|
196
195
|
{...otherProps}
|
|
197
196
|
>
|
|
198
197
|
{children}
|
|
199
198
|
</ScrollView>
|
|
200
199
|
)
|
|
201
200
|
} else {
|
|
202
201
|
return (
|
|
203
202
|
<ScrollView
|
|
204
203
|
scrollX
|
|
205
204
|
enhanced
|
|
206
205
|
showScrollbar={false}
|
|
207
206
|
{...otherProps}
|
|
208
207
|
className={classNames(
|
|
209
208
|
className,
|
|
210
209
|
{
|
|
211
210
|
[customScrollViewStyle[
|
|
212
211
|
'd-custom-ios-mini-extend-border-radius'
|
|
213
212
|
]]:
|
|
214
213
|
isIosDevice &&
|
|
215
214
|
isWxMin &&
|
|
216
215
|
scrollX &&
|
|
217
216
|
style['borderRadius'],
|
|
218
217
|
},
|
|
219
218
|
{
|
|
220
219
|
[customScrollViewStyle[
|
|
221
220
|
'd-custom-ios-h5-extend-border-radius'
|
|
222
221
|
]]: isIosDevice,
|
|
223
222
|
},
|
|
224
223
|
{
|
|
225
224
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]:
|
|
226
225
|
isWxMin,
|
|
227
226
|
},
|
|
228
227
|
)}
|
|
229
228
|
style={style}
|
|
230
229
|
>
|
|
231
230
|
{children}
|
|
232
231
|
</ScrollView>
|
|
233
232
|
)
|
|
234
233
|
}
|
|
235
234
|
iosNeedDisableVertical: false,
|
|
235
|
+
import React, { useRef, useEffect } from 'react';
|
|
236
236
|
isH5AndJdShopView,
|
|
237
237
|
isAndroidDevice,
|
|
238
238
|
isJdAndAndroidDevice,
|
|
239
239
|
isJdAndIosDevice,
|
|
240
240
|
isIosDevice,
|
|
241
241
|
isJdApp,
|
|
242
242
|
isWxMin,
|
|
243
243
|
isH5AndJdShopViewH5Scroll,
|
|
244
244
|
isH5AndJdShopH5CustomScrollView,
|
|
245
245
|
isH5,
|
|
246
246
|
isAppClassifyPage,
|
|
247
247
|
lodashThrottle,
|
|
248
248
|
START: 'start',
|
|
249
249
|
MOVE: 'move',
|
|
250
250
|
END: 'end',
|
|
251
251
|
'当前业务是否忽略原生阻止底层滚动',
|
|
252
252
|
isIgnorePreventNative,
|
|
253
253
|
ignoreBuildTypeList,
|
|
254
254
|
newBuildType,
|
|
255
255
|
const { scrollX, children, style = {}, iosNeedDisableVertical, className, ...otherProps } = props;
|
|
256
256
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null;
|
|
257
257
|
const needShowHighVersion =
|
|
258
258
|
isH5AndJdShopViewH5Scroll &&
|
|
259
259
|
!(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
|
|
260
260
|
const mLastClientPosRef = useRef({
|
|
261
261
|
mLastClientX: 0,
|
|
262
262
|
mLastClientY: 0,
|
|
263
263
|
});
|
|
264
264
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
|
|
265
265
|
|
|
266
266
|
const touchstartEventBubbleFunc = (e) => {
|
|
267
267
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
268
268
|
if (!isH5SwiperCustomEle) {
|
|
269
269
|
const hasCustomEle = e
|
|
270
270
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
271
271
|
: false;
|
|
272
272
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
273
273
|
window?.JdAndroid &&
|
|
274
274
|
window?.JdAndroid?.requestEvent &&
|
|
275
275
|
window.JdAndroid.requestEvent(false);
|
|
276
276
|
}
|
|
277
277
|
!hasCustomEle &&
|
|
278
278
|
rootEleNode &&
|
|
279
279
|
rootEleNode.classList.contains('over-hidden') &&
|
|
280
280
|
rootEleNode.classList.remove('over-hidden');
|
|
281
281
|
console.log(
|
|
282
282
|
'customScrollView所在页面document touch start事件是否有J_customScroll元素',
|
|
283
283
|
hasCustomEle,
|
|
284
284
|
'根元素是否有over-hidden',
|
|
285
285
|
rootEleNode.classList,
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
289
|
const touchstartEventCaptureFunc = (e) => {
|
|
290
290
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
|
|
291
291
|
rootEleNode &&
|
|
292
292
|
rootEleNode.classList.contains('over-hidden') &&
|
|
293
293
|
rootEleNode.classList.remove('over-hidden');
|
|
294
294
|
console.log(
|
|
295
295
|
'customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden',
|
|
296
296
|
rootEleNode.classList,
|
|
297
297
|
);
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
useEffect(() => {
|
|
301
301
|
isJdApp &&
|
|
302
302
|
!window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
303
303
|
nativePageGetScaledTouchSlop((res) => {
|
|
304
304
|
console.log('获取安卓系统滑动阈值', res);
|
|
305
305
|
window.JDJshopViewInfo.androidTouchSlop = res;
|
|
306
306
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true;
|
|
307
307
|
});
|
|
308
308
|
if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
|
|
309
309
|
global?.removeJdAndroidRquestEventForTouchStart &&
|
|
310
310
|
global.removeJdAndroidRquestEventForTouchStart();
|
|
311
311
|
rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
312
312
|
|
|
313
313
|
rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
314
314
|
rootEleAddEventListenerState = true;
|
|
315
315
|
console.warn('customScrollView 初始化document监听完成');
|
|
316
316
|
}
|
|
317
317
|
return () => {
|
|
318
318
|
if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
|
|
319
319
|
console.warn('customScrollView document监听取消完成');
|
|
320
320
|
rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
321
321
|
rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
322
322
|
}
|
|
323
323
|
};
|
|
324
324
|
}, []);
|
|
325
325
|
|
|
326
326
|
const androidDeviceStopNativeScrollEvent = (touchType) => {
|
|
327
327
|
isJdApp &&
|
|
328
328
|
isAndroidDevice &&
|
|
329
329
|
window?.JdAndroid &&
|
|
330
330
|
window?.JdAndroid?.requestEvent &&
|
|
331
331
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
332
332
|
console.log('触发window?.JdAndroid.requestEvent', touchType === TouchType.START, touchType);
|
|
333
333
|
};
|
|
334
334
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
335
335
|
e && e.stopPropagation();
|
|
336
336
|
sendIosState && iosDeviceSendRouter(touchType);
|
|
337
337
|
};
|
|
338
338
|
const iosDeviceSendRouter = (state) => {
|
|
339
339
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
340
340
|
method: 'callRouterModuleWithParams',
|
|
341
341
|
params: {
|
|
342
342
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
343
343
|
routerParam: {
|
|
344
344
|
slideDirection: 'horizontal',
|
|
345
345
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
346
346
|
state,
|
|
347
347
|
},
|
|
348
348
|
callBackId: new Date().getTime(),
|
|
349
349
|
},
|
|
350
350
|
});
|
|
351
351
|
};
|
|
352
352
|
const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
|
|
353
353
|
if (isJdApp) {
|
|
354
354
|
isIosDevice &&
|
|
355
355
|
!isAppClassifyPage &&
|
|
356
356
|
iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
|
|
357
357
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
|
|
358
358
|
console.log(
|
|
359
359
|
'当前customScrollView touch事件',
|
|
360
360
|
touchType,
|
|
361
361
|
e,
|
|
362
362
|
'是否是e instanceof CustomEvent',
|
|
363
363
|
e instanceof CustomEvent,
|
|
364
364
|
);
|
|
365
365
|
}
|
|
366
366
|
};
|
|
367
367
|
const GetSlideAngle = (dx, dy) => {
|
|
368
368
|
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
369
369
|
};
|
|
370
370
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
371
371
|
const dy = startY - endY;
|
|
372
372
|
const dx = endX - startX;
|
|
373
373
|
let result = 0;
|
|
374
374
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
375
375
|
return result;
|
|
376
376
|
}
|
|
377
377
|
const angle = GetSlideAngle(dx, dy);
|
|
378
378
|
if (angle >= -45 && angle < 45) {
|
|
379
379
|
result = 4;
|
|
380
380
|
} else if (angle >= 45 && angle < 135) {
|
|
381
381
|
result = 1;
|
|
382
382
|
} else if (angle >= -135 && angle < -45) {
|
|
383
383
|
result = 2;
|
|
384
384
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
385
385
|
result = 3;
|
|
386
386
|
}
|
|
387
387
|
return result;
|
|
388
388
|
};
|
|
389
389
|
const changeTouchStart = (e) => {
|
|
390
390
|
if (isJdApp) {
|
|
391
391
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
|
|
392
392
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
393
393
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
394
394
|
console.info(
|
|
395
395
|
'customScrollView touchstart 当前根元素是否添加还是删除over-hidden',
|
|
396
396
|
TouchType.START,
|
|
397
397
|
rootEleNode.classList,
|
|
398
398
|
);
|
|
399
399
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
400
400
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
|
|
401
401
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
|
|
402
402
|
console.log('ustomScrollView touchstart 获取mLastClientPosRef', mLastClientPosRef);
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
};
|
|
406
406
|
const changeTouchEnd = (e) => {
|
|
407
407
|
stopNativeScrollEvent(e, TouchType.END);
|
|
408
408
|
mLastClientPosRef.current.mLastClientX = 0;
|
|
409
409
|
mLastClientPosRef.current.mLastClientY = 0;
|
|
410
410
|
console.log('ustomScrollView touchend 获取mLastClientPosRef', mLastClientPosRef);
|
|
411
411
|
};
|
|
412
412
|
const triggerIosTouchMove = () => {
|
|
413
413
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
|
|
417
417
|
|
|
418
418
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
419
419
|
const direction = GetSlideDirection(
|
|
420
420
|
mLastClientPosRef.current.mLastClientX,
|
|
421
421
|
mLastClientPosRef.current.mLastClientY,
|
|
422
422
|
touchEvent.clientX,
|
|
423
423
|
touchEvent.clientY,
|
|
424
424
|
);
|
|
425
425
|
if (direction === 1 || direction === 2) {
|
|
426
426
|
rootEleNode &&
|
|
427
427
|
rootEleNode.classList.contains('over-hidden') &&
|
|
428
428
|
rootEleNode.classList.remove('over-hidden');
|
|
429
429
|
}
|
|
430
430
|
console.log(
|
|
431
431
|
'获取当前滚动方向,向上向下1、2',
|
|
432
432
|
direction,
|
|
433
433
|
'根元素的classList',
|
|
434
434
|
rootEleNode.classList,
|
|
435
435
|
'mLastClientPosRef.current.mLastClientX',
|
|
436
436
|
mLastClientPosRef.current.mLastClientX,
|
|
437
437
|
);
|
|
438
438
|
};
|
|
439
439
|
const changeTouchMove = (e) => {
|
|
440
440
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
441
441
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
442
442
|
const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
|
|
443
443
|
2,
|
|
444
444
|
);
|
|
445
445
|
const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
|
|
446
446
|
2,
|
|
447
447
|
);
|
|
448
448
|
if (isJdApp) {
|
|
449
449
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
450
450
|
console.log(
|
|
451
451
|
'横向滚动触发',
|
|
452
452
|
xDiff,
|
|
453
453
|
touchEvent,
|
|
454
454
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
455
455
|
'iosNeedDisableVertical',
|
|
456
456
|
iosNeedDisableVertical,
|
|
457
457
|
);
|
|
458
458
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
|
|
459
459
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
460
460
|
console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
|
|
461
461
|
stopNativeScrollEvent(e, TouchType.END);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
|
|
465
465
|
}
|
|
466
466
|
};
|
|
467
467
|
if (scrollX && isJdApp && !isIgnorePreventNative) {
|
|
468
468
|
return (
|
|
469
469
|
<ScrollView
|
|
470
470
|
scrollX
|
|
471
471
|
onTouchStart={changeTouchStart}
|
|
472
472
|
onTouchEnd={changeTouchEnd}
|
|
473
473
|
onTouchCancel={changeTouchEnd}
|
|
474
474
|
onTouchMove={changeTouchMove}
|
|
475
475
|
enhanced
|
|
476
476
|
showScrollbar={false}
|
|
477
477
|
style={style}
|
|
478
478
|
className={classNames(
|
|
479
479
|
className,
|
|
480
480
|
{
|
|
481
481
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
482
482
|
},
|
|
483
483
|
'J_customScroll',
|
|
484
484
|
)}
|
|
485
485
|
{...otherProps}
|
|
486
486
|
>
|
|
487
487
|
{children}
|
|
488
488
|
</ScrollView>
|
|
489
489
|
);
|
|
490
490
|
} else {
|
|
491
491
|
return (
|
|
492
492
|
<ScrollView
|
|
493
493
|
scrollX
|
|
494
494
|
enhanced
|
|
495
495
|
showScrollbar={false}
|
|
496
496
|
{...otherProps}
|
|
497
497
|
className={classNames(
|
|
498
498
|
className,
|
|
499
499
|
{
|
|
500
500
|
[customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
|
|
501
501
|
isIosDevice && isWxMin && scrollX && style['borderRadius'],
|
|
502
502
|
},
|
|
503
503
|
{
|
|
504
504
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
505
505
|
},
|
|
506
506
|
{
|
|
507
507
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
|
|
508
508
|
},
|
|
509
509
|
)}
|
|
510
510
|
style={style}
|
|
511
511
|
>
|
|
512
512
|
{children}
|
|
513
513
|
</ScrollView>
|
|
514
514
|
);
|
|
515
515
|
}
|
|
516
516
|
style: {},
|
|
517
517
|
scrollX: false,
|
|
518
518
|
scrollY: false,
|
|
519
519
|
scrollWithAnimation: true,
|
|
520
520
|
iosNeedDisableVertical: false,
|
|
521
521
|
className: null,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const MediaError = {
|
|
2
|
MEDIA_ERR_ABORTED: 1,
|
|
1
3
|
MEDIA_ERR_NETWORK: 2,
|
|
2
4
|
MEDIA_ERR_DECODE: 3,
|
|
3
5
|
MEDIA_ERR_SRC_NOT_SUPPORTED: 4,
|
|
4
6
|
[MediaError.MEDIA_ERR_ABORTED]: 'MEDIA_ERR_ABORTED',
|
|
5
7
|
[MediaError.MEDIA_ERR_NETWORK]: 'MEDIA_ERR_NETWORK',
|
|
6
8
|
[MediaError.MEDIA_ERR_DECODE]: 'MEDIA_ERR_DECODE',
|
|
7
9
|
[MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED]: 'MEDIA_ERR_SRC_NOT_SUPPORTED',
|
|
8
10
|
if (!error) {
|
|
9
11
|
return ''
|
|
10
12
|
}
|
|
11
13
|
const message = error.message
|
|
12
14
|
let s = ''
|
|
13
15
|
if (error?.code) {
|
|
14
16
|
s += codeMap[error.code] || 'UNKNOWN'
|
|
15
17
|
}
|
|
16
18
|
if (message?.length > 0) {
|
|
17
19
|
s += ` ${message}`
|
|
18
20
|
}
|
|
19
21
|
return `${error.constructor.name} ${error.code}: ${s}`
|