优化个人页

This commit is contained in:
2025-10-17 16:24:07 +08:00
parent 8f688378e1
commit f3ab0020d3
7 changed files with 549 additions and 429 deletions

View File

@@ -9,10 +9,10 @@ import {
UserInfoCard,
// GameCard,
GameTabs,
UserInfo,
// UserInfo,
GameRecord,
} from "@/components/UserInfo";
import { UserService } from "@/services/userService";
import { UserService, UserInfoType } from "@/services/userService";
import * as LoginService from "@/services/loginService";
const OtherUserPage: React.FC = () => {
@@ -21,21 +21,22 @@ const OtherUserPage: React.FC = () => {
const user_id = instance.router?.params?.userid;
// 模拟用户数据
const [user_info, setUserInfo] = useState<UserInfo>({
id: user_id || "1",
const [user_info, setUserInfo] = useState<Partial<UserInfoType>>({
id: parseInt(user_id || "1") || 1,
gender: "",
nickname: "网球爱好者",
avatar: require("@/static/userInfo/default_avatar.svg"),
avatar_url: require("@/static/userInfo/default_avatar.svg"),
join_date: "2024年3月加入",
stats: {
following: 0,
friends: 0,
hosted: 0,
participated: 0,
following_count: 0,
followers_count: 0,
hosted_games_count: 0,
participated_games_count: 0,
},
tags: ["北京朝阳", "金融从业者", "NTRP 3.5"],
bio: "热爱网球的金融从业者,周末喜欢约球\n技术还在提升中欢迎一起切磋\n平时在朝阳公园附近活动",
location: "北京朝阳",
city: "北京",
district: "朝阳",
occupation: "金融从业者",
ntrp_level: "NTRP 3.5",
is_following: false,
@@ -68,22 +69,26 @@ const OtherUserPage: React.FC = () => {
const { data: userData } = res;
// setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")});
setUserInfo({
id: user_id || "",
id: parseInt(user_id || "") || 0,
nickname: userData.nickname || "",
avatar: userData.avatar_url || "",
avatar_url: 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,
friends: userData.stats?.followers_count || 0,
hosted: userData.stats?.hosted_games_count || 0,
participated: userData.stats?.participated_games_count || 0,
following_count: userData.stats?.following_count || 0,
followers_count: userData.stats?.followers_count || 0,
hosted_games_count: userData.stats?.hosted_games_count || 0,
participated_games_count:
userData.stats?.participated_games_count || 0,
},
personal_profile: userData.personal_profile || "",
location: userData.city + userData.district || "",
province: userData.province || "",
city: userData.city || "",
district: userData.district || "",
occupation: userData.occupation || "",
ntrp_level: "",
phone: userData.phone || "",
@@ -132,7 +137,10 @@ const OtherUserPage: React.FC = () => {
active_tab
);
const sorted_games = games_data.sort((a, b) => {
return new Date(a.original_start_time.replace(/\s/, 'T')).getTime() - new Date(b.original_start_time.replace(/\s/, 'T')).getTime();
return (
new Date(a.original_start_time.replace(/\s/, "T")).getTime() -
new Date(b.original_start_time.replace(/\s/, "T")).getTime()
);
});
const { notEndGames, finishedGames } = classifyGameRecords(sorted_games);
setGameRecords(notEndGames);
@@ -157,7 +165,7 @@ const OtherUserPage: React.FC = () => {
const handle_follow = async () => {
try {
const new_follow_status = await UserService.toggle_follow(
user_info.id,
user_info.id || "",
is_following
);
setIsFollowing(new_follow_status);
@@ -178,7 +186,9 @@ const OtherUserPage: React.FC = () => {
// 处理发送消息
const handle_send_message = () => {
Taro.navigateTo({
url: `/mode_user/message/chat/index?user_id=${user_info.id}&nickname=${user_info.nickname}`,
url: `/mode_user/message/chat/index?user_id=${
user_info.id || ""
}&nickname=${user_info.nickname || ""}`,
});
};
@@ -244,7 +254,7 @@ const OtherUserPage: React.FC = () => {
error={null}
errorImg="ICON_LIST_EMPTY"
emptyText="暂无消息,去互动看看吧"
loadMoreMatches={() => { }}
loadMoreMatches={() => {}}
/>
</ScrollView>
{/* </View> */}
@@ -280,7 +290,7 @@ const OtherUserPage: React.FC = () => {
error={null}
errorImg="ICON_LIST_EMPTY"
emptyText="暂无消息,去互动看看吧"
loadMoreMatches={() => { }}
loadMoreMatches={() => {}}
/>
</ScrollView>
{/* </View> */}