@conecli/cone-render 0.8.19-beta.0 → 0.8.19-beta.2
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/assets/networkError.png +0 -0
- 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/components/base/CustomVideo/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/LazyLayoutLoad/index.tsx +1 -1
- 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 +19 -14
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/utils.ts +1 -1
- package/dist/jumpEventReport/index.h5.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/web.jdb.ts +1 -0
- package/dist/libs/taroAppReport.js +2 -4
- package/dist/open/api/index.ts +1 -1
- package/dist/service/http/bMallConst.ts +1 -0
- package/dist/service/http/const.ts +1 -0
- package/dist/service/http/http.ts +1 -0
- package/dist/service/http/httpInterceptors.jd.ts +1 -0
- package/dist/service/http/httpInterceptors.ts +1 -0
- package/dist/service/http/index.ts +1 -0
- package/dist/service/requestServer.ts +1 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/jm-common.js +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
public config: object | null
|
|
3
2
|
this.config = {}
|
|
4
3
|
console.log('=================>', 'updateBusinessDomainAndApi')
|
|
4
|
+
import Taro from '@tarojs/taro'
|
|
5
5
|
public config: {
|
|
6
6
|
[key: string]: any
|
|
7
7
|
}
|
|
8
8
|
this.config = {}
|
|
9
9
|
console.log('=================>', 'updateBusinessDomainAndApi')
|
|
10
10
|
|
|
11
11
|
setTimeout(() => {
|
|
12
12
|
console.log("微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
|
|
13
13
|
this.getLoginCookie(`${Date.now()}`)
|
|
14
14
|
},500)
|
|
15
15
|
this.getLoginCookie(`${Date.now()}`)
|
|
16
16
|
setTimeout(() => {
|
|
17
17
|
console.log("微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
|
|
18
18
|
this.getLoginCookie(`${Date.now()}`)
|
|
19
19
|
},500)
|
|
20
20
|
return new Promise((resolve) => {
|
|
21
21
|
console.log("开始获取更新wxapp中的cookie信息", updateKey)
|
|
22
22
|
if(this.config.wqCookie && this.config.wqCookieStr && this.config.getWqCookieKey === updateKey){
|
|
23
23
|
console.log("已有存储wxapp中的cookie信息,直接返回",this.config)
|
|
24
24
|
resolve({
|
|
25
25
|
wqCookie: this.config.wqCookie,
|
|
26
26
|
wqCookieStr: this.config.wqCookieStr,
|
|
27
27
|
})
|
|
28
28
|
}else {
|
|
29
29
|
if (isPublishToWxapp) {
|
|
30
30
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
|
|
31
31
|
if (getWxappCookieObj) {
|
|
32
32
|
const getCookieObj = getWxappCookieObj['_data']
|
|
33
33
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
|
|
34
34
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie
|
|
35
35
|
this.info.loginState = true
|
|
36
36
|
this.info.userInfo.wqCookie = wqCookieStr
|
|
37
37
|
this.info.userInfo.wqVisitkey = visitkey
|
|
38
38
|
console.log('获取用户完整cookie信息', getCookieObj)
|
|
39
39
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress()
|
|
40
40
|
console.log('获取微信用户地址信息', getUserAddress)
|
|
41
41
|
if (getUserAddress) {
|
|
42
42
|
this.info.pageInfo.address = getUserAddress?.areaId
|
|
43
43
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo
|
|
44
44
|
.address
|
|
45
45
|
? this.info.pageInfo.address.replace(/_/g, ',')
|
|
46
46
|
: ''
|
|
47
47
|
this.info.pageInfo.un_area = this.info.pageInfo.address
|
|
48
48
|
Taro.eventCenter.trigger(
|
|
49
49
|
TaroEventType.USER_AREA_UPDATE,
|
|
50
50
|
this.info.pageInfo.address,
|
|
51
51
|
)
|
|
52
52
|
}
|
|
53
53
|
if(this.miniAppLogInstance){
|
|
54
54
|
this.miniAppLogInstance.set({
|
|
55
55
|
account: pin,
|
|
56
56
|
unionid: wq_unionid,
|
|
57
57
|
openid: wxapp_openid,
|
|
58
58
|
})
|
|
59
59
|
}
|
|
60
60
|
this.config.wqCookie = wqCookie
|
|
61
61
|
this.config.wqCookieStr = wqCookieStr
|
|
62
62
|
this.config.getWqCookieKey = updateKey
|
|
63
63
|
console.log("解析wxapp中的cookie信息成功,返回后存储",this.config)
|
|
64
64
|
resolve({
|
|
65
65
|
wqCookie,
|
|
66
66
|
wqCookieStr,
|
|
67
67
|
})
|
|
68
68
|
}else {
|
|
69
69
|
console.log("解析wxapp中的cookie信息异常,返回异常结果",this.config)
|
|
70
70
|
resolve({
|
|
71
71
|
wqCookie: false,
|
|
72
72
|
wqCookieStr: false,
|
|
73
73
|
})
|
|
74
74
|
}
|
|
75
75
|
}else {
|
|
76
76
|
resolve({
|
|
77
77
|
wqCookie: false,
|
|
78
78
|
wqCookieStr: false,
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
1
|
if (!isH5 || !ref.current) return
|
|
3
2
|
playVideo()
|
|
4
3
|
manualPauseStateRef.current = false
|
|
5
4
|
}
|
|
6
5
|
if (!isH5 || !ref.current) return
|
|
7
6
|
pauseVideo()
|
|
8
7
|
manualPauseStateRef.current = true
|
|
9
8
|
}
|
|
10
9
|
if (!isH5 || !ref.current) return
|
|
11
10
|
}, [])
|
|
11
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
12
12
|
if (!isH5 || !ref.current) return
|
|
13
13
|
playVideo()
|
|
14
14
|
manualPauseStateRef.current = false
|
|
15
15
|
}
|
|
16
16
|
if (!isH5 || !ref.current) return
|
|
17
17
|
pauseVideo()
|
|
18
18
|
manualPauseStateRef.current = true
|
|
19
19
|
}
|
|
20
20
|
if (!isH5 || !ref.current) return
|
|
21
21
|
}, [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
const {
|
|
3
2
|
children,
|
|
4
3
|
inViewCallback,
|
|
5
4
|
outViewCallback,
|
|
6
5
|
threshold = 0
|
|
7
6
|
} = props
|
|
8
7
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
9
8
|
const componentObserverRef = useRef<HTMLElement | null>(null)
|
|
10
9
|
const componentShowStateRef = useRef(false)
|
|
11
10
|
if (isH5AndJdShopView) {
|
|
12
11
|
useEffect(() => {
|
|
13
12
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
14
13
|
dealPageScrollInfo(latestRes)
|
|
15
14
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
16
15
|
dealPageScrollInfo(res)
|
|
17
16
|
})
|
|
18
17
|
Taro.eventCenter.on(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, (state) => {
|
|
19
18
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
20
19
|
})
|
|
21
20
|
return function cleanup() {
|
|
22
21
|
Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
|
|
23
22
|
dealPageScrollInfo(res)
|
|
24
23
|
})
|
|
25
24
|
|
|
26
25
|
Taro.eventCenter.off(TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE, (state) => {
|
|
27
26
|
state === WEBVIEW_STATE.NOT_VISIBLE &&
|
|
28
27
|
handleInOrOutView(false)
|
|
29
28
|
})
|
|
30
29
|
}
|
|
31
30
|
}, [])
|
|
32
31
|
useEffect(() => {
|
|
33
32
|
if (componentShowState) {
|
|
34
33
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
35
34
|
console.log('app=>in可视区域')
|
|
36
35
|
} else {
|
|
37
36
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
38
37
|
console.log('app=>out可视区域')
|
|
39
38
|
}
|
|
40
39
|
}, [componentShowState])
|
|
41
40
|
|
|
42
41
|
const handleInOrOutView = (type: boolean) => {
|
|
43
42
|
componentShowStateRef.current = type
|
|
44
43
|
setComponentShowState(type)
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
const dealPageScrollInfo = (res) => {
|
|
48
47
|
const { displayHeight, offSetY } = res
|
|
49
48
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
50
49
|
if (componentObserverRef.current) {
|
|
51
50
|
const eleClientRect =
|
|
52
51
|
componentObserverRef.current.getBoundingClientRect()
|
|
53
52
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
54
53
|
const eleHeight = Math.ceil(eleClientRect.height)
|
|
55
54
|
console.log('==========================eleOffsetTop, eleHeight', eleOffsetTop, eleHeight)
|
|
56
55
|
if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
|
|
57
56
|
const isOutView = offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
|
|
58
57
|
handleInOrOutView(!isOutView)
|
|
59
58
|
} else {
|
|
60
59
|
const isInView = (offSetY > eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold)) && (offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)))
|
|
61
60
|
handleInOrOutView(isInView)
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
return (
|
|
66
65
|
<View ref={componentObserverRef}>
|
|
67
66
|
{children}
|
|
68
67
|
</View>
|
|
69
68
|
)
|
|
70
69
|
} else {
|
|
71
70
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
72
71
|
const { ref, inView } = useInView({
|
|
73
72
|
threshold,
|
|
74
73
|
triggerOnce: false,
|
|
75
74
|
root: rootDom || null,
|
|
76
75
|
rootMargin: `0px 0px 0px 0px`,
|
|
77
76
|
})
|
|
78
77
|
useEffect(() => {
|
|
79
78
|
if (inView) {
|
|
80
79
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
81
80
|
console.log('其他h5=>in可视区域')
|
|
82
81
|
} else {
|
|
83
82
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
84
83
|
console.log('其他h5=>out可视区域')
|
|
85
84
|
}
|
|
86
85
|
}, [inView])
|
|
87
86
|
return (
|
|
88
87
|
<View ref={ref}>
|
|
89
88
|
{children}
|
|
90
89
|
</View>
|
|
91
90
|
)
|
|
92
91
|
}
|
|
93
92
|
children: null,
|
|
94
93
|
className: '',
|
|
95
94
|
inViewCallback: null,
|
|
96
95
|
outViewCallback: null,
|
|
97
96
|
threshold: 0
|
|
97
|
+
import Taro from '@tarojs/taro'
|
|
98
98
|
TaroEventType,
|
|
99
99
|
WEBVIEW_STATE,
|
|
100
100
|
M_H5_ROOT_ELE_NODE,
|
|
101
101
|
props: ComponentInterFace.InOrOutViewObserverProps,
|
|
102
102
|
const { children, inViewCallback, outViewCallback, threshold = 0 } = props
|
|
103
103
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
104
104
|
const componentObserverRef = useRef<HTMLElement | null>(null)
|
|
105
105
|
const componentShowStateRef = useRef(false)
|
|
106
106
|
if (isH5AndJdShopView) {
|
|
107
107
|
useEffect(() => {
|
|
108
108
|
const latestRes =
|
|
109
109
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
110
110
|
dealPageScrollInfo(latestRes)
|
|
111
111
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
112
112
|
dealPageScrollInfo(res)
|
|
113
113
|
})
|
|
114
114
|
Taro.eventCenter.on(
|
|
115
115
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
116
116
|
(state) => {
|
|
117
117
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
118
118
|
},
|
|
119
119
|
)
|
|
120
120
|
return function cleanup() {
|
|
121
121
|
Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
|
|
122
122
|
dealPageScrollInfo(res)
|
|
123
123
|
})
|
|
124
124
|
Taro.eventCenter.off(
|
|
125
125
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
126
126
|
(state) => {
|
|
127
127
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
128
128
|
},
|
|
129
129
|
)
|
|
130
130
|
}
|
|
131
131
|
}, [])
|
|
132
132
|
useEffect(() => {
|
|
133
133
|
if (componentShowState) {
|
|
134
134
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
135
135
|
console.log('app=>in可视区域')
|
|
136
136
|
} else {
|
|
137
137
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
138
138
|
console.log('app=>out可视区域')
|
|
139
139
|
}
|
|
140
140
|
}, [componentShowState])
|
|
141
141
|
|
|
142
142
|
const handleInOrOutView = (type: boolean) => {
|
|
143
143
|
componentShowStateRef.current = type
|
|
144
144
|
setComponentShowState(type)
|
|
145
145
|
console.log('handleInOrOutView', type)
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
const dealPageScrollInfo = (res) => {
|
|
149
149
|
console.log('dealPageScrollInfo===', res)
|
|
150
150
|
|
|
151
151
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
152
152
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
153
153
|
console.log(
|
|
154
154
|
'处理后dealPageScrollInfo===displayHeight=offSetY',
|
|
155
155
|
displayHeight,
|
|
156
156
|
offSetY,
|
|
157
157
|
)
|
|
158
158
|
if (componentObserverRef.current) {
|
|
159
159
|
const eleClientRect =
|
|
160
160
|
componentObserverRef.current.getBoundingClientRect()
|
|
161
161
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
162
162
|
const eleHeight = Math.ceil(eleClientRect.height)
|
|
163
163
|
console.log(
|
|
164
164
|
'==========================eleOffsetTop, eleHeight',
|
|
165
165
|
eleOffsetTop,
|
|
166
166
|
eleHeight,
|
|
167
167
|
)
|
|
168
168
|
if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
|
|
169
169
|
const isOutView =
|
|
170
170
|
offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
|
|
171
171
|
displayHeight - (eleOffsetTop - offSetY) <
|
|
172
172
|
Math.ceil(eleHeight * threshold)
|
|
173
173
|
|
|
174
174
|
console.log(
|
|
175
175
|
'比较isOutView',
|
|
176
176
|
isOutView,
|
|
177
177
|
offSetY,
|
|
178
178
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
179
179
|
displayHeight - (eleOffsetTop - offSetY),
|
|
180
180
|
Math.ceil(eleHeight * threshold),
|
|
181
181
|
)
|
|
182
182
|
handleInOrOutView(!isOutView)
|
|
183
183
|
} else {
|
|
184
184
|
const isInView =
|
|
185
185
|
offSetY >
|
|
186
186
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
|
|
187
187
|
offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
|
|
188
188
|
console.log(
|
|
189
189
|
'比较isInView',
|
|
190
190
|
isInView,
|
|
191
191
|
offSetY,
|
|
192
192
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
|
|
193
193
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
194
194
|
)
|
|
195
195
|
handleInOrOutView(isInView)
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
return <View ref={componentObserverRef}>{children}</View>
|
|
200
200
|
} else {
|
|
201
201
|
const rootDom = document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
|
|
202
202
|
const { ref, inView } = useInView({
|
|
203
203
|
threshold,
|
|
204
204
|
triggerOnce: false,
|
|
205
205
|
root: rootDom || null,
|
|
206
206
|
rootMargin: `0px 0px 0px 0px`,
|
|
207
207
|
})
|
|
208
208
|
useEffect(() => {
|
|
209
209
|
if (inView) {
|
|
210
210
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
211
211
|
console.log('其他h5=>in可视区域')
|
|
212
212
|
} else {
|
|
213
213
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
214
214
|
console.log('其他h5=>out可视区域')
|
|
215
215
|
}
|
|
216
216
|
}, [inView])
|
|
217
217
|
return <View ref={ref}>{children}</View>
|
|
218
218
|
}
|
|
219
219
|
children: null,
|
|
220
220
|
className: '',
|
|
221
221
|
inViewCallback: null,
|
|
222
222
|
outViewCallback: null,
|
|
223
223
|
threshold: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
TaroEventType,
|
|
3
2
|
const {
|
|
4
3
|
children,
|
|
5
4
|
placeholder,
|
|
6
5
|
height,
|
|
7
6
|
inViewCallback
|
|
8
7
|
} = props
|
|
9
8
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
10
9
|
const [componentRenderShowState, setComponentRenderShowState] =
|
|
11
10
|
useState(false)
|
|
12
11
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
13
12
|
const componentShowStateRef = useRef(false)
|
|
14
13
|
if (isH5AndJdShopView) {
|
|
15
14
|
useEffect(() => {
|
|
16
15
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
17
16
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
18
17
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
19
18
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
20
19
|
})
|
|
21
20
|
}, [])
|
|
22
21
|
useEffect(() => {
|
|
23
22
|
if (componentShowState) {
|
|
24
23
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
25
24
|
console.log('InViewRender -- 店铺H5 展示啦!')
|
|
26
25
|
}
|
|
27
26
|
}, [componentShowState])
|
|
28
27
|
|
|
29
28
|
const dealPageScrollInfo = (res) => {
|
|
30
29
|
if (componentLazyRef.current) {
|
|
31
30
|
const eleClientRect =
|
|
32
31
|
componentLazyRef.current.getBoundingClientRect()
|
|
33
32
|
const getContainerHeightOffSetY = res.displayHeight + res.offSetY
|
|
34
33
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
35
34
|
if (!componentShowStateRef.current) {
|
|
36
35
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
37
36
|
componentShowStateRef.current = true
|
|
38
37
|
setComponentShowState(true)
|
|
39
38
|
Taro.nextTick(() => {
|
|
40
39
|
setComponentRenderShowState(true)
|
|
41
40
|
})
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
return (
|
|
47
46
|
<View
|
|
48
47
|
ref={componentLazyRef}
|
|
49
48
|
className={classNames(
|
|
50
49
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
51
50
|
'd-app-floor-lazy-load',
|
|
52
51
|
)}
|
|
53
52
|
style={{
|
|
54
53
|
minHeight: `${componentRenderShowState ? 'auto' : height + (typeof height === 'number' ? 'px' : '')
|
|
55
54
|
}`,
|
|
56
55
|
backgroundColor: componentRenderShowState
|
|
57
56
|
? 'transparent'
|
|
58
57
|
: '#ffffff',
|
|
59
58
|
}}
|
|
60
59
|
>
|
|
61
60
|
{componentShowState ? children : placeholder}
|
|
62
61
|
</View>
|
|
63
62
|
)
|
|
64
63
|
} else {
|
|
65
64
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
66
65
|
const { ref, inView } = useInView({
|
|
67
66
|
threshold: 0,
|
|
68
67
|
triggerOnce: true,
|
|
69
68
|
root: rootDom || null,
|
|
70
69
|
rootMargin: `0px 0px 0px 0px`,
|
|
71
70
|
})
|
|
72
71
|
useEffect(() => {
|
|
73
72
|
if (inView) {
|
|
74
73
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
75
74
|
console.log('InViewRender -- 其它H5 展示啦!')
|
|
76
75
|
}
|
|
77
76
|
}, [inView])
|
|
78
77
|
return (
|
|
79
78
|
<View
|
|
80
79
|
ref={ref}
|
|
81
80
|
style={{
|
|
82
81
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
83
82
|
backgroundColor: 'transparent',
|
|
84
83
|
}}
|
|
85
84
|
>
|
|
86
85
|
{inView ? children : placeholder}
|
|
87
86
|
</View>
|
|
88
87
|
)
|
|
89
88
|
}
|
|
90
89
|
children: null,
|
|
91
90
|
placeholder: null,
|
|
92
91
|
height: 1,
|
|
93
92
|
className: '',
|
|
94
93
|
lazyNodeClassName: '',
|
|
95
94
|
inViewCallback: null,
|
|
95
|
+
import Taro from '@tarojs/taro'
|
|
96
96
|
TaroEventType,
|
|
97
97
|
const {
|
|
98
98
|
children,
|
|
99
99
|
placeholder,
|
|
100
100
|
height,
|
|
101
101
|
inViewCallback
|
|
102
102
|
} = props
|
|
103
103
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
104
104
|
const [componentRenderShowState, setComponentRenderShowState] =
|
|
105
105
|
useState(false)
|
|
106
106
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
107
107
|
const componentShowStateRef = useRef(false)
|
|
108
108
|
if (isH5AndJdShopView) {
|
|
109
109
|
useEffect(() => {
|
|
110
110
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
111
111
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
112
112
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
113
113
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
114
114
|
})
|
|
115
115
|
}, [])
|
|
116
116
|
useEffect(() => {
|
|
117
117
|
if (componentShowState) {
|
|
118
118
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
119
119
|
console.log('InViewRender -- 店铺H5 展示啦!')
|
|
120
120
|
}
|
|
121
121
|
}, [componentShowState])
|
|
122
122
|
|
|
123
123
|
const dealPageScrollInfo = (res) => {
|
|
124
124
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
125
125
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
126
126
|
if (componentLazyRef.current) {
|
|
127
127
|
const eleClientRect =
|
|
128
128
|
componentLazyRef.current.getBoundingClientRect()
|
|
129
129
|
const getContainerHeightOffSetY = displayHeight + offSetY
|
|
130
130
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
131
131
|
if (!componentShowStateRef.current) {
|
|
132
132
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
133
133
|
componentShowStateRef.current = true
|
|
134
134
|
setComponentShowState(true)
|
|
135
135
|
Taro.nextTick(() => {
|
|
136
136
|
setComponentRenderShowState(true)
|
|
137
137
|
})
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
return (
|
|
143
143
|
<View
|
|
144
144
|
ref={componentLazyRef}
|
|
145
145
|
className={classNames(
|
|
146
146
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
147
147
|
'd-app-floor-lazy-load',
|
|
148
148
|
)}
|
|
149
149
|
style={{
|
|
150
150
|
minHeight: `${componentRenderShowState ? 'auto' : height + (typeof height === 'number' ? 'px' : '')
|
|
151
151
|
}`,
|
|
152
152
|
backgroundColor: componentRenderShowState
|
|
153
153
|
? 'transparent'
|
|
154
154
|
: '#ffffff',
|
|
155
155
|
}}
|
|
156
156
|
>
|
|
157
157
|
{componentShowState ? children : placeholder}
|
|
158
158
|
</View>
|
|
159
159
|
)
|
|
160
160
|
} else {
|
|
161
161
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
162
162
|
const { ref, inView } = useInView({
|
|
163
163
|
threshold: 0,
|
|
164
164
|
triggerOnce: true,
|
|
165
165
|
root: rootDom || null,
|
|
166
166
|
rootMargin: `0px 0px 0px 0px`,
|
|
167
167
|
})
|
|
168
168
|
useEffect(() => {
|
|
169
169
|
if (inView) {
|
|
170
170
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
171
171
|
console.log('InViewRender -- 其它H5 展示啦!')
|
|
172
172
|
}
|
|
173
173
|
}, [inView])
|
|
174
174
|
return (
|
|
175
175
|
<View
|
|
176
176
|
ref={ref}
|
|
177
177
|
style={{
|
|
178
178
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
179
179
|
backgroundColor: 'transparent',
|
|
180
180
|
}}
|
|
181
181
|
>
|
|
182
182
|
{inView ? children : placeholder}
|
|
183
183
|
</View>
|
|
184
184
|
)
|
|
185
185
|
}
|
|
186
186
|
children: null,
|
|
187
187
|
placeholder: null,
|
|
188
188
|
height: 1,
|
|
189
189
|
className: '',
|
|
190
190
|
lazyNodeClassName: '',
|
|
191
191
|
inViewCallback: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro, { useRouter } from '@tarojs/taro'
|
|
2
1
|
floorData = {},
|
|
3
2
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
4
3
|
root: rootDom,
|
|
5
4
|
rootMargin: `0px 0px ${window.innerHeight}px 0px`,
|
|
6
5
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
7
6
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
8
7
|
useEffect(() => {
|
|
9
8
|
if(componentShowState === true){
|
|
10
9
|
console.log('>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!')
|
|
11
10
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
12
11
|
nativePageRegisterMessage(
|
|
13
12
|
Message_Type.NATIVE_INJECT_JS_FILE,
|
|
14
13
|
{
|
|
15
14
|
data: {
|
|
16
15
|
"bundleUrl": [bundleUrl]
|
|
17
16
|
},
|
|
18
17
|
},
|
|
19
18
|
)
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
}, [componentShowState])
|
|
23
22
|
ref={ref}
|
|
23
|
+
import Taro, { useRouter } from '@tarojs/taro'
|
|
24
24
|
floorData = {},
|
|
25
25
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
26
26
|
root: rootDom,
|
|
27
27
|
rootMargin: `0px 0px ${window.innerHeight}px 0px`,
|
|
28
28
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
29
29
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
if(componentShowState === true){
|
|
32
32
|
console.log('>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!')
|
|
33
33
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
34
34
|
nativePageRegisterMessage(
|
|
35
35
|
Message_Type.NATIVE_INJECT_JS_FILE,
|
|
36
36
|
{
|
|
37
37
|
data: {
|
|
38
38
|
"bundleUrl": [bundleUrl]
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}, [componentShowState])
|
|
45
45
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
46
46
|
ref={ref}
|