他人页
This commit is contained in:
@@ -98,6 +98,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||||
|
border-radius: 20px;
|
||||||
|
|
||||||
.follow_button {
|
.follow_button {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -106,14 +108,22 @@
|
|||||||
padding: 12px 16px 12px 12px;
|
padding: 12px 16px 12px 12px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background: #000000;
|
background: #000000;
|
||||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
border: none;
|
||||||
border-radius: 999px;
|
outline: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
&.following {
|
&.following {
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
|
|
||||||
|
.button_text {
|
||||||
|
color: #000000 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button_icon {
|
.button_icon {
|
||||||
@@ -127,10 +137,6 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 1.4em;
|
line-height: 1.4em;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
|
|
||||||
.following & {
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +146,7 @@
|
|||||||
padding: unset;
|
padding: unset;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border: 0.5px solid rgba(0, 0, 0, 0.12);
|
border: 0.5px solid rgba(0, 0, 0, 0.12);
|
||||||
border-radius: 999px;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -251,7 +257,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
|
|
||||||
&::before, &::after {
|
&::before,
|
||||||
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
width: 6px;
|
width: 6px;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
@@ -262,6 +269,7 @@
|
|||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
transform: rotate(-45deg);
|
transform: rotate(-45deg);
|
||||||
translate: 4.2px 0;
|
translate: 4.2px 0;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { UserService } from "@/services/userService";
|
|||||||
|
|
||||||
// 用户信息接口
|
// 用户信息接口
|
||||||
export interface UserInfo {
|
export interface UserInfo {
|
||||||
id: string;
|
id: string | number;
|
||||||
nickname: string;
|
nickname: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
join_date: string;
|
join_date: string;
|
||||||
@@ -169,20 +169,20 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
? "@/static/userInfo/following.svg"
|
? "@/static/userInfo/following.svg"
|
||||||
: "@/static/userInfo/unfollow.svg")}
|
: "@/static/userInfo/unfollow.svg")}
|
||||||
/>
|
/>
|
||||||
<Text className="button_text">
|
<Text className={`button_text ${is_following ? "following" : ""}`}>
|
||||||
{is_following ? "已关注" : "关注"}
|
{is_following ? "已关注" : "关注"}
|
||||||
</Text>
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{/* 只有非当前用户才显示消息按钮 */}
|
{/* 只有非当前用户才显示消息按钮 */}
|
||||||
{!is_current_user && on_message && (
|
{/* {!is_current_user && on_message && (
|
||||||
<Button className="message_button" onClick={on_message}>
|
<Button className="message_button" onClick={on_message}>
|
||||||
<Image
|
<Image
|
||||||
className="button_icon"
|
className="button_icon"
|
||||||
src={require("@/static/userInfo/chat.svg")}
|
src={require("@/static/userInfo/chat.svg")}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
{/* 只有当前用户才显示分享按钮 */}
|
{/* 只有当前用户才显示分享按钮 */}
|
||||||
{is_current_user && on_share && (
|
{is_current_user && on_share && (
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ export class UserService {
|
|||||||
if (response.code === 0) {
|
if (response.code === 0) {
|
||||||
const userData = response.data;
|
const userData = response.data;
|
||||||
return {
|
return {
|
||||||
id: userData.user_code || user_id || '',
|
id: userData.user_code || userData.id || '',
|
||||||
nickname: userData.nickname || '',
|
nickname: userData.nickname || '',
|
||||||
avatar: userData.avatar_url || '',
|
avatar: userData.avatar_url || '',
|
||||||
join_date: userData.subscribe_time ? `${new Date(userData.subscribe_time).getFullYear()}年${new Date(userData.subscribe_time).getMonth() + 1}月加入` : '',
|
join_date: userData.subscribe_time ? `${new Date(userData.subscribe_time).getFullYear()}年${new Date(userData.subscribe_time).getMonth() + 1}月加入` : '',
|
||||||
@@ -285,7 +285,7 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户主办的球局
|
// 获取用户主办的球局
|
||||||
static async get_hosted_games(userId: string): Promise<any[]> {
|
static async get_hosted_games(userId: string | number): Promise<any[]> {
|
||||||
try {
|
try {
|
||||||
const response = await httpService.post<any>(API_CONFIG.USER.HOSTED_GAMES, {
|
const response = await httpService.post<any>(API_CONFIG.USER.HOSTED_GAMES, {
|
||||||
userId
|
userId
|
||||||
@@ -308,7 +308,7 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户参与的球局
|
// 获取用户参与的球局
|
||||||
static async get_participated_games(userId: string): Promise<any[]> {
|
static async get_participated_games(userId: string | number): Promise<any[]> {
|
||||||
try {
|
try {
|
||||||
const response = await httpService.post<any>(API_CONFIG.USER.PARTICIPATED_GAMES, {
|
const response = await httpService.post<any>(API_CONFIG.USER.PARTICIPATED_GAMES, {
|
||||||
userId
|
userId
|
||||||
@@ -332,7 +332,7 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户球局记录(兼容旧方法)
|
// 获取用户球局记录(兼容旧方法)
|
||||||
static async get_user_games(user_id: string, type: 'hosted' | 'participated'): Promise<any[]> {
|
static async get_user_games(user_id: string | number, type: 'hosted' | 'participated'): Promise<any[]> {
|
||||||
if (type === 'hosted') {
|
if (type === 'hosted') {
|
||||||
return this.get_hosted_games(user_id);
|
return this.get_hosted_games(user_id);
|
||||||
} else {
|
} else {
|
||||||
@@ -341,10 +341,10 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 关注/取消关注用户
|
// 关注/取消关注用户
|
||||||
static async toggle_follow(user_id: string, is_following: boolean): Promise<boolean> {
|
static async toggle_follow(following_id: string | number, is_following: boolean): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const endpoint = is_following ? API_CONFIG.USER.UNFOLLOW : API_CONFIG.USER.FOLLOW;
|
const endpoint = is_following ? API_CONFIG.USER.UNFOLLOW : API_CONFIG.USER.FOLLOW;
|
||||||
const response = await httpService.post<any>(endpoint, { user_id }, {
|
const response = await httpService.post<any>(endpoint, { following_id }, {
|
||||||
|
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
loadingText: is_following ? '取消关注中...' : '关注中...'
|
loadingText: is_following ? '取消关注中...' : '关注中...'
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
|
|
||||||
// 用户信息状态
|
// 用户信息状态
|
||||||
const [user_info, set_user_info] = useState<UserInfo>({
|
const [user_info, set_user_info] = useState<UserInfo>({
|
||||||
id: "1",
|
id: "",
|
||||||
nickname: "加载中...",
|
nickname: "加载中...",
|
||||||
avatar: require("@/static/userInfo/default_avatar.svg"),
|
avatar: require("@/static/userInfo/default_avatar.svg"),
|
||||||
join_date: "加载中...",
|
join_date: "加载中...",
|
||||||
@@ -54,11 +54,8 @@ const MyselfPage: React.FC = () => {
|
|||||||
set_loading(true);
|
set_loading(true);
|
||||||
|
|
||||||
// 获取用户信息(包含统计数据)
|
// 获取用户信息(包含统计数据)
|
||||||
const user_data = await UserService.get_user_info(user_id);
|
const user_data = await UserService.get_user_info();
|
||||||
set_user_info(user_data);
|
set_user_info(user_data);
|
||||||
|
|
||||||
// 获取球局记录
|
|
||||||
load_game_data();
|
|
||||||
// let games_data;
|
// let games_data;
|
||||||
// if (active_tab === "hosted") {
|
// if (active_tab === "hosted") {
|
||||||
// games_data = await UserService.get_hosted_games(user_id);
|
// games_data = await UserService.get_hosted_games(user_id);
|
||||||
@@ -78,6 +75,12 @@ const MyselfPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (user_info.id) {
|
||||||
|
load_game_data(); // 在 user_info 更新后调用
|
||||||
|
}
|
||||||
|
}, [user_info]);
|
||||||
|
|
||||||
// 页面加载时获取数据
|
// 页面加载时获取数据
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// load_user_data();
|
// load_user_data();
|
||||||
|
|||||||
@@ -158,7 +158,7 @@
|
|||||||
height: 40px;
|
height: 40px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border: 0.5px solid rgba(0, 0, 0, 0.12);
|
border: 0.5px solid rgba(0, 0, 0, 0.12);
|
||||||
border-radius: 999px;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { View, Text, ScrollView } from "@tarojs/components";
|
import { View, Text, ScrollView } from "@tarojs/components";
|
||||||
|
import ListContainer from "@/container/listContainer";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
// import GuideBar from "@/components/GuideBar";
|
// import GuideBar from "@/components/GuideBar";
|
||||||
import {
|
import {
|
||||||
UserInfoCard,
|
UserInfoCard,
|
||||||
GameCard,
|
// GameCard,
|
||||||
GameTabs,
|
GameTabs,
|
||||||
UserInfo,
|
UserInfo,
|
||||||
GameRecord,
|
GameRecord,
|
||||||
@@ -26,10 +27,10 @@ const OtherUserPage: React.FC = () => {
|
|||||||
avatar: require("@/static/userInfo/default_avatar.svg"),
|
avatar: require("@/static/userInfo/default_avatar.svg"),
|
||||||
join_date: "2024年3月加入",
|
join_date: "2024年3月加入",
|
||||||
stats: {
|
stats: {
|
||||||
following: 89,
|
following: 0,
|
||||||
friends: 15,
|
friends: 0,
|
||||||
hosted: 12,
|
hosted: 0,
|
||||||
participated: 35,
|
participated: 0,
|
||||||
},
|
},
|
||||||
tags: ["北京朝阳", "金融从业者", "NTRP 3.5"],
|
tags: ["北京朝阳", "金融从业者", "NTRP 3.5"],
|
||||||
bio: "热爱网球的金融从业者,周末喜欢约球\n技术还在提升中,欢迎一起切磋\n平时在朝阳公园附近活动",
|
bio: "热爱网球的金融从业者,周末喜欢约球\n技术还在提升中,欢迎一起切磋\n平时在朝阳公园附近活动",
|
||||||
@@ -47,6 +48,8 @@ const OtherUserPage: React.FC = () => {
|
|||||||
// 关注状态
|
// 关注状态
|
||||||
const [is_following, setIsFollowing] = useState(false);
|
const [is_following, setIsFollowing] = useState(false);
|
||||||
|
|
||||||
|
const [loading, set_loading] = useState(true);
|
||||||
|
|
||||||
// 当前激活的标签页
|
// 当前激活的标签页
|
||||||
const [active_tab, setActiveTab] = useState<"hosted" | "participated">(
|
const [active_tab, setActiveTab] = useState<"hosted" | "participated">(
|
||||||
"hosted"
|
"hosted"
|
||||||
@@ -62,12 +65,11 @@ const OtherUserPage: React.FC = () => {
|
|||||||
const { data: userData } = res;
|
const { data: userData } = res;
|
||||||
// setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")});
|
// setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")});
|
||||||
setUserInfo({
|
setUserInfo({
|
||||||
id: userData.user_code || user_id || "",
|
id: user_id || "",
|
||||||
nickname: userData.nickname || "",
|
nickname: userData.nickname || "",
|
||||||
avatar: userData.avatar_url || "",
|
avatar: userData.avatar_url || "",
|
||||||
join_date: userData.subscribe_time
|
join_date: userData.subscribe_time
|
||||||
? `${new Date(userData.subscribe_time).getFullYear()}年${
|
? `${new Date(userData.subscribe_time).getFullYear()}年${new Date(userData.subscribe_time).getMonth() + 1
|
||||||
new Date(userData.subscribe_time).getMonth() + 1
|
|
||||||
}月加入`
|
}月加入`
|
||||||
: "",
|
: "",
|
||||||
stats: {
|
stats: {
|
||||||
@@ -85,12 +87,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
gender: userData.gender || "",
|
gender: userData.gender || "",
|
||||||
birthday: userData.birthday || "",
|
birthday: userData.birthday || "",
|
||||||
});
|
});
|
||||||
|
setIsFollowing(userData.is_following || false);
|
||||||
const games_data = await UserService.get_user_games(
|
|
||||||
user_id,
|
|
||||||
active_tab
|
|
||||||
);
|
|
||||||
setGameRecords(games_data);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("加载用户数据失败:", error);
|
console.error("加载用户数据失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
@@ -102,7 +99,31 @@ const OtherUserPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
load_user_data();
|
load_user_data();
|
||||||
}, [user_id, active_tab]);
|
}, [user_id]);
|
||||||
|
|
||||||
|
const load_game_data = async () => {
|
||||||
|
try {
|
||||||
|
set_loading(true);
|
||||||
|
const games_data = await UserService.get_user_games(
|
||||||
|
user_id || "",
|
||||||
|
active_tab
|
||||||
|
);
|
||||||
|
setGameRecords(games_data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("加载球局数据失败:", error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: "加载失败,请重试",
|
||||||
|
icon: "error",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
set_loading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load_game_data();
|
||||||
|
}, [active_tab]);
|
||||||
|
|
||||||
// 处理关注/取消关注
|
// 处理关注/取消关注
|
||||||
const handle_follow = async () => {
|
const handle_follow = async () => {
|
||||||
@@ -134,11 +155,11 @@ const OtherUserPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 处理球局详情
|
// 处理球局详情
|
||||||
const handle_game_detail = (game_id: string) => {
|
// const handle_game_detail = (game_id: string) => {
|
||||||
Taro.navigateTo({
|
// Taro.navigateTo({
|
||||||
url: `/game_pages/detail/index?id=${game_id}&from=personal`,
|
// url: `/game_pages/detail/index?id=${game_id}&from=personal`,
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="other_user_page">
|
<View className="other_user_page">
|
||||||
@@ -170,8 +191,22 @@ const OtherUserPage: React.FC = () => {
|
|||||||
<Text className="weekday_text">星期六</Text>
|
<Text className="weekday_text">星期六</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{/* 球局列表 */}
|
||||||
|
<View className="game_list_section">
|
||||||
|
<ScrollView scrollY>
|
||||||
|
<ListContainer
|
||||||
|
data={game_records}
|
||||||
|
recommendList={[]}
|
||||||
|
loading={loading}
|
||||||
|
error={null}
|
||||||
|
reload={load_game_data}
|
||||||
|
loadMoreMatches={() => { }}
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
|
||||||
{/* 球局卡片 */}
|
{/* 球局卡片 */}
|
||||||
<View className="game_cards">
|
{/* <View className="game_cards">
|
||||||
{game_records.map((game) => (
|
{game_records.map((game) => (
|
||||||
<GameCard
|
<GameCard
|
||||||
key={game.id}
|
key={game.id}
|
||||||
@@ -179,7 +214,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
on_click={handle_game_detail}
|
on_click={handle_game_detail}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View> */}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{/* <GuideBar currentPage="personal" /> */}
|
{/* <GuideBar currentPage="personal" /> */}
|
||||||
|
|||||||
Reference in New Issue
Block a user