往期球局排序处理

This commit is contained in:
2026-02-25 16:37:47 +08:00
parent baa60bbfcb
commit 4a553c63fc
2 changed files with 27 additions and 25 deletions

View File

@@ -89,11 +89,10 @@ const MyselfPage: React.FC = () => {
await fetchUserInfo(); await fetchUserInfo();
} }
// 获取测试结果 // 获取测试结果
const res = await evaluateService.getLastResult(); const res = await evaluateService.getLastResult();
if (res.code === 0) { if (res.code === 0) {
console.log( "getLastResult", res.data); console.log("getLastResult", res.data);
setHasTestInLastMonth(res.data.has_test_in_last_month); setHasTestInLastMonth(res.data.has_test_in_last_month);
} }
}; };
@@ -110,25 +109,28 @@ const MyselfPage: React.FC = () => {
}); });
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数) // 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
const classifyGameRecords = useCallback(( const classifyGameRecords = useCallback(
game_records: TennisMatch[] (
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => { game_records: TennisMatch[]
const now = new Date().getTime(); ): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
return game_records.reduce( const now = new Date().getTime();
(result, cur) => { return game_records.reduce(
let { end_time } = cur; (result, cur) => {
end_time = end_time.replace(/\s/, "T"); let { end_time } = cur;
new Date(end_time).getTime() > now end_time = end_time.replace(/\s/, "T");
? result.notEndGames.push(cur) new Date(end_time).getTime() > now
: result.finishedGames.push(cur); ? result.notEndGames.push(cur)
return result; : result.finishedGames.unshift(cur);
}, return result;
{ },
notEndGames: [] as TennisMatch[], {
finishedGames: [] as TennisMatch[], notEndGames: [] as TennisMatch[],
} finishedGames: [] as TennisMatch[],
); }
}, []); );
},
[]
);
// 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数) // 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
const load_game_data = useCallback(async () => { const load_game_data = useCallback(async () => {
@@ -272,7 +274,7 @@ const MyselfPage: React.FC = () => {
</View> </View>
{/* 球局列表 */} {/* 球局列表 */}
<View className="game_list_section" > <View className="game_list_section">
<ScrollView scrollY refresherBackground="#FAFAFA"> <ScrollView scrollY refresherBackground="#FAFAFA">
<ListContainer <ListContainer
data={game_records} data={game_records}

View File

@@ -141,7 +141,7 @@ const OtherUserPage: React.FC = () => {
end_time = end_time.replace(/\s/, "T"); end_time = end_time.replace(/\s/, "T");
new Date(end_time).getTime() > now new Date(end_time).getTime() > now
? result.notEndGames.push(cur) ? result.notEndGames.push(cur)
: result.finishedGames.push(cur); : result.finishedGames.unshift(cur);
return result; return result;
}, },
{ {