✨ feat(邀请码): 完成邀请码对接
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useMemo, useState } from 'react'
|
||||
import React, { memo, useMemo, useState } from 'react'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import style from './index.module.scss'
|
||||
import DotLoading from '@/components/dotLoading'
|
||||
import Empty from '../empty'
|
||||
import Empty from '@/components/empty'
|
||||
import { SEARCH_EMPTY_IMAGE } from '@/common/constant'
|
||||
|
||||
export type StatusParam = 0|1|2|3
|
||||
export type StatusParam = 0 | 1 | 2 | 3
|
||||
|
||||
interface Params {
|
||||
styleObj?: Object
|
||||
styleObj?: React.CSSProperties
|
||||
selfonScrollToLower?: () => void
|
||||
hasMore?: false|true
|
||||
moreStatus?: false|true
|
||||
enableLoadMoreStatus?: boolean
|
||||
safeAreaInsetBottom?: boolean
|
||||
moreStatus?: boolean
|
||||
statusMore?: StatusParam // 0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode
|
||||
lowerThresholdNum?: number
|
||||
@@ -26,7 +27,11 @@ interface Params {
|
||||
paddingBottom?: number
|
||||
refresherTriggered?: boolean
|
||||
refresherEnabled?: boolean
|
||||
enableBackToTop?: boolean
|
||||
emptySlot?: React.ReactNode
|
||||
moreText?: string
|
||||
loadingText?: string
|
||||
noMoreText?: string
|
||||
}
|
||||
const InfiniteScroll = ({
|
||||
styleObj,
|
||||
@@ -37,7 +42,8 @@ const InfiniteScroll = ({
|
||||
selfOnRefresherRefresh,
|
||||
selfOnRefresherRestore,
|
||||
selfOnRefresherAbort,
|
||||
emptySlot,
|
||||
safeAreaInsetBottom = true,
|
||||
enableLoadMoreStatus = true,
|
||||
children,
|
||||
lowerThresholdNum = 5,
|
||||
paddingBottom = 0,
|
||||
@@ -45,6 +51,8 @@ const InfiniteScroll = ({
|
||||
refresherEnabled = false,
|
||||
moreStatus = true,
|
||||
statusMore = 0,
|
||||
enableBackToTop = true,
|
||||
emptySlot,
|
||||
}: Params) => {
|
||||
const scrollToLower = () => {
|
||||
selfonScrollToLower?.()
|
||||
@@ -75,9 +83,54 @@ const InfiniteScroll = ({
|
||||
}
|
||||
}, [statusMore])
|
||||
|
||||
const component = () => {
|
||||
if (enableLoadMoreStatus) {
|
||||
if (!moreStatus) {
|
||||
return (
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<>
|
||||
{(statusMore == 2 || statusMore == 3) && (
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{statusMore == 2
|
||||
? (
|
||||
<View className={style.loading_more}>
|
||||
加载中
|
||||
<DotLoading />
|
||||
</View>
|
||||
)
|
||||
: (
|
||||
<View className={style.noMore}>没有更多数据了</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{statusMore == 0 && <LoadingCard />}
|
||||
{statusMore == 1 && (emptySlot || <Empty picUrl={SEARCH_EMPTY_IMAGE} text="暂无数据" />)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
id="infiniteScroll"
|
||||
style={styleObj}
|
||||
className={style.scroll_main}
|
||||
scrollY
|
||||
@@ -92,33 +145,15 @@ const InfiniteScroll = ({
|
||||
onRefresherRestore={() => refresherRestore()}
|
||||
onRefresherAbort={() => refresherAbort()}
|
||||
refresherBackground="#F8F8F8"
|
||||
enableBackToTop={enableBackToTop}
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{!moreStatus
|
||||
? <>
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
</>
|
||||
: <>
|
||||
{(statusMore == 2 || statusMore == 3) && <View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{
|
||||
(statusMore == 2)
|
||||
? <View className={style.loading_more}>加载中<DotLoading /></View>
|
||||
: <View className={style.noMore}>没有更多数据了</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
{(statusMore == 0) && <LoadingCard />}
|
||||
{statusMore == 1 && (emptySlot || <Empty picUrl={SEARCH_EMPTY_IMAGE} text="暂无数据" />)}
|
||||
</>}
|
||||
|
||||
<View className="common_safe_area_y"></View>
|
||||
{component()}
|
||||
{safeAreaInsetBottom && <View className="common_safe_area_y"></View>}
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default memo(InfiniteScroll)
|
||||
export default memo(
|
||||
InfiniteScroll,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user