This commit is contained in:
张成
2026-02-09 13:25:13 +08:00
parent 632da5112d
commit cab90aa1cb
6 changed files with 164 additions and 41 deletions

View File

@@ -1,6 +1,7 @@
import React, { useState } from "react";
import { View, Text, Button, Image } from "@tarojs/components";
import Taro, { useRouter } from "@tarojs/taro";
import { GeneralNavbar } from "@/components";
import {
wechat_auth_login,
save_login_state,
@@ -171,6 +172,8 @@ const LoginPage: React.FC = () => {
<View className="bg_overlay"></View>
</View>
<GeneralNavbar title="" showBack={true} showAvatar={false} onBack={handle_return_home} />
{/* 主要内容 */}
<View className="login_main_content">
{/* 品牌区域 */}
@@ -216,9 +219,9 @@ const LoginPage: React.FC = () => {
<Text className="button_text"></Text>
</Button>
<View className="return_home_button link_button" onClick={handle_return_home}>
{/* <View className="return_home_button link_button" onClick={handle_return_home}>
<Text className="button_text">返回首页</Text>
</View>
</View> */}
{/* 用户协议复选框 */}
<View className="terms_checkbox_section">

View File

@@ -65,20 +65,22 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
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[],
}
);
// 使用for
const notEndGames: TennisMatch[] = [];
const finishedGames: TennisMatch[] = [];
for (const game of game_records) {
const { end_time } = game;
const end_time_str = end_time.replace(/\s/, "T");
new Date(end_time_str).getTime() > now
? notEndGames.push(game)
: finishedGames.push(game);
}
console.log("notEndGames", notEndGames);
return { notEndGames, finishedGames };
},
[]
);
@@ -95,6 +97,8 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
} else {
games_data = await UserService.get_participated_games(user_info.id);
}
const sorted_games = games_data.sort((a, b) => {
return (
new Date(a.original_start_time.replace(/\s/, "T")).getTime() -
@@ -102,6 +106,8 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
);
});
const { notEndGames, finishedGames } = classifyGameRecords(sorted_games);
console.log("notEndGames", notEndGames);
set_game_records(notEndGames);
setEndedGameRecords(finishedGames);
} catch (error) {
@@ -250,17 +256,15 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
<View className={styles.gameTabsSection}>
<View className={styles.tabContainer}>
<View
className={`${styles.tabItem} ${
active_tab === "hosted" ? styles.active : ""
}`}
className={`${styles.tabItem} ${active_tab === "hosted" ? styles.active : ""
}`}
onClick={() => setActiveTab("hosted")}
>
<Text className={styles.tabText}></Text>
</View>
<View
className={`${styles.tabItem} ${
active_tab === "participated" ? styles.active : ""
}`}
className={`${styles.tabItem} ${active_tab === "participated" ? styles.active : ""
}`}
onClick={() => setActiveTab("participated")}
>
<Text className={styles.tabText}></Text>
@@ -281,7 +285,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
btnImg="ICON_ADD"
reload={goPublish}
isShowNoData={game_records.length === 0}
loadMoreMatches={() => {}}
loadMoreMatches={() => { }}
collapse={true}
style={{
paddingBottom: ended_game_records.length ? 0 : "90px",
@@ -308,7 +312,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
error={null}
errorImg="ICON_LIST_EMPTY_CARD"
isShowNoData={ended_game_records.length === 0}
loadMoreMatches={() => {}}
loadMoreMatches={() => { }}
collapse={true}
style={{ paddingBottom: "90px", overflow: "hidden" }}
listLoadErrorWrapperHeight="fit-content"

View File

@@ -249,7 +249,7 @@ const CommentReply = () => {
<View className="comment-left">
<Image
className="user-avatar"
src={item.user_avatar || "https://img.yzcdn.cn/vant/cat.jpeg"}
src={item.user_avatar }
mode="aspectFill"
onClick={(e) => handleUserClick(e, item.user_id)}
/>

View File

@@ -151,6 +151,7 @@ interface BackendGameData {
longitude: string;
venue_type: string;
surface_type: string;
distance_km: string;
};
participants: {
user: {
@@ -206,7 +207,7 @@ export class UserService {
latitude = parseFloat(game.venue_dtl.latitude) || latitude;
longitude = parseFloat(game.venue_dtl.longitude) || longitude;
}
const distance = this.calculate_distance(latitude, longitude);
// 处理地点信息 - 优先使用venue_dtl中的信息
let location = game.location_name || game.location || "未知地点";
@@ -227,7 +228,7 @@ export class UserService {
original_start_time: game.start_time,
end_time: game.end_time || "",
location: location,
distance_km: parseFloat(distance.replace("km", "")) || 0,
distance_km: game.venue_dtl?.distance_km ,
current_players: registered_count,
max_players: max_count,
skill_level_min: parseInt(game.skill_level_min) || 0,
@@ -303,20 +304,7 @@ export class UserService {
return `${date_str} ${time_str}`;
}
// 计算距离(模拟实现,实际需要根据用户位置计算)
private static calculate_distance(
latitude: number,
longitude: number
): string {
if (latitude === 0 && longitude === 0) {
return "未知距离";
}
// 这里应该根据用户当前位置计算实际距离
// 暂时返回模拟距离
const distances = ["1.2km", "2.5km", "3.8km", "5.1km", "7.3km"];
return distances[Math.floor(Math.random() * distances.length)];
}
// 获取用户信息
static async get_user_info(user_id?: string): Promise<UserInfo> {
try {