@conecli/cone-render 0.8.39 → 0.8.41
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/README.md +7 -1
- package/dist/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.ts +1 -0
- 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/jdplayerSdk.ts +1 -0
- package/dist/common/sgmCustomCode.ts +1 -0
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/token/token.ts +1 -1
- package/dist/common/wxappApi.jd.ts +1 -0
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.module.scss +7 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +5 -0
- package/dist/components/base/Dialog/index.tsx +1 -1
- package/dist/components/base/Exposure/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.tsx +1 -1
- 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/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +20 -20
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +4 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Skeleton/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/components/isv/Floor/index.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/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/interface/utils.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/createReportFloorData.ts +1 -1
- package/dist/jumpEventReport/index.h5.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 -0
- package/dist/jumpEventReport/web.tjapp.ts +1 -0
- package/dist/jumpEventReport/web.tjm.ts +1 -0
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/modules/ContainerFloorList/index.h5.module.scss +17 -1
- 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/index.ts +1 -1
- package/dist/open/api/jump copy.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/track.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/sass/app.h5.scss +39 -3
- package/dist/sass/base.scss +12 -0
- package/dist/service/requestServer.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/draExceptionAndProfile.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/jm-common.js +1 -1
- package/dist/utils/sgmCodeUtils.ts +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -0
- package/dist/utils/utils.ts +1 -1
- package/package.json +2 -1
- package/dist/components/base/Skeleton/old.tsx +0 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
console.log('load token.jd')
|
|
2
1
|
return new Promise((resolve) => {
|
|
3
2
|
if (window['jmfe']) {
|
|
4
3
|
window['jmfe'].isJDAppLogin().then(({ data }) => {
|
|
5
4
|
if (data === '1') {
|
|
6
5
|
resolve(true)
|
|
7
6
|
} else if (data === '0') {
|
|
8
7
|
resolve(false)
|
|
9
8
|
}
|
|
10
9
|
})
|
|
11
10
|
} else {
|
|
12
11
|
console.warn('jmfe对象不存在,可能没有提前动态引入jd-jssdk.js')
|
|
13
12
|
resolve(false)
|
|
14
13
|
}
|
|
15
14
|
})
|
|
16
15
|
return requestIsvToken(window.location.href)
|
|
17
16
|
if (window['jmfe']) {
|
|
18
17
|
window['jmfe'].toLogin(options)
|
|
19
18
|
} else {
|
|
20
19
|
console.warn('jmfe对象不存在,可能没有提前动态引入jd-jssdk.js')
|
|
21
20
|
}
|
|
22
21
|
if (window['jmfe']) {
|
|
23
22
|
console.log('registerCode:', code)
|
|
24
23
|
window['jmfe'].registerCode(code)
|
|
25
24
|
} else {
|
|
26
25
|
console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
|
|
27
26
|
}
|
|
28
27
|
return new Promise((resolve) => {
|
|
29
28
|
console.log('requestIsvToken:', url)
|
|
30
29
|
if (window['jmfe']) {
|
|
31
30
|
window['jmfe']
|
|
32
31
|
.requestIsvToken(url)
|
|
33
32
|
.then((result: any) => {
|
|
34
33
|
console.log('requestIsvToken result:' + JSON.stringify(result))
|
|
35
34
|
const { status, data, msg } = result
|
|
36
35
|
if (status === '0') {
|
|
37
36
|
resolve(data || '')
|
|
38
37
|
} else {
|
|
39
38
|
resolve('')
|
|
40
39
|
}
|
|
41
40
|
})
|
|
42
41
|
.catch((e: any) => {
|
|
43
42
|
console.log('requestIsvToken error:' + JSON.stringify(e))
|
|
44
43
|
resolve('')
|
|
45
44
|
})
|
|
46
45
|
} else {
|
|
47
46
|
console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
|
|
48
47
|
resolve('')
|
|
49
48
|
}
|
|
50
49
|
})
|
|
50
|
+
console.log('load token.jd')
|
|
51
51
|
return new Promise((resolve) => {
|
|
52
52
|
if (window['jmfe']) {
|
|
53
53
|
window['jmfe'].isJDAppLogin().then(({ data }) => {
|
|
54
54
|
if (data === '1') {
|
|
55
55
|
resolve(true)
|
|
56
56
|
} else if (data === '0') {
|
|
57
57
|
resolve(false)
|
|
58
58
|
}
|
|
59
59
|
})
|
|
60
60
|
} else {
|
|
61
61
|
console.warn('jmfe对象不存在,可能没有提前动态引入jd-jssdk.js')
|
|
62
62
|
resolve(false)
|
|
63
63
|
}
|
|
64
64
|
})
|
|
65
65
|
return requestIsvToken(window.location.href)
|
|
66
66
|
if (window['jmfe']) {
|
|
67
67
|
window['jmfe'].toLogin(options)
|
|
68
68
|
} else {
|
|
69
69
|
console.warn('jmfe对象不存在,可能没有提前动态引入jd-jssdk.js')
|
|
70
70
|
}
|
|
71
71
|
if (window['jmfe']) {
|
|
72
72
|
console.log('registerCode:', code)
|
|
73
73
|
window['jmfe'].registerCode(code)
|
|
74
74
|
} else {
|
|
75
75
|
console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
|
|
76
76
|
}
|
|
77
77
|
return new Promise((resolve) => {
|
|
78
78
|
console.log('requestIsvToken:', url)
|
|
79
79
|
if (window['jmfe']) {
|
|
80
80
|
window['jmfe']
|
|
81
81
|
.requestIsvToken(url)
|
|
82
82
|
.then((result: any) => {
|
|
83
83
|
console.log('requestIsvToken result:' + JSON.stringify(result))
|
|
84
84
|
const { status, data, msg } = result
|
|
85
85
|
if (status === '0') {
|
|
86
86
|
resolve(data || '')
|
|
87
87
|
} else {
|
|
88
88
|
resolve('')
|
|
89
89
|
}
|
|
90
90
|
})
|
|
91
91
|
.catch((e: any) => {
|
|
92
92
|
console.log('requestIsvToken error:' + JSON.stringify(e))
|
|
93
93
|
resolve('')
|
|
94
94
|
})
|
|
95
95
|
} else {
|
|
96
96
|
console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
|
|
97
97
|
resolve('')
|
|
98
98
|
}
|
|
99
99
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import global from '../../common'
|
|
2
1
|
return window?.page_data?.pageChannel || ''
|
|
3
2
|
return new Promise((resolve) => {
|
|
4
3
|
const channel = getPageChannel()
|
|
5
4
|
if (
|
|
6
5
|
channel === PageChannel.TYPE_ISVDEV ||
|
|
7
6
|
channel === PageChannel.TYPE_ISV_PACK_SAMPLE
|
|
8
7
|
) {
|
|
9
8
|
getIsvToken().then((token) => {
|
|
10
9
|
console.log('isLogin token:' + token)
|
|
11
10
|
if (token) {
|
|
12
11
|
resolve(true)
|
|
13
12
|
} else {
|
|
14
13
|
resolve(false)
|
|
15
14
|
}
|
|
16
15
|
})
|
|
17
16
|
} else {
|
|
18
17
|
global.checkLoginStatus().then(res => {
|
|
19
18
|
resolve(res)
|
|
20
19
|
}).catch(() => {
|
|
21
20
|
resolve(false)
|
|
22
21
|
})
|
|
23
22
|
}
|
|
24
23
|
})
|
|
25
24
|
let token = ''
|
|
26
25
|
const result: any = await getIsvTokenInner()
|
|
27
26
|
if (!result.success) {
|
|
28
27
|
const channel = getPageChannel()
|
|
29
28
|
if (channel === PageChannel.TYPE_ISV_PACK_SAMPLE) {
|
|
30
29
|
console.log('getIsvToken打包校验中获取token失败')
|
|
31
30
|
if (window['isvTokenFailCallback']) {
|
|
32
31
|
window['isvTokenFailCallback'](result.error)
|
|
33
32
|
console.log('浏览器中调用isvTokenFailCallback结束')
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
} else {
|
|
37
36
|
token = result.data
|
|
38
37
|
}
|
|
39
38
|
return token
|
|
40
39
|
return new Promise((resolve) => {
|
|
41
40
|
fetchGateway(
|
|
42
41
|
'isvObfuscator',
|
|
43
42
|
{
|
|
44
43
|
url: window.location.href,
|
|
45
44
|
id: 'shopisv',
|
|
46
45
|
},
|
|
47
46
|
{},
|
|
48
47
|
)
|
|
49
48
|
.then((data: any) => {
|
|
50
49
|
console.log('fetchGateway isvObfuscator data:' + JSON.stringify(data))
|
|
51
50
|
if (
|
|
52
51
|
data?.statusCode == 200 &&
|
|
53
52
|
data?.data?.errcode === 0 &&
|
|
54
53
|
data?.data?.token
|
|
55
54
|
) {
|
|
56
55
|
resolve({
|
|
57
56
|
success: true,
|
|
58
57
|
data: data?.data?.token,
|
|
59
58
|
})
|
|
60
59
|
} else {
|
|
61
60
|
resolve({
|
|
62
61
|
success: false,
|
|
63
62
|
error: data,
|
|
64
63
|
})
|
|
65
64
|
}
|
|
66
65
|
})
|
|
67
66
|
.catch((error: { message: any }) => {
|
|
68
67
|
console.log('fetchGateway isvObfuscator error:' + error.message)
|
|
69
68
|
resolve({
|
|
70
69
|
success: false,
|
|
71
70
|
error,
|
|
72
71
|
})
|
|
73
72
|
})
|
|
74
73
|
})
|
|
75
74
|
const defaultParams = {
|
|
76
75
|
appid: '100',
|
|
77
76
|
returnurl: window.location.href,
|
|
78
77
|
}
|
|
79
78
|
const params = Object.assign({}, defaultParams, options)
|
|
80
79
|
params.returnurl = encodeURIComponent(params.returnurl)
|
|
81
80
|
const loginUrl = `${domain.mobileLogin}/user/login.action?${serialize(
|
|
82
81
|
params,
|
|
83
82
|
)}`
|
|
84
83
|
console.log('loginUrl:', loginUrl)
|
|
85
84
|
window.location.href = loginUrl
|
|
85
|
+
import global from '../../common'
|
|
86
86
|
return window?.page_data?.pageChannel || ''
|
|
87
87
|
return new Promise((resolve) => {
|
|
88
88
|
const channel = getPageChannel()
|
|
89
89
|
if (
|
|
90
90
|
channel === PageChannel.TYPE_ISVDEV ||
|
|
91
91
|
channel === PageChannel.TYPE_ISV_PACK_SAMPLE
|
|
92
92
|
) {
|
|
93
93
|
getIsvToken().then((token) => {
|
|
94
94
|
console.log('isLogin token:' + token)
|
|
95
95
|
if (token) {
|
|
96
96
|
resolve(true)
|
|
97
97
|
} else {
|
|
98
98
|
resolve(false)
|
|
99
99
|
}
|
|
100
100
|
})
|
|
101
101
|
} else {
|
|
102
102
|
global.checkLoginStatus().then(res => {
|
|
103
103
|
resolve(res)
|
|
104
104
|
}).catch(() => {
|
|
105
105
|
resolve(false)
|
|
106
106
|
})
|
|
107
107
|
}
|
|
108
108
|
})
|
|
109
109
|
let token = ''
|
|
110
110
|
const result: any = await getIsvTokenInner()
|
|
111
111
|
if (!result.success) {
|
|
112
112
|
const channel = getPageChannel()
|
|
113
113
|
if (channel === PageChannel.TYPE_ISV_PACK_SAMPLE) {
|
|
114
114
|
console.log('getIsvToken打包校验中获取token失败')
|
|
115
115
|
if (window['isvTokenFailCallback']) {
|
|
116
116
|
window['isvTokenFailCallback'](result.error)
|
|
117
117
|
console.log('浏览器中调用isvTokenFailCallback结束')
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
} else {
|
|
121
121
|
token = result.data
|
|
122
122
|
}
|
|
123
123
|
return token
|
|
124
124
|
return new Promise((resolve) => {
|
|
125
125
|
fetchGateway(
|
|
126
126
|
'isvObfuscator',
|
|
127
127
|
{
|
|
128
128
|
url: window.location.href,
|
|
129
129
|
id: 'shopisv',
|
|
130
130
|
},
|
|
131
131
|
{},
|
|
132
132
|
)
|
|
133
133
|
.then((data: any) => {
|
|
134
134
|
console.log('fetchGateway isvObfuscator data:' + JSON.stringify(data))
|
|
135
135
|
if (
|
|
136
136
|
data?.statusCode == 200 &&
|
|
137
137
|
data?.data?.errcode === 0 &&
|
|
138
138
|
data?.data?.token
|
|
139
139
|
) {
|
|
140
140
|
resolve({
|
|
141
141
|
success: true,
|
|
142
142
|
data: data?.data?.token,
|
|
143
143
|
})
|
|
144
144
|
} else {
|
|
145
145
|
resolve({
|
|
146
146
|
success: false,
|
|
147
147
|
error: data,
|
|
148
148
|
})
|
|
149
149
|
}
|
|
150
150
|
})
|
|
151
151
|
.catch((error: { message: any }) => {
|
|
152
152
|
console.log('fetchGateway isvObfuscator error:' + error.message)
|
|
153
153
|
resolve({
|
|
154
154
|
success: false,
|
|
155
155
|
error,
|
|
156
156
|
})
|
|
157
157
|
})
|
|
158
158
|
})
|
|
159
159
|
const defaultParams = {
|
|
160
160
|
appid: '100',
|
|
161
161
|
returnurl: window.location.href,
|
|
162
162
|
}
|
|
163
163
|
const params = Object.assign({}, defaultParams, options)
|
|
164
164
|
params.returnurl = encodeURIComponent(params.returnurl)
|
|
165
165
|
const loginUrl = `${domain.mobileLogin}/user/login.action?${serialize(
|
|
166
166
|
params,
|
|
167
167
|
)}`
|
|
168
168
|
console.log('loginUrl:', loginUrl)
|
|
169
169
|
window.location.href = loginUrl
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as WXAPP_LOGIN from '../wxapp/common/login/login.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
code: 'isvModuleError',
|
|
3
2
|
msg: opt,
|
|
4
3
|
})
|
|
5
4
|
if(this.props.customErrorIsvFloorModule){
|
|
6
5
|
return this.props.customErrorIsvFloorModule
|
|
7
6
|
}
|
|
7
|
+
import React from 'react'
|
|
8
8
|
const floorLoadWay = floorData?.floorExtInfo?.floorLoadWay
|
|
9
9
|
const isRemoteLoadFloor = floorLoadWay === 2
|
|
10
10
|
msg: `店铺h5楼层隐藏不显示。原因:模块js执行异常,楼层过滤。`,
|
|
11
11
|
floorIdx: floorData?.floorIdx,
|
|
12
12
|
moduleDesignerType: floorData?.floorExtInfo?.moduleDesignerType,
|
|
13
13
|
floorLoadWay,
|
|
14
14
|
floorKind: floorData?.floorExtInfo?.floorKind,
|
|
15
15
|
}
|
|
16
16
|
code: getSgmCustomCode(isRemoteLoadFloor ? SgmCustomCode.REMOTEMODULE_JS : SgmCustomCode.SYSTEMMODULE_JS),
|
|
17
17
|
msg: opt,
|
|
18
18
|
})
|
|
19
19
|
if(this.props.customErrorIsvFloorModule){
|
|
20
20
|
return this.props.customErrorIsvFloorModule
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
2
|
showDayToSecondState,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
return (
|
|
1
3
|
<ScrollView
|
|
2
4
|
scrollX
|
|
3
5
|
enhanced
|
|
4
6
|
showScrollbar={false}
|
|
5
7
|
{...otherProps}
|
|
6
8
|
className={classNames(
|
|
7
9
|
className,
|
|
8
10
|
{
|
|
9
11
|
[customScrollViewStyle[
|
|
10
12
|
'd-custom-ios-mini-extend-border-radius'
|
|
11
13
|
]]:
|
|
12
14
|
isIosDevice &&
|
|
13
15
|
isJdMin &&
|
|
14
16
|
scrollX &&
|
|
15
17
|
style['borderRadius'],
|
|
16
18
|
},
|
|
17
19
|
{
|
|
18
20
|
[customScrollViewStyle[
|
|
19
21
|
'd-custom-ios-h5-extend-border-radius'
|
|
20
22
|
]]: isIosDevice,
|
|
21
23
|
},
|
|
22
24
|
{
|
|
23
25
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]:
|
|
24
26
|
isJdMin,
|
|
25
27
|
},
|
|
26
28
|
)}
|
|
27
29
|
style={style}
|
|
28
30
|
>
|
|
29
31
|
{children}
|
|
30
32
|
</ScrollView>
|
|
31
33
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, {useRef, useEffect} from 'react'
|
|
2
1
|
isH5AndJdShopView,
|
|
3
2
|
isAndroidDevice,
|
|
4
3
|
isIosDevice,
|
|
5
4
|
isJdApp,
|
|
6
5
|
isWxMin,
|
|
7
6
|
isH5AndJdShopViewH5Scroll,
|
|
8
7
|
isH5,
|
|
9
8
|
START: 'start',
|
|
10
9
|
END: 'end'
|
|
11
10
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null
|
|
12
11
|
const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
|
|
13
12
|
const iosDeviceStopNativeScrollEvent = (e, touchType) => {
|
|
14
13
|
e && e.stopPropagation()
|
|
15
14
|
iosDeviceSendRouter(touchType)
|
|
16
15
|
}
|
|
17
16
|
const iosDeviceSendRouter = (state) => {
|
|
18
17
|
window.webkit.messageHandlers.MobileNavi.postMessage?.({
|
|
19
18
|
method: 'callRouterModuleWithParams',
|
|
20
19
|
params: {
|
|
21
20
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
22
21
|
routerParam: { slideDirection: 'horizontal', state },
|
|
23
22
|
callBackId: new Date().getTime(),
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType)
|
|
28
27
|
const GetSlideAngle = (dx,dy) => {
|
|
29
28
|
return Math.atan2(dy,dx) * 180 / Math.PI;
|
|
30
29
|
}
|
|
31
30
|
const GetSlideDirection = (startX,startY,endX,endY) => {
|
|
32
31
|
const dy = startY - endY;
|
|
33
32
|
const dx = endX - startX;
|
|
34
33
|
let result = 0;
|
|
35
34
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
36
35
|
return result;
|
|
37
36
|
}
|
|
38
37
|
const angle = GetSlideAngle(dx, dy);
|
|
39
38
|
if (angle >= -45 && angle < 45) {
|
|
40
39
|
result = 4;
|
|
41
40
|
}else if (angle >= 45 && angle < 135) {
|
|
42
41
|
result = 1;
|
|
43
42
|
}else if (angle >= -135 && angle < -45) {
|
|
44
43
|
result = 2;
|
|
45
44
|
}else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
46
45
|
result = 3;
|
|
47
46
|
}
|
|
48
47
|
return result;
|
|
49
48
|
}
|
|
50
49
|
needShowHighVersion && rootEleNode && rootEleNode.classList.add('over-hidden')
|
|
51
50
|
stopNativeScrollEvent(e,TouchType.END)
|
|
52
51
|
const touchEvent =
|
|
53
52
|
e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
|
|
54
53
|
const xDiff = Math.abs(
|
|
55
54
|
touchEvent.clientX - mLastClientPosRef.current.mLastClientX,
|
|
56
55
|
).toFixed(2)
|
|
57
56
|
const yDiff = Math.abs(
|
|
58
57
|
touchEvent.clientY - mLastClientPosRef.current.mLastClientY,
|
|
59
58
|
).toFixed(2)
|
|
60
59
|
if(isAndroidDevice) {
|
|
61
60
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
62
61
|
console.log(
|
|
63
62
|
'横向滚动触发',
|
|
64
63
|
xDiff,
|
|
65
64
|
touchEvent,
|
|
66
65
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
67
66
|
)
|
|
68
67
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
69
68
|
console.log(
|
|
70
69
|
'纵向滚动触发',
|
|
71
70
|
yDiff,
|
|
72
71
|
touchEvent,
|
|
73
72
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
74
73
|
)
|
|
75
74
|
stopNativeScrollEvent(e,TouchType.END)
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
if(needShowHighVersion) {
|
|
79
78
|
const direction = GetSlideDirection(mLastClientPosRef.current.mLastClientX, mLastClientPosRef.current.mLastClientY, touchEvent.clientX, touchEvent.clientY);
|
|
80
79
|
if(direction === 1 || direction === 2) {
|
|
81
80
|
rootEleNode && rootEleNode.classList.remove('over-hidden')
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
<ScrollView
|
|
85
84
|
scrollX
|
|
86
85
|
onTouchStart={changeTouchStart}
|
|
87
86
|
onTouchEnd={changeTouchEnd}
|
|
88
87
|
onTouchCancel={changeTouchEnd}
|
|
89
88
|
onTouchMove={changeTouchMove}
|
|
90
89
|
enhanced
|
|
91
90
|
showScrollbar={false}
|
|
92
91
|
style={style}
|
|
93
92
|
className={classNames(className, {
|
|
94
93
|
[customScrollViewStyle[
|
|
95
94
|
'd-custom-ios-h5-extend-border-radius'
|
|
96
95
|
]]: isIosDevice,
|
|
97
96
|
},'J_customScroll')}
|
|
98
97
|
{...otherProps}
|
|
99
98
|
>
|
|
100
99
|
{children}
|
|
101
100
|
</ScrollView>
|
|
101
|
+
import React, { useRef, useEffect } from 'react'
|
|
102
102
|
isH5AndJdShopView,
|
|
103
103
|
isAndroidDevice,
|
|
104
104
|
isJdAndAndroidDevice,
|
|
105
105
|
isJdAndIosDevice,
|
|
106
106
|
isIosDevice,
|
|
107
107
|
isJdApp,
|
|
108
108
|
isWxMin,
|
|
109
109
|
isH5AndJdShopViewH5Scroll,
|
|
110
110
|
isH5AndJdShopH5CustomScrollView,
|
|
111
111
|
isH5,
|
|
112
112
|
isAppClassifyPage,
|
|
113
113
|
lodashThrottle,
|
|
114
114
|
START: 'start',
|
|
115
115
|
MOVE: 'move',
|
|
116
116
|
END: 'end',
|
|
117
117
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null
|
|
118
118
|
const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
|
|
119
119
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView
|
|
120
120
|
|
|
121
121
|
const touchstartEventBubbleFunc = (e) => {
|
|
122
122
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom')
|
|
123
123
|
if(!isH5SwiperCustomEle){
|
|
124
124
|
const hasCustomEle = e ? (e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')) : false
|
|
125
125
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
126
126
|
window.JdAndroid && window.JdAndroid.requestEvent(false)
|
|
127
127
|
}
|
|
128
128
|
!hasCustomEle && rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
|
|
129
129
|
console.log("customScrollView所在页面document touch start事件是否有J_customScroll元素",hasCustomEle,"根元素是否有over-hidden",rootEleNode.classList)
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
const touchstartEventCaptureFunc = (e) => {
|
|
133
133
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')){
|
|
134
134
|
rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
|
|
135
135
|
console.log("customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden",rootEleNode.classList)
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
useEffect(() => {
|
|
139
139
|
isJdApp && !window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
140
140
|
nativePageGetScaledTouchSlop((res) => {
|
|
141
141
|
console.log('获取安卓系统滑动阈值', res)
|
|
142
142
|
window.JDJshopViewInfo.androidTouchSlop = res
|
|
143
143
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true
|
|
144
144
|
})
|
|
145
145
|
if(isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState){
|
|
146
146
|
global?.removeJdAndroidRquestEventForTouchStart && global.removeJdAndroidRquestEventForTouchStart()
|
|
147
147
|
rootEleNode.addEventListener(
|
|
148
148
|
'touchstart',
|
|
149
149
|
touchstartEventBubbleFunc,
|
|
150
150
|
false,
|
|
151
151
|
)
|
|
152
152
|
|
|
153
153
|
rootEleNode.addEventListener(
|
|
154
154
|
'touchstart',
|
|
155
155
|
touchstartEventCaptureFunc,
|
|
156
156
|
true,
|
|
157
157
|
)
|
|
158
158
|
rootEleAddEventListenerState = true
|
|
159
159
|
console.warn("customScrollView 初始化document监听完成")
|
|
160
160
|
}
|
|
161
161
|
return () => {
|
|
162
162
|
if(isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState){
|
|
163
163
|
console.warn("customScrollView document监听取消完成")
|
|
164
164
|
rootEleNode.removeEventListener(
|
|
165
165
|
'touchstart',
|
|
166
166
|
touchstartEventBubbleFunc,
|
|
167
167
|
false,
|
|
168
168
|
)
|
|
169
169
|
rootEleNode.removeEventListener(
|
|
170
170
|
'touchstart',
|
|
171
171
|
touchstartEventCaptureFunc,
|
|
172
172
|
true,
|
|
173
173
|
)
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}, [])
|
|
177
177
|
console.log("触发window?.JdAndroid.requestEvent",touchType === TouchType.START,touchType)
|
|
178
178
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
179
179
|
e && e.stopPropagation()
|
|
180
180
|
sendIosState && iosDeviceSendRouter(touchType)
|
|
181
181
|
}
|
|
182
182
|
const iosDeviceSendRouter = (state) => {
|
|
183
183
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
184
184
|
method: 'callRouterModuleWithParams',
|
|
185
185
|
params: {
|
|
186
186
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
187
187
|
routerParam: {
|
|
188
188
|
slideDirection: 'horizontal',
|
|
189
189
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
190
190
|
state,
|
|
191
191
|
},
|
|
192
192
|
callBackId: new Date().getTime(),
|
|
193
193
|
},
|
|
194
194
|
})
|
|
195
195
|
}
|
|
196
196
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType)
|
|
197
197
|
console.log("当前customScrollView touch事件", touchType, e, "是否是e instanceof CustomEvent", e instanceof CustomEvent)
|
|
198
198
|
const GetSlideAngle = (dx,dy) => {
|
|
199
199
|
return Math.atan2(dy,dx) * 180 / Math.PI;
|
|
200
200
|
}
|
|
201
201
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
202
202
|
const dy = startY - endY
|
|
203
203
|
const dx = endX - startX
|
|
204
204
|
let result = 0
|
|
205
205
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
206
206
|
return result
|
|
207
207
|
}
|
|
208
208
|
const angle = GetSlideAngle(dx, dy)
|
|
209
209
|
if (angle >= -45 && angle < 45) {
|
|
210
210
|
result = 4
|
|
211
211
|
} else if (angle >= 45 && angle < 135) {
|
|
212
212
|
result = 1
|
|
213
213
|
} else if (angle >= -135 && angle < -45) {
|
|
214
214
|
result = 2
|
|
215
215
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
216
216
|
result = 3
|
|
217
217
|
}
|
|
218
218
|
return result
|
|
219
219
|
}
|
|
220
220
|
if(isJdApp){
|
|
221
221
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical)
|
|
222
222
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
223
223
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden')
|
|
224
224
|
console.info("customScrollView touchstart 当前根元素是否添加还是删除over-hidden",TouchType.START,rootEleNode.classList)
|
|
225
225
|
const touchEvent =
|
|
226
226
|
e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
|
|
227
227
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX
|
|
228
228
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY
|
|
229
229
|
console.log('ustomScrollView touchstart 获取mLastClientPosRef', mLastClientPosRef)
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
stopNativeScrollEvent(e,TouchType.END)
|
|
233
233
|
mLastClientPosRef.current.mLastClientX = 0
|
|
234
234
|
mLastClientPosRef.current.mLastClientY = 0
|
|
235
235
|
console.log('ustomScrollView touchend 获取mLastClientPosRef', mLastClientPosRef)
|
|
236
236
|
const triggerIosTouchMove = () => {
|
|
237
237
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null,TouchType.START, true)
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(
|
|
241
241
|
triggerIosTouchMove,
|
|
242
242
|
500,
|
|
243
243
|
)
|
|
244
244
|
|
|
245
245
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
246
246
|
const direction = GetSlideDirection(mLastClientPosRef.current.mLastClientX, mLastClientPosRef.current.mLastClientY, touchEvent.clientX, touchEvent.clientY)
|
|
247
247
|
if (direction === 1 || direction === 2) {
|
|
248
248
|
rootEleNode && rootEleNode.classList.contains('over-hidden') && rootEleNode.classList.remove('over-hidden')
|
|
249
249
|
}
|
|
250
250
|
console.log("获取当前滚动方向,向上向下1、2",direction,'根元素的classList',rootEleNode.classList,'mLastClientPosRef.current.mLastClientX',mLastClientPosRef.current.mLastClientX)
|
|
251
251
|
}
|
|
252
252
|
const touchEvent =
|
|
253
253
|
e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
|
|
254
254
|
const xDiff = Math.abs(
|
|
255
255
|
touchEvent.clientX - mLastClientPosRef.current.mLastClientX,
|
|
256
256
|
).toFixed(2)
|
|
257
257
|
const yDiff = Math.abs(
|
|
258
258
|
touchEvent.clientY - mLastClientPosRef.current.mLastClientY,
|
|
259
259
|
).toFixed(2)
|
|
260
260
|
if(isJdApp) {
|
|
261
261
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
262
262
|
console.log(
|
|
263
263
|
'横向滚动触发',
|
|
264
264
|
xDiff,
|
|
265
265
|
touchEvent,
|
|
266
266
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
267
267
|
"iosNeedDisableVertical",
|
|
268
268
|
iosNeedDisableVertical
|
|
269
269
|
)
|
|
270
270
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove()
|
|
271
271
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
272
272
|
console.log(
|
|
273
273
|
'纵向滚动触发',
|
|
274
274
|
yDiff,
|
|
275
275
|
touchEvent,
|
|
276
276
|
window.JDJshopViewInfo.androidTouchSlop,
|
|
277
277
|
)
|
|
278
278
|
stopNativeScrollEvent(e,TouchType.END)
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent)
|
|
282
282
|
<ScrollView
|
|
283
283
|
scrollX
|
|
284
284
|
onTouchStart={changeTouchStart}
|
|
285
285
|
onTouchEnd={changeTouchEnd}
|
|
286
286
|
onTouchCancel={changeTouchEnd}
|
|
287
287
|
onTouchMove={changeTouchMove}
|
|
288
288
|
enhanced
|
|
289
289
|
showScrollbar={false}
|
|
290
290
|
style={style}
|
|
291
291
|
className={classNames(className, {
|
|
292
292
|
[customScrollViewStyle[
|
|
293
293
|
'd-custom-ios-h5-extend-border-radius'
|
|
294
294
|
]]: isIosDevice,
|
|
295
295
|
}, 'J_customScroll')}
|
|
296
296
|
{...otherProps}
|
|
297
297
|
>
|
|
298
298
|
{children}
|
|
299
299
|
</ScrollView>
|
|
300
300
|
)
|
|
301
301
|
} else {
|
|
302
302
|
return (
|
|
303
303
|
<ScrollView
|
|
304
304
|
scrollX
|
|
305
305
|
enhanced
|
|
306
306
|
showScrollbar={false}
|
|
307
307
|
{...otherProps}
|
|
308
308
|
className={classNames(
|
|
309
309
|
className,
|
|
310
310
|
{
|
|
311
311
|
[customScrollViewStyle[
|
|
312
312
|
'd-custom-ios-mini-extend-border-radius'
|
|
313
313
|
]]:
|
|
314
314
|
isIosDevice &&
|
|
315
315
|
isWxMin &&
|
|
316
316
|
scrollX &&
|
|
317
317
|
style['borderRadius'],
|
|
318
318
|
},
|
|
319
319
|
{
|
|
320
320
|
[customScrollViewStyle[
|
|
321
321
|
'd-custom-ios-h5-extend-border-radius'
|
|
322
322
|
]]: isIosDevice,
|
|
323
323
|
},
|
|
324
324
|
{
|
|
325
325
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]:
|
|
326
326
|
isWxMin,
|
|
327
327
|
},
|
|
328
328
|
)}
|
|
329
329
|
style={style}
|
|
330
330
|
>
|
|
331
331
|
{children}
|
|
332
332
|
</ScrollView>
|
|
333
333
|
)
|
|
334
334
|
}
|
|
335
335
|
iosNeedDisableVertical: false,
|