往期球局排序处理

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

@@ -16,7 +16,7 @@ import { waitForAuthInit } from "@/utils/authInit";
const MyselfPage: React.FC = () => {
const pickerOption = usePickerOption();
// 获取页面参数
const instance = Taro.getCurrentInstance();
const user_id = instance.router?.params?.userid || "";
@@ -38,7 +38,7 @@ const MyselfPage: React.FC = () => {
// 最近一个月是否有测试记录
const [has_test_in_last_month, setHasTestInLastMonth] = useState(false);
const { fetchUserInfo } = useUserActions();
// 当前激活的标签页
@@ -89,11 +89,10 @@ const MyselfPage: React.FC = () => {
await fetchUserInfo();
}
// 获取测试结果
const res = await evaluateService.getLastResult();
if (res.code === 0) {
console.log( "getLastResult", res.data);
console.log("getLastResult", res.data);
setHasTestInLastMonth(res.data.has_test_in_last_month);
}
};
@@ -110,25 +109,28 @@ const MyselfPage: React.FC = () => {
});
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
const classifyGameRecords = useCallback((
game_records: TennisMatch[]
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
const now = new Date().getTime();
return game_records.reduce(
(result, cur) => {
let { end_time } = cur;
end_time = end_time.replace(/\s/, "T");
new Date(end_time).getTime() > now
? result.notEndGames.push(cur)
: result.finishedGames.push(cur);
return result;
},
{
notEndGames: [] as TennisMatch[],
finishedGames: [] as TennisMatch[],
}
);
}, []);
const classifyGameRecords = useCallback(
(
game_records: TennisMatch[]
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
const now = new Date().getTime();
return game_records.reduce(
(result, cur) => {
let { end_time } = cur;
end_time = end_time.replace(/\s/, "T");
new Date(end_time).getTime() > now
? result.notEndGames.push(cur)
: result.finishedGames.unshift(cur);
return result;
},
{
notEndGames: [] as TennisMatch[],
finishedGames: [] as TennisMatch[],
}
);
},
[]
);
// 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
const load_game_data = useCallback(async () => {
@@ -272,7 +274,7 @@ const MyselfPage: React.FC = () => {
</View>
{/* 球局列表 */}
<View className="game_list_section" >
<View className="game_list_section">
<ScrollView scrollY refresherBackground="#FAFAFA">
<ListContainer
data={game_records}

View File

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