This commit is contained in:
张成
2025-09-07 18:22:07 +08:00
parent 98bf0fbe13
commit 45f85a8572
12 changed files with 72 additions and 858 deletions

View File

@@ -12,7 +12,7 @@ import { withAuth } from '@/components';
const MyselfPage: React.FC = () => {
// 获取页面参数
const instance = Taro.getCurrentInstance();
const user_id = instance.router?.params?.userid;
const user_id = instance.router?.params?.userid || '';
// 判断是否为当前用户
const is_current_user = !user_id;
@@ -29,7 +29,6 @@ const MyselfPage: React.FC = () => {
hosted: 0,
participated: 0
},
tags: ['加载中...'],
bio: '加载中...',
location: '加载中...',
occupation: '加载中...',
@@ -58,9 +57,9 @@ const MyselfPage: React.FC = () => {
// 获取球局记录
let games_data;
if (active_tab === 'hosted') {
games_data = await UserService.get_hosted_games(user_id || '1');
games_data = await UserService.get_hosted_games(user_id);
} else {
games_data = await UserService.get_participated_games(user_id || '1');
games_data = await UserService.get_participated_games(user_id);
}
set_game_records(games_data);
@@ -93,9 +92,9 @@ const MyselfPage: React.FC = () => {
try {
let games_data;
if (active_tab === 'hosted') {
games_data = await UserService.get_hosted_games(user_id || '1');
games_data = await UserService.get_hosted_games(user_id);
} else {
games_data = await UserService.get_participated_games(user_id || '1');
games_data = await UserService.get_participated_games(user_id);
}
set_game_records(games_data);
} catch (error) {
@@ -106,7 +105,7 @@ const MyselfPage: React.FC = () => {
// 处理关注/取消关注
const handle_follow = async () => {
try {
const new_following_state = await UserService.toggle_follow(user_id || '1', is_following);
const new_following_state = await UserService.toggle_follow(user_id, is_following);
setIsFollowing(new_following_state);
Taro.showToast({