往期球局排序处理
This commit is contained in:
@@ -16,7 +16,7 @@ import { waitForAuthInit } from "@/utils/authInit";
|
|||||||
|
|
||||||
const MyselfPage: React.FC = () => {
|
const MyselfPage: React.FC = () => {
|
||||||
const pickerOption = usePickerOption();
|
const pickerOption = usePickerOption();
|
||||||
|
|
||||||
// 获取页面参数
|
// 获取页面参数
|
||||||
const instance = Taro.getCurrentInstance();
|
const instance = Taro.getCurrentInstance();
|
||||||
const user_id = instance.router?.params?.userid || "";
|
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 [has_test_in_last_month, setHasTestInLastMonth] = useState(false);
|
||||||
|
|
||||||
const { fetchUserInfo } = useUserActions();
|
const { fetchUserInfo } = useUserActions();
|
||||||
|
|
||||||
// 当前激活的标签页
|
// 当前激活的标签页
|
||||||
@@ -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}
|
||||||
|
|||||||
@@ -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;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user