@conecli/cone-render 0.10.1-beta.3 → 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/ExposureSmart/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.module.scss +8 -0
- 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/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/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/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
|
-
import Taro, { useRouter } from '@tarojs/taro'
|
|
2
1
|
isH5AndJdShopView,
|
|
3
2
|
isH5AndJdShopViewH5Scroll,
|
|
4
3
|
sgmCustomReport,
|
|
5
4
|
getSgmCustomCode,
|
|
6
5
|
SECTION_HOME_TAB_TYPE,
|
|
7
6
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
8
7
|
TaroEventType,
|
|
9
8
|
latestFromNativeMsgStorage,
|
|
10
9
|
nativePageRegisterMessage,
|
|
11
10
|
Message_Type,
|
|
12
11
|
getNativePageScrollRes,
|
|
13
12
|
const {
|
|
14
13
|
children,
|
|
15
14
|
containerId,
|
|
16
15
|
type,
|
|
17
16
|
placeholder,
|
|
18
17
|
height,
|
|
19
18
|
floorData = {},
|
|
20
19
|
sectionType,
|
|
21
20
|
lazyNodeClassName,
|
|
22
21
|
} = props
|
|
23
22
|
const getRouterInfo = useRouter()
|
|
24
23
|
const getQueryData = getRouterInfo?.params || {}
|
|
25
24
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
26
25
|
const [componentRenderShowState, setComponentRenderShowState] = useState(
|
|
27
26
|
false,
|
|
28
27
|
)
|
|
29
28
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
30
29
|
const componentShowStateRef = useRef(false)
|
|
31
30
|
const needShowHighVersion =
|
|
32
31
|
isH5AndJdShopViewH5Scroll &&
|
|
33
32
|
!(
|
|
34
33
|
global.info.queryInfo?.downgraded &&
|
|
35
34
|
global.info.queryInfo.downgraded === 'true'
|
|
36
35
|
)
|
|
37
36
|
const rootDom =
|
|
38
37
|
isH5AndJdShopView && needShowHighVersion
|
|
39
38
|
? null
|
|
40
39
|
: document.querySelector('#J_shopHomeRoot')
|
|
41
40
|
const { ref, inView } = useInView({
|
|
42
41
|
threshold: 0,
|
|
43
42
|
triggerOnce: true,
|
|
44
43
|
root: rootDom,
|
|
45
44
|
rootMargin: `0px 0px ${window.innerHeight}px 0px`,
|
|
46
45
|
})
|
|
47
46
|
useEffect(() => {
|
|
48
47
|
if (needShowHighVersion || !isH5AndJdShopView) return
|
|
49
48
|
if (type === LazyType.FLOOR) {
|
|
50
49
|
const latestRes =
|
|
51
50
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
52
51
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes, false)
|
|
53
52
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, res => {
|
|
54
53
|
!componentShowStateRef.current && dealPageScrollInfo(res, true)
|
|
55
54
|
})
|
|
56
55
|
}
|
|
57
56
|
}, [])
|
|
58
57
|
useEffect(() => {
|
|
59
58
|
if (
|
|
60
59
|
(!needShowHighVersion && componentShowState === true) ||
|
|
61
60
|
(needShowHighVersion && inView && isH5AndJdShopView)
|
|
62
61
|
) {
|
|
63
62
|
console.log(
|
|
64
63
|
'>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!',
|
|
65
64
|
)
|
|
66
65
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
67
66
|
const modularPackResultObj =
|
|
68
67
|
typeof modularPackResult === 'string'
|
|
69
68
|
? JSON.parse(modularPackResult)
|
|
70
69
|
: modularPackResult
|
|
71
70
|
if (modularPackResultObj && modularPackResultObj.bundleUrl) {
|
|
72
71
|
const { bundleUrl } = modularPackResultObj
|
|
73
72
|
nativePageRegisterMessage(Message_Type.NATIVE_INJECT_JS_FILE, {
|
|
74
73
|
data: {
|
|
75
74
|
bundleUrl: [bundleUrl],
|
|
76
75
|
},
|
|
77
76
|
})
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}, [componentShowState, inView])
|
|
81
80
|
|
|
82
81
|
const dealPageScrollInfo = (res, pageScrollTrigger) => {
|
|
83
82
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
84
83
|
if (
|
|
85
84
|
typeof displayHeight === 'undefined' ||
|
|
86
85
|
typeof offSetY === 'undefined'
|
|
87
86
|
) {
|
|
88
87
|
const shopId = floorData?.floorExtInfo?.shopId
|
|
89
88
|
if (!lazyLayoutLoadErrorShopId[`${shopId}`] && pageScrollTrigger) {
|
|
90
89
|
const opt = {
|
|
91
90
|
msg: `店铺楼层懒加载失败。楼层顺序-floorIdx: ${floorData?.floorIdx}。`,
|
|
92
91
|
uid: floorData?.uid,
|
|
93
92
|
floorIdx: floorData?.floorIdx,
|
|
94
93
|
shopId: shopId,
|
|
95
94
|
moduleId: floorData?.moduleId,
|
|
96
95
|
moduleName: floorData?.moduleName,
|
|
97
96
|
middleTemplateId: floorData?.middleTemplateId,
|
|
98
97
|
modularPackResult:
|
|
99
98
|
typeof floorData?.floorExtInfo?.modularPackResult == 'string'
|
|
100
99
|
? JSON.parse(floorData?.floorExtInfo?.modularPackResult)
|
|
101
100
|
: floorData?.floorExtInfo?.modularPackResult,
|
|
102
101
|
}
|
|
103
102
|
sgmCustomReport({
|
|
104
103
|
code: getSgmCustomCode(SgmCustomCode.FLOORLAZYLOAD_DATA),
|
|
105
104
|
msg: opt,
|
|
106
105
|
})
|
|
107
106
|
lazyLayoutLoadErrorShopId[`${shopId}`] = true
|
|
108
107
|
}
|
|
109
108
|
return
|
|
110
109
|
}
|
|
111
110
|
if (componentLazyRef.current) {
|
|
112
111
|
const eleClientRect = componentLazyRef.current.getBoundingClientRect()
|
|
113
112
|
const getContainerHeightOffSetY = displayHeight + offSetY
|
|
114
113
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
115
114
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
116
115
|
const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight
|
|
117
116
|
if (!componentShowStateRef.current) {
|
|
118
117
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
119
118
|
componentShowStateRef.current = true
|
|
120
119
|
setComponentShowState(true)
|
|
121
120
|
Taro.nextTick(() => {
|
|
122
121
|
setComponentRenderShowState(true)
|
|
123
122
|
})
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
return isH5AndJdShopView && !needShowHighVersion ? (
|
|
129
128
|
<div
|
|
130
129
|
id={`${containerId}_lazy`}
|
|
131
130
|
ref={componentLazyRef}
|
|
132
131
|
className={classNames(
|
|
133
132
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
134
133
|
'd-app-floor-lazy-load',
|
|
135
134
|
)}
|
|
136
135
|
style={{
|
|
137
136
|
minHeight: `${componentRenderShowState ? 'auto' : height + 'px'}`,
|
|
138
137
|
backgroundColor: componentRenderShowState ? 'transparent' : '#ffffff',
|
|
139
138
|
}}
|
|
140
139
|
>
|
|
141
140
|
{componentShowState ? children : placeholder}
|
|
142
141
|
</div>
|
|
143
142
|
) : (
|
|
144
143
|
<div
|
|
145
144
|
id={`${containerId}_lazy`}
|
|
146
145
|
className={classNames(
|
|
147
146
|
lazyLayoutLoadStyle['d-mobile-floor-lazy-layout-load'],
|
|
148
147
|
'd-mobile-floor-lazy-load',
|
|
149
148
|
lazyNodeClassName,
|
|
150
149
|
)}
|
|
151
150
|
ref={ref}
|
|
152
151
|
style={{
|
|
153
152
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
154
153
|
backgroundColor: inView ? 'transparent' : '#ffffff',
|
|
155
154
|
}}
|
|
156
155
|
>
|
|
157
156
|
{inView ? children : placeholder}
|
|
158
157
|
</div>
|
|
159
158
|
)
|
|
160
159
|
sectionType:
|
|
161
160
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
|
|
162
161
|
type: LazyType.FLOOR,
|
|
163
162
|
children: null,
|
|
164
163
|
placeholder: null,
|
|
165
164
|
height: 200,
|
|
166
165
|
className: '',
|
|
167
166
|
lazyNodeClassName: '',
|
|
167
|
+
import Taro, { useRouter } from '@tarojs/taro'
|
|
168
168
|
isH5AndJdShopView,
|
|
169
169
|
isH5AndJdShopViewH5Scroll,
|
|
170
170
|
sgmCustomReport,
|
|
171
171
|
getSgmCustomCode,
|
|
172
172
|
SECTION_HOME_TAB_TYPE,
|
|
173
173
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
174
174
|
TaroEventType,
|
|
175
175
|
latestFromNativeMsgStorage,
|
|
176
176
|
nativePageRegisterMessage,
|
|
177
177
|
Message_Type,
|
|
178
178
|
getNativePageScrollRes,
|
|
179
179
|
const {
|
|
180
180
|
sectionType = SECTION_HOME_TAB_NAME_TYPE[
|
|
181
181
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
182
182
|
],
|
|
183
183
|
type = LazyType.FLOOR,
|
|
184
184
|
children = null,
|
|
185
185
|
placeholder = null,
|
|
186
186
|
height = 200,
|
|
187
187
|
className = '',
|
|
188
188
|
lazyNodeClassName = '',
|
|
189
189
|
containerId,
|
|
190
190
|
floorData = {},
|
|
191
191
|
} = props
|
|
192
192
|
const getRouterInfo = useRouter()
|
|
193
193
|
const getQueryData = getRouterInfo?.params || {}
|
|
194
194
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
195
195
|
const [componentRenderShowState, setComponentRenderShowState] =
|
|
196
196
|
useState(false)
|
|
197
197
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
198
198
|
const componentShowStateRef = useRef(false)
|
|
199
199
|
const needShowHighVersion =
|
|
200
200
|
isH5AndJdShopViewH5Scroll &&
|
|
201
201
|
!(
|
|
202
202
|
global.info.queryInfo?.downgraded &&
|
|
203
203
|
global.info.queryInfo.downgraded === 'true'
|
|
204
204
|
)
|
|
205
205
|
const rootDom =
|
|
206
206
|
isH5AndJdShopView && needShowHighVersion
|
|
207
207
|
? null
|
|
208
208
|
: document.querySelector('#J_shopHomeRoot')
|
|
209
209
|
const { ref, inView } = useInView({
|
|
210
210
|
threshold: 0,
|
|
211
211
|
triggerOnce: true,
|
|
212
212
|
root: rootDom,
|
|
213
213
|
rootMargin: `0px 0px ${window.innerHeight}px 0px`,
|
|
214
214
|
})
|
|
215
215
|
useEffect(() => {
|
|
216
216
|
if (needShowHighVersion || !isH5AndJdShopView) return
|
|
217
217
|
if (type === LazyType.FLOOR) {
|
|
218
218
|
const latestRes =
|
|
219
219
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
220
220
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes, false)
|
|
221
221
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
222
222
|
!componentShowStateRef.current && dealPageScrollInfo(res, true)
|
|
223
223
|
})
|
|
224
224
|
}
|
|
225
225
|
}, [])
|
|
226
226
|
useEffect(() => {
|
|
227
227
|
if (
|
|
228
228
|
(!needShowHighVersion && componentShowState === true) ||
|
|
229
229
|
(needShowHighVersion && inView && isH5AndJdShopView)
|
|
230
230
|
) {
|
|
231
231
|
console.log(
|
|
232
232
|
'>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!',
|
|
233
233
|
)
|
|
234
234
|
const modularPackResult = floorData?.floorExtInfo?.modularPackResult
|
|
235
235
|
const modularPackResultObj =
|
|
236
236
|
typeof modularPackResult === 'string'
|
|
237
237
|
? JSON.parse(modularPackResult)
|
|
238
238
|
: modularPackResult
|
|
239
239
|
if (modularPackResultObj && modularPackResultObj.bundleUrl) {
|
|
240
240
|
const { bundleUrl } = modularPackResultObj
|
|
241
241
|
nativePageRegisterMessage(Message_Type.NATIVE_INJECT_JS_FILE, {
|
|
242
242
|
data: {
|
|
243
243
|
bundleUrl: [bundleUrl],
|
|
244
244
|
},
|
|
245
245
|
})
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}, [componentShowState, inView])
|
|
249
249
|
|
|
250
250
|
const dealPageScrollInfo = (res, pageScrollTrigger) => {
|
|
251
251
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
252
252
|
if (
|
|
253
253
|
typeof displayHeight === 'undefined' ||
|
|
254
254
|
typeof offSetY === 'undefined'
|
|
255
255
|
) {
|
|
256
256
|
const shopId = floorData?.floorExtInfo?.shopId
|
|
257
257
|
if (!lazyLayoutLoadErrorShopId[`${shopId}`] && pageScrollTrigger) {
|
|
258
258
|
const opt = {
|
|
259
259
|
msg: `店铺楼层懒加载失败。楼层顺序-floorIdx: ${floorData?.floorIdx}。`,
|
|
260
260
|
uid: floorData?.uid,
|
|
261
261
|
floorIdx: floorData?.floorIdx,
|
|
262
262
|
shopId: shopId,
|
|
263
263
|
moduleId: floorData?.moduleId,
|
|
264
264
|
moduleName: floorData?.moduleName,
|
|
265
265
|
middleTemplateId: floorData?.middleTemplateId,
|
|
266
266
|
}
|
|
267
267
|
sgmCustomReport({
|
|
268
268
|
code: getSgmCustomCode(SgmCustomCode.FLOORLAZYLOAD_DATA),
|
|
269
269
|
msg: opt,
|
|
270
270
|
})
|
|
271
271
|
lazyLayoutLoadErrorShopId[`${shopId}`] = true
|
|
272
272
|
}
|
|
273
273
|
return
|
|
274
274
|
}
|
|
275
275
|
if (componentLazyRef.current) {
|
|
276
276
|
const eleClientRect = componentLazyRef.current.getBoundingClientRect()
|
|
277
277
|
const getContainerHeightOffSetY = displayHeight + offSetY
|
|
278
278
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
279
279
|
const eleOffsetHeight = Math.ceil(eleClientRect.height)
|
|
280
280
|
const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight
|
|
281
281
|
if (!componentShowStateRef.current) {
|
|
282
282
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
283
283
|
componentShowStateRef.current = true
|
|
284
284
|
setComponentShowState(true)
|
|
285
285
|
Taro.nextTick(() => {
|
|
286
286
|
setComponentRenderShowState(true)
|
|
287
287
|
})
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
return isH5AndJdShopView && !needShowHighVersion ? (
|
|
293
293
|
<div
|
|
294
294
|
id={`${containerId}_lazy`}
|
|
295
295
|
ref={componentLazyRef}
|
|
296
296
|
className={classNames(
|
|
297
297
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
298
298
|
'd-app-floor-lazy-load',
|
|
299
299
|
)}
|
|
300
300
|
style={{
|
|
301
301
|
minHeight: `${componentRenderShowState ? 'auto' : height + 'px'}`,
|
|
302
302
|
backgroundColor: componentRenderShowState ? 'transparent' : '#ffffff',
|
|
303
303
|
}}
|
|
304
304
|
>
|
|
305
305
|
{componentShowState ? children : placeholder}
|
|
306
306
|
</div>
|
|
307
307
|
) : (
|
|
308
308
|
<div
|
|
309
309
|
id={`${containerId}_lazy`}
|
|
310
310
|
className={classNames(
|
|
311
311
|
lazyLayoutLoadStyle['d-mobile-floor-lazy-layout-load'],
|
|
312
312
|
'd-mobile-floor-lazy-load',
|
|
313
313
|
lazyNodeClassName,
|
|
314
314
|
)}
|
|
315
315
|
ref={ref}
|
|
316
316
|
style={{
|
|
317
317
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
318
318
|
backgroundColor: inView ? 'transparent' : '#ffffff',
|
|
319
319
|
}}
|
|
320
320
|
>
|
|
321
321
|
{inView ? children : placeholder}
|
|
322
322
|
</div>
|
|
323
323
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
SECTION_HOME_TAB_TYPE,
|
|
3
2
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
4
3
|
const {
|
|
5
4
|
children,
|
|
6
5
|
containerId,
|
|
7
6
|
type,
|
|
8
7
|
placeholder,
|
|
9
8
|
height,
|
|
10
9
|
sectionType,
|
|
11
10
|
lazyNodeClassName,
|
|
12
11
|
} = props
|
|
13
12
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
14
13
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
15
14
|
const lazyLayoutLoadFloor =
|
|
16
15
|
'lazy-layout-load-floor' + Math.floor(Math.random() * 10000000)
|
|
17
16
|
useEffect(() => {
|
|
18
17
|
Taro.nextTick(() => {
|
|
19
18
|
const createIntersectionObserver = new intersectionObserver({
|
|
20
19
|
selector: `.${lazyLayoutLoadFloor}`,
|
|
21
20
|
context: this,
|
|
22
21
|
onFinal: () => {
|
|
23
22
|
setComponentShowState(true)
|
|
24
23
|
createIntersectionObserver.disconnect()
|
|
25
24
|
},
|
|
26
25
|
})
|
|
27
26
|
createIntersectionObserver.connect()
|
|
28
27
|
})
|
|
29
28
|
}, [])
|
|
30
29
|
return type === LazyType.IMAGE ? (
|
|
31
30
|
children
|
|
32
31
|
) : (
|
|
33
32
|
<View
|
|
34
33
|
id={`${containerId}_lazy`}
|
|
35
34
|
ref={componentLazyRef}
|
|
36
35
|
className={classNames(
|
|
37
36
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
38
37
|
'd-app-floor-lazy-load',
|
|
39
38
|
lazyLayoutLoadFloor,
|
|
40
39
|
)}
|
|
41
40
|
style={{
|
|
42
41
|
minHeight: `${componentShowState ? 'auto' : height + 'px'}`,
|
|
43
42
|
backgroundColor: componentShowState ? 'transparent' : '#ffffff',
|
|
44
43
|
}}
|
|
45
44
|
>
|
|
46
45
|
{componentShowState ? children : placeholder}
|
|
47
46
|
</View>
|
|
48
47
|
)
|
|
49
48
|
sectionType:
|
|
50
49
|
SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
|
|
51
50
|
type: LazyType.FLOOR,
|
|
52
51
|
children: null,
|
|
53
52
|
placeholder: null,
|
|
54
53
|
height: 200,
|
|
55
54
|
className: '',
|
|
56
55
|
lazyNodeClassName: '',
|
|
56
|
+
import Taro from '@tarojs/taro'
|
|
57
57
|
SECTION_HOME_TAB_TYPE,
|
|
58
58
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
59
59
|
const {
|
|
60
60
|
sectionType = SECTION_HOME_TAB_NAME_TYPE[
|
|
61
61
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
62
62
|
],
|
|
63
63
|
type = LazyType.FLOOR,
|
|
64
64
|
children = null,
|
|
65
65
|
placeholder = null,
|
|
66
66
|
height = 200,
|
|
67
67
|
className = '',
|
|
68
68
|
lazyNodeClassName = '',
|
|
69
69
|
containerId,
|
|
70
70
|
} = props
|
|
71
71
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
72
72
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
73
73
|
const lazyLayoutLoadFloor =
|
|
74
74
|
'lazy-layout-load-floor' + Math.floor(Math.random() * 10000000)
|
|
75
75
|
useEffect(() => {
|
|
76
76
|
Taro.nextTick(() => {
|
|
77
77
|
const createIntersectionObserver = new intersectionObserver({
|
|
78
78
|
selector: `.${lazyLayoutLoadFloor}`,
|
|
79
79
|
context: this,
|
|
80
80
|
onFinal: () => {
|
|
81
81
|
setComponentShowState(true)
|
|
82
82
|
createIntersectionObserver.disconnect()
|
|
83
83
|
},
|
|
84
84
|
})
|
|
85
85
|
createIntersectionObserver.connect()
|
|
86
86
|
})
|
|
87
87
|
}, [])
|
|
88
88
|
return type === LazyType.IMAGE ? (
|
|
89
89
|
children
|
|
90
90
|
) : (
|
|
91
91
|
<View
|
|
92
92
|
id={`${containerId}_lazy`}
|
|
93
93
|
ref={componentLazyRef}
|
|
94
94
|
className={classNames(
|
|
95
95
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
96
96
|
'd-app-floor-lazy-load',
|
|
97
97
|
lazyLayoutLoadFloor,
|
|
98
98
|
)}
|
|
99
99
|
style={{
|
|
100
100
|
minHeight: `${componentShowState ? 'auto' : height + 'px'}`,
|
|
101
101
|
backgroundColor: componentShowState ? 'transparent' : '#ffffff',
|
|
102
102
|
}}
|
|
103
103
|
>
|
|
104
104
|
{componentShowState ? children : placeholder}
|
|
105
105
|
</View>
|
|
106
106
|
)
|