处理列表

This commit is contained in:
李瑞
2025-09-13 17:49:59 +08:00
parent aef84e76cb
commit ba7d904134
15 changed files with 226 additions and 194 deletions

View File

@@ -2,9 +2,8 @@ import { View } from "@tarojs/components";
import ListCard from "@/components/ListCard";
import ListLoadError from "@/components/ListLoadError";
import ListCardSkeleton from "@/components/ListCardSkeleton";
// import { VirtualList } from '@nutui/nutui-react-taro'
import "./index.scss";
import { useReachBottom } from "@tarojs/taro";
import "./index.scss";
const ListContainer = (props) => {
const {
@@ -12,14 +11,12 @@ const ListContainer = (props) => {
data = [],
error,
reload,
recommendList,
// recommendList,
loadMoreMatches,
} = props;
console.log("===data", data);
useReachBottom(() => {
console.log("触底了");
// 调用 store 的加载更多方法
// 加载更多方法
loadMoreMatches();
});
@@ -39,17 +36,6 @@ const ListContainer = (props) => {
// 渲染列表
const renderList = (list) => {
// 请求未回来显示骨架屏
// if (loading && list?.length === 0) {
// return (
// <>
// {new Array(10).fill(0).map(() => {
// return <ListCardSkeleton />;
// })}
// </>
// );
// }
// 请求数据为空
if (!loading && list?.length === 0) {
return <ListLoadError reload={reload} text="暂无数据" />;
@@ -58,15 +44,6 @@ const ListContainer = (props) => {
// 渲染数据
return (
<>
{/* <VirtualList
containerHeight={1000}
itemHeight={144}
// itemEqual={false}
list={list}
itemRender={(data) => {
return <ListCard {...data}/>
}}
/> */}
{list?.map((match, index) => (
<ListCard key={match.id || index} {...match} />
))}
@@ -76,15 +53,25 @@ const ListContainer = (props) => {
return (
<View className="listContentWrapper">
{renderList(data)}
{/* 显示骨架屏 */}
{loading && renderSkeleton()}
{/* <View className="recommendTextWrapper">
{/* <ScrollView
scrollY
scrollWithAnimation
enableBackToTop
enablePassive
style={{ height: '100vh' }}
onScrollToLower={handleScrollToLower}
upperThreshold={60}
> */}
{renderList(data)}
{/* 显示骨架屏 */}
{loading && renderSkeleton()}
{/* <View className="recommendTextWrapper">
<Text className="recommendText">搜索结果较少,已为你推荐其他内容</Text>
</View>
{renderList(recommendList)} */}
{/* 到底了 */}
{data?.length > 0 && <View className="bottomTextWrapper"></View>}
{/* 到底了 */}
{data?.length > 0 && <View className="bottomTextWrapper"></View>}
{/* </ScrollView> */}
</View>
);
};