优化活动加载更多
This commit is contained in:
@@ -125,29 +125,35 @@ const ListContainer = (props) => {
|
||||
|
||||
// 对于没有ntrp等级的用户每个月展示一次, 插在第二个位置后面
|
||||
function insertEvaluateCard(list) {
|
||||
if (!evaluateFlag) return list;
|
||||
if (!evaluateFlag)
|
||||
return showNumber !== undefined ? list.slice(0, showNumber) : list;
|
||||
if (!list || list.length === 0) {
|
||||
return list;
|
||||
}
|
||||
// 如果最近一个月有测试记录,则不插入 card
|
||||
if (hasTestInLastMonth) {
|
||||
return list;
|
||||
return showNumber !== undefined ? list.slice(0, showNumber) : list;
|
||||
}
|
||||
|
||||
if (list.length <= 2) {
|
||||
return [...list, { type: "evaluateCard" }];
|
||||
}
|
||||
const [item1, item2, ...rest] = list;
|
||||
return [item1, item2, { type: "evaluateCard" }, ...rest];
|
||||
return [
|
||||
item1,
|
||||
item2,
|
||||
{ type: "evaluateCard" },
|
||||
...(showNumber !== undefined ? rest.slice(0, defaultShowNum - 2) : rest),
|
||||
];
|
||||
}
|
||||
|
||||
const memoizedList = useMemo(
|
||||
() => insertEvaluateCard(data),
|
||||
[evaluateFlag, data, hasTestInLastMonth]
|
||||
[evaluateFlag, data, hasTestInLastMonth, showNumber]
|
||||
);
|
||||
|
||||
// 渲染列表
|
||||
const renderList = (list) => {
|
||||
const renderList = () => {
|
||||
// 请求数据为空
|
||||
if (isShowNoData) {
|
||||
return (
|
||||
@@ -162,8 +168,6 @@ const ListContainer = (props) => {
|
||||
);
|
||||
}
|
||||
|
||||
showNumber !== undefined && (list = list.slice(0, showNumber));
|
||||
|
||||
// 渲染数据
|
||||
return (
|
||||
<>
|
||||
@@ -181,7 +185,7 @@ const ListContainer = (props) => {
|
||||
|
||||
return (
|
||||
<View className="listContentWrapper" style={style}>
|
||||
{renderList(data)}
|
||||
{renderList()}
|
||||
{/* 显示骨架屏 - 只有在 loading 超过 300ms 时才显示 */}
|
||||
{loading && showSkeleton && renderSkeleton()}
|
||||
{/* <View className="recommendTextWrapper">
|
||||
|
||||
Reference in New Issue
Block a user