他人页
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
|
||||
import { View, Text, ScrollView } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.scss";
|
||||
import GuideBar from "@/components/GuideBar";
|
||||
// import GuideBar from "@/components/GuideBar";
|
||||
import {
|
||||
UserInfoCard,
|
||||
GameCard,
|
||||
@@ -21,6 +21,7 @@ const OtherUserPage: React.FC = () => {
|
||||
// 模拟用户数据
|
||||
const [user_info, setUserInfo] = useState<UserInfo>({
|
||||
id: user_id || "1",
|
||||
gender:"",
|
||||
nickname: "网球爱好者",
|
||||
avatar: require("@/static/userInfo/default_avatar.svg"),
|
||||
join_date: "2024年3月加入",
|
||||
@@ -37,7 +38,7 @@ const OtherUserPage: React.FC = () => {
|
||||
ntrp_level: "NTRP 3.5",
|
||||
is_following: false,
|
||||
ongoing_games: [],
|
||||
personal_profile: '',
|
||||
personal_profile: "",
|
||||
});
|
||||
|
||||
// 模拟球局数据
|
||||
@@ -48,7 +49,7 @@ const OtherUserPage: React.FC = () => {
|
||||
|
||||
// 当前激活的标签页
|
||||
const [active_tab, setActiveTab] = useState<"hosted" | "participated">(
|
||||
"hosted",
|
||||
"hosted"
|
||||
);
|
||||
|
||||
// 页面加载时获取用户信息
|
||||
@@ -58,11 +59,36 @@ const OtherUserPage: React.FC = () => {
|
||||
try {
|
||||
// const user_data = await UserService.get_user_info(user_id);
|
||||
const res = await LoginService.getUserInfoById(user_id);
|
||||
setUserInfo(res.data as UserInfo);
|
||||
const { data: userData } = res;
|
||||
// setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")});
|
||||
setUserInfo({
|
||||
id: userData.user_code || user_id || "",
|
||||
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
|
||||
}月加入`
|
||||
: "",
|
||||
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,
|
||||
},
|
||||
|
||||
personal_profile: userData.personal_profile || "",
|
||||
location: userData.city + userData.district || "",
|
||||
occupation: userData.occupation || "",
|
||||
ntrp_level: "",
|
||||
phone: userData.phone || "",
|
||||
gender: userData.gender || "",
|
||||
birthday: userData.birthday || "",
|
||||
});
|
||||
|
||||
const games_data = await UserService.get_user_games(
|
||||
user_id,
|
||||
active_tab,
|
||||
active_tab
|
||||
);
|
||||
setGameRecords(games_data);
|
||||
} catch (error) {
|
||||
@@ -83,7 +109,7 @@ const OtherUserPage: React.FC = () => {
|
||||
try {
|
||||
const new_follow_status = await UserService.toggle_follow(
|
||||
user_info.id,
|
||||
is_following,
|
||||
is_following
|
||||
);
|
||||
setIsFollowing(new_follow_status);
|
||||
Taro.showToast({
|
||||
|
||||
Reference in New Issue
Block a user