往期球局

This commit is contained in:
2025-09-16 14:35:34 +08:00
parent 4a00c7f1d8
commit 6516e1f0c9
3 changed files with 89 additions and 10 deletions

View File

@@ -45,6 +45,8 @@ const OtherUserPage: React.FC = () => {
// 模拟球局数据
const [game_records, setGameRecords] = useState<GameRecord[]>([]);
// 往期球局
const [ended_game_records, setEndedGameRecords] = useState<GameRecord[]>([]);
// 关注状态
const [is_following, setIsFollowing] = useState(false);
@@ -70,8 +72,9 @@ const OtherUserPage: React.FC = () => {
nickname: userData.nickname || "",
avatar: userData.avatar_url || "",
join_date: userData.subscribe_time
? `${new Date(userData.subscribe_time).getFullYear()}${new Date(userData.subscribe_time).getMonth() + 1
}月加入`
? `${new Date(userData.subscribe_time).getFullYear()}${
new Date(userData.subscribe_time).getMonth() + 1
}月加入`
: "",
stats: {
following: userData.stats?.following_count || 0,
@@ -102,6 +105,25 @@ const OtherUserPage: React.FC = () => {
load_user_data();
}, [user_id]);
const classifyGameRecords = (
game_records: GameRecord[]
): { notEndGames: GameRecord[]; finishedGames: GameRecord[] } => {
const timestamp = new Date().getTime();
return game_records.reduce(
(result, cur) => {
const { end_time } = cur;
timestamp > new Date(end_time).getTime()
? result.notEndGames.push(cur)
: result.finishedGames.push(cur);
return result;
},
{
notEndGames: [] as GameRecord[],
finishedGames: [] as GameRecord[],
}
);
};
const load_game_data = async () => {
try {
set_loading(true);
@@ -109,7 +131,9 @@ const OtherUserPage: React.FC = () => {
user_id || "",
active_tab
);
setGameRecords(games_data);
const { notEndGames, finishedGames } = classifyGameRecords(games_data);
setGameRecords(notEndGames);
setEndedGameRecords(finishedGames);
} catch (error) {
console.error("加载球局数据失败:", error);
Taro.showToast({
@@ -166,7 +190,12 @@ const OtherUserPage: React.FC = () => {
<View className="other_user_page">
<View className="custom-navbar">
<View className="detail-navigator">
<View className="detail-navigator-back" onClick={() => { Taro.navigateBack() }}>
<View
className="detail-navigator-back"
onClick={() => {
Taro.navigateBack();
}}
>
<Image
className="detail-navigator-back-icon"
src={img.ICON_NAVIGATOR_BACK}
@@ -211,7 +240,42 @@ const OtherUserPage: React.FC = () => {
loading={loading}
error={null}
reload={load_game_data}
loadMoreMatches={() => { }}
loadMoreMatches={() => {}}
/>
</ScrollView>
</View>
{/* 球局卡片 */}
{/* <View className="game_cards">
{game_records.map((game) => (
<GameCard
key={game.id}
game={game}
on_click={handle_game_detail}
/>
))}
</View> */}
</View>
{/* 往期球局 */}
<View className="ended_game_text"></View>
<View className="game_list_section">
<View className="date_header">
<Text className="date_text">529</Text>
<Text className="separator">/</Text>
<Text className="weekday_text"></Text>
</View>
{/* 球局列表 */}
<View className="game_list_section">
<ScrollView scrollY>
<ListContainer
data={ended_game_records}
recommendList={[]}
loading={loading}
error={null}
reload={load_game_data}
loadMoreMatches={() => {}}
/>
</ScrollView>
</View>