1
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
export default defineAppConfig({
|
export default defineAppConfig({
|
||||||
pages: [
|
pages: [
|
||||||
|
'pages/userInfo/myself/index', // 个人中心
|
||||||
'pages/login/index/index',
|
'pages/login/index/index',
|
||||||
'pages/login/verification/index',
|
'pages/login/verification/index',
|
||||||
'pages/login/terms/index',
|
'pages/login/terms/index',
|
||||||
@@ -11,8 +12,10 @@ export default defineAppConfig({
|
|||||||
'pages/detail/index',
|
'pages/detail/index',
|
||||||
'pages/message/index',
|
'pages/message/index',
|
||||||
'pages/orderCheck/index',
|
'pages/orderCheck/index',
|
||||||
'pages/userInfo/myself/index', // 个人中心
|
|
||||||
|
'pages/userInfo/edit/index', // 个人中心
|
||||||
|
'pages/userInfo/favorites/index', // 个人中心
|
||||||
|
'pages/userInfo/orders/index', // 个人中心
|
||||||
// 'pages/mapDisplay/index',
|
// 'pages/mapDisplay/index',
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import Taro from '@tarojs/taro';
|
||||||
import { View, Text, Image, Button } from '@tarojs/components';
|
import { View, Text, Image, Button } from '@tarojs/components';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
|
||||||
@@ -19,6 +20,8 @@ export interface UserInfo {
|
|||||||
location: string;
|
location: string;
|
||||||
occupation: string;
|
occupation: string;
|
||||||
ntrp_level: string;
|
ntrp_level: string;
|
||||||
|
phone?: string;
|
||||||
|
gender?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户信息卡片组件属性
|
// 用户信息卡片组件属性
|
||||||
@@ -28,10 +31,16 @@ interface UserInfoCardProps {
|
|||||||
is_following?: boolean;
|
is_following?: boolean;
|
||||||
on_follow?: () => void;
|
on_follow?: () => void;
|
||||||
on_message?: () => void;
|
on_message?: () => void;
|
||||||
on_edit?: () => void;
|
|
||||||
on_share?: () => void;
|
on_share?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理编辑用户信息
|
||||||
|
const on_edit = () => {
|
||||||
|
Taro.navigateTo({
|
||||||
|
url: '/pages/userInfo/edit/index'
|
||||||
|
});
|
||||||
|
};
|
||||||
// 用户信息卡片组件
|
// 用户信息卡片组件
|
||||||
export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
||||||
user_info,
|
user_info,
|
||||||
@@ -39,7 +48,6 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
is_following = false,
|
is_following = false,
|
||||||
on_follow,
|
on_follow,
|
||||||
on_message,
|
on_message,
|
||||||
on_edit,
|
|
||||||
on_share
|
on_share
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
@@ -53,7 +61,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
<Text className="nickname">{user_info.nickname}</Text>
|
<Text className="nickname">{user_info.nickname}</Text>
|
||||||
<Text className="join_date">{user_info.join_date}</Text>
|
<Text className="join_date">{user_info.join_date}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className='tag_item'>
|
<View className='tag_item' onClick={on_edit}>
|
||||||
<Image
|
<Image
|
||||||
className="tag_icon"
|
className="tag_icon"
|
||||||
src={require('../../static/userInfo/edit.svg')}
|
src={require('../../static/userInfo/edit.svg')}
|
||||||
@@ -105,12 +113,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
|
|||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{/* 只有当前用户才显示编辑按钮 */}
|
|
||||||
{is_current_user && on_edit && (
|
|
||||||
<Button className="edit_button" onClick={on_edit}>
|
|
||||||
<Text className="button_text">编辑</Text>
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
{/* 只有当前用户才显示分享按钮 */}
|
{/* 只有当前用户才显示分享按钮 */}
|
||||||
{is_current_user && on_share && (
|
{is_current_user && on_share && (
|
||||||
<Button className="share_button" onClick={on_share}>
|
<Button className="share_button" onClick={on_share}>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ export const API_CONFIG = {
|
|||||||
DETAIL: '/user/detail',
|
DETAIL: '/user/detail',
|
||||||
UPDATE: '/user/update',
|
UPDATE: '/user/update',
|
||||||
FOLLOW: '/user/follow',
|
FOLLOW: '/user/follow',
|
||||||
UNFOLLOW: '/user/unfollow'
|
UNFOLLOW: '/user/unfollow',
|
||||||
|
HOSTED_GAMES: '/user/games',
|
||||||
|
PARTICIPATED_GAMES: '/user/participated'
|
||||||
},
|
},
|
||||||
|
|
||||||
// 文件上传接口
|
// 文件上传接口
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ const envConfigs: Record<EnvType, EnvConfig> = {
|
|||||||
// 开发环境
|
// 开发环境
|
||||||
development: {
|
development: {
|
||||||
name: '开发环境',
|
name: '开发环境',
|
||||||
apiBaseURL: 'https://sit.light120.com',
|
// apiBaseURL: 'https://sit.light120.com',
|
||||||
|
apiBaseURL: 'http://localhost:9098',
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
enableLog: true,
|
enableLog: true,
|
||||||
enableMock: true
|
enableMock: true
|
||||||
@@ -26,7 +27,8 @@ const envConfigs: Record<EnvType, EnvConfig> = {
|
|||||||
// 测试环境
|
// 测试环境
|
||||||
test: {
|
test: {
|
||||||
name: '测试环境',
|
name: '测试环境',
|
||||||
apiBaseURL: 'https://sit.light120.com',
|
// apiBaseURL: 'https://sit.light120.com',
|
||||||
|
apiBaseURL: 'http://localhost:9098',
|
||||||
timeout: 12000,
|
timeout: 12000,
|
||||||
enableLog: true,
|
enableLog: true,
|
||||||
enableMock: false
|
enableMock: false
|
||||||
@@ -53,10 +55,10 @@ export const getCurrentEnv = (): EnvType => {
|
|||||||
|
|
||||||
// 在开发调试时,可以通过修改这里的逻辑来切换环境
|
// 在开发调试时,可以通过修改这里的逻辑来切换环境
|
||||||
// 默认在小程序中使用生产环境配置
|
// 默认在小程序中使用生产环境配置
|
||||||
if (currentEnv === Taro.ENV_TYPE.WEAPP) {
|
// if (currentEnv === Taro.ENV_TYPE.WEAPP) {
|
||||||
// 微信小程序环境
|
// // 微信小程序环境
|
||||||
return 'production'
|
// return 'production'
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 默认返回开发环境(便于调试)
|
// 默认返回开发环境(便于调试)
|
||||||
return 'development'
|
return 'development'
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { View, Text, Image, ScrollView, Button, Input, Textarea } from '@tarojs/components';
|
import { View, Text, Image, ScrollView, Button, Input, Textarea } from '@tarojs/components';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
import GuideBar from '@/components/GuideBar';
|
|
||||||
import { UserInfo } from '@/components/UserInfo';
|
import { UserInfo } from '@/components/UserInfo';
|
||||||
import { UserService } from '@/services/userService';
|
import { UserService } from '@/services/userService';
|
||||||
|
|
||||||
@@ -10,33 +9,70 @@ const EditProfilePage: React.FC = () => {
|
|||||||
// 用户信息状态
|
// 用户信息状态
|
||||||
const [user_info, setUserInfo] = useState<UserInfo>({
|
const [user_info, setUserInfo] = useState<UserInfo>({
|
||||||
id: '1',
|
id: '1',
|
||||||
nickname: '188的王晨',
|
nickname: '加载中...',
|
||||||
avatar: require('../../../static/userInfo/default_avatar.svg'),
|
avatar: require('../../../static/userInfo/default_avatar.svg'),
|
||||||
bio: '网球入坑两年,偏好双打,正手进攻型选手\n平时在张江、世纪公园附近活动,欢迎约球!\n不卷分数,但认真对待每一拍,每一场球都想打得开心。有时候也会带相机来拍点照片📸',
|
join_date: '加载中...',
|
||||||
location: '上海黄浦',
|
stats: {
|
||||||
occupation: '互联网从业者',
|
following: 0,
|
||||||
ntrp_level: 'NTRP 4.0'
|
friends: 0,
|
||||||
|
hosted: 0,
|
||||||
|
participated: 0
|
||||||
|
},
|
||||||
|
tags: ['加载中...'],
|
||||||
|
bio: '加载中...',
|
||||||
|
location: '加载中...',
|
||||||
|
occupation: '加载中...',
|
||||||
|
ntrp_level: 'NTRP 3.0',
|
||||||
|
phone: '',
|
||||||
|
gender: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表单状态
|
// 表单状态
|
||||||
const [form_data, setFormData] = useState({
|
const [form_data, setFormData] = useState({
|
||||||
nickname: user_info.nickname,
|
nickname: '',
|
||||||
bio: user_info.bio,
|
bio: '',
|
||||||
location: user_info.location,
|
location: '',
|
||||||
occupation: user_info.occupation,
|
occupation: '',
|
||||||
ntrp_level: user_info.ntrp_level,
|
ntrp_level: 'NTRP 3.0',
|
||||||
phone: '', // 新增手机号字段
|
phone: '',
|
||||||
gender: '' // 新增性别字段
|
gender: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 加载状态
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
// 页面加载时初始化数据
|
// 页面加载时初始化数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 这里应该从store或API获取当前用户信息
|
load_user_info();
|
||||||
// const currentUser = getUserInfo();
|
|
||||||
// setUserInfo(currentUser);
|
|
||||||
// setFormData(currentUser);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 加载用户信息
|
||||||
|
const load_user_info = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const user_data = await UserService.get_user_info();
|
||||||
|
setUserInfo(user_data);
|
||||||
|
setFormData({
|
||||||
|
nickname: user_data.nickname,
|
||||||
|
bio: user_data.bio,
|
||||||
|
location: user_data.location,
|
||||||
|
occupation: user_data.occupation,
|
||||||
|
ntrp_level: user_data.ntrp_level,
|
||||||
|
phone: user_data.phone || '',
|
||||||
|
gender: user_data.gender || ''
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载用户信息失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '加载用户信息失败',
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 处理输入变化
|
// 处理输入变化
|
||||||
const handle_input_change = (field: string, value: string) => {
|
const handle_input_change = (field: string, value: string) => {
|
||||||
setFormData(prev => ({
|
setFormData(prev => ({
|
||||||
@@ -45,6 +81,9 @@ const EditProfilePage: React.FC = () => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处理头像上传
|
// 处理头像上传
|
||||||
const handle_avatar_upload = () => {
|
const handle_avatar_upload = () => {
|
||||||
Taro.chooseImage({
|
Taro.chooseImage({
|
||||||
@@ -107,6 +146,12 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<View className="edit_profile_page">
|
<View className="edit_profile_page">
|
||||||
{/* 主要内容 */}
|
{/* 主要内容 */}
|
||||||
<ScrollView className="main_content" scrollY>
|
<ScrollView className="main_content" scrollY>
|
||||||
|
{loading ? (
|
||||||
|
<View className="loading_container">
|
||||||
|
<Text className="loading_text">加载中...</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
{/* 头部操作栏 */}
|
{/* 头部操作栏 */}
|
||||||
<View className="header_section">
|
<View className="header_section">
|
||||||
<Button className="back_button" onClick={handle_back}>
|
<Button className="back_button" onClick={handle_back}>
|
||||||
@@ -231,8 +276,9 @@ const EditProfilePage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<GuideBar currentPage='personal' />
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
13
src/pages/userInfo/favorites/index.tsx
Normal file
13
src/pages/userInfo/favorites/index.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { View, } from '@tarojs/components';
|
||||||
|
const OrderPage: React.FC = () => {
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="myself_page">
|
||||||
|
我的收藏
|
||||||
|
</View>)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default OrderPage;
|
||||||
@@ -27,6 +27,19 @@
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
margin-top: 98px;
|
margin-top: 98px;
|
||||||
|
|
||||||
|
// 加载状态
|
||||||
|
.loading_container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 40px 0;
|
||||||
|
|
||||||
|
.loading_text {
|
||||||
|
@include text-style(16px, 400, 1.4em);
|
||||||
|
color: $color-primary-lightest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 统计数据
|
// 统计数据
|
||||||
.stats_section {
|
.stats_section {
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import { View, Text, Image, ScrollView } from '@tarojs/components';
|
|||||||
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 { UserInfoCard, UserInfo, GameRecord } from '@/components/UserInfo/index'
|
import { UserInfoCard, UserInfo } from '@/components/UserInfo/index'
|
||||||
import { UserService } from '@/services/userService'
|
import { UserService } from '@/services/userService'
|
||||||
|
import ListContainer from '@/container/listContainer'
|
||||||
|
import { TennisMatch } from '../../../../types/list/types'
|
||||||
|
|
||||||
const MyselfPage: React.FC = () => {
|
const MyselfPage: React.FC = () => {
|
||||||
// 获取页面参数
|
// 获取页面参数
|
||||||
@@ -35,7 +36,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 球局记录状态
|
// 球局记录状态
|
||||||
const [game_records, set_game_records] = useState<GameRecord[]>([]);
|
const [game_records, set_game_records] = useState<TennisMatch[]>([]);
|
||||||
const [loading, set_loading] = useState(true);
|
const [loading, set_loading] = useState(true);
|
||||||
|
|
||||||
// 关注状态
|
// 关注状态
|
||||||
@@ -44,50 +45,121 @@ const MyselfPage: React.FC = () => {
|
|||||||
// 当前激活的标签页
|
// 当前激活的标签页
|
||||||
const [active_tab, setActiveTab] = useState<'hosted' | 'participated'>('hosted');
|
const [active_tab, setActiveTab] = useState<'hosted' | 'participated'>('hosted');
|
||||||
|
|
||||||
|
// 加载用户数据
|
||||||
|
const load_user_data = async () => {
|
||||||
|
try {
|
||||||
|
set_loading(true);
|
||||||
|
|
||||||
|
// 获取用户信息(包含统计数据)
|
||||||
|
const user_data = await UserService.get_user_info(user_id);
|
||||||
|
set_user_info(user_data);
|
||||||
|
|
||||||
|
// 获取球局记录
|
||||||
|
let games_data;
|
||||||
|
if (active_tab === 'hosted') {
|
||||||
|
games_data = await UserService.get_hosted_games(user_id || '1');
|
||||||
|
} else {
|
||||||
|
games_data = await UserService.get_participated_games(user_id || '1');
|
||||||
|
}
|
||||||
|
set_game_records(games_data);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载用户数据失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '加载失败,请重试',
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
set_loading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 页面加载时获取数据
|
||||||
|
useEffect(() => {
|
||||||
|
load_user_data();
|
||||||
|
}, [user_id]);
|
||||||
|
|
||||||
|
// 切换标签页时重新加载球局数据
|
||||||
|
useEffect(() => {
|
||||||
|
if (!loading) {
|
||||||
|
load_game_data();
|
||||||
|
}
|
||||||
|
}, [active_tab]);
|
||||||
|
|
||||||
|
// 加载球局数据
|
||||||
|
const load_game_data = async () => {
|
||||||
|
try {
|
||||||
|
let games_data;
|
||||||
|
if (active_tab === 'hosted') {
|
||||||
|
games_data = await UserService.get_hosted_games(user_id || '1');
|
||||||
|
} else {
|
||||||
|
games_data = await UserService.get_participated_games(user_id || '1');
|
||||||
|
}
|
||||||
|
set_game_records(games_data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载球局数据失败:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 处理关注/取消关注
|
// 处理关注/取消关注
|
||||||
const handle_follow = () => {
|
const handle_follow = async () => {
|
||||||
setIsFollowing(!is_following);
|
try {
|
||||||
Taro.showToast({
|
const new_following_state = await UserService.toggle_follow(user_id || '1', is_following);
|
||||||
title: is_following ? '已取消关注' : '关注成功',
|
setIsFollowing(new_following_state);
|
||||||
icon: 'success',
|
|
||||||
duration: 1500
|
Taro.showToast({
|
||||||
});
|
title: new_following_state ? '关注成功' : '已取消关注',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('关注操作失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '操作失败,请重试',
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 处理球局详情
|
|
||||||
const handle_game_detail = (game_id: string) => {
|
|
||||||
Taro.navigateTo({
|
|
||||||
url: `/pages/game/detail/index?id=${game_id}`
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 处理球局订单
|
// 处理球局订单
|
||||||
const handle_game_orders = () => {
|
const handle_game_orders = () => {
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/game/orders/index'
|
url: '/pages/userInfo/orders/index'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理收藏
|
// 处理收藏
|
||||||
const handle_favorites = () => {
|
const handle_favorites = () => {
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: '/pages/game/favorites/index'
|
url: '/pages/userInfo/favorites/index'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="myself_page">
|
<View className="myself_page">
|
||||||
{/* 主要内容 */}
|
{/* 主要内容 */}
|
||||||
<View className='main_content'>
|
<View className='main_content'>
|
||||||
{/* 用户信息区域 */}
|
{/* 用户信息区域 */}
|
||||||
<View className="user_info_section">
|
<View className="user_info_section">
|
||||||
|
{loading ? (
|
||||||
<UserInfoCard user_info={user_info}
|
<View className="loading_container">
|
||||||
is_current_user={false}
|
<Text className="loading_text">加载中...</Text>
|
||||||
is_following={is_following}
|
</View>
|
||||||
on_follow={handle_follow}
|
) : (
|
||||||
></UserInfoCard>
|
<UserInfoCard
|
||||||
|
user_info={user_info}
|
||||||
|
is_current_user={is_current_user}
|
||||||
|
is_following={is_following}
|
||||||
|
on_follow={handle_follow}
|
||||||
|
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{/* 球局订单和收藏功能 */}
|
{/* 球局订单和收藏功能 */}
|
||||||
<View className="quick_actions_section">
|
<View className="quick_actions_section">
|
||||||
<View className="action_card">
|
<View className="action_card">
|
||||||
@@ -124,88 +196,14 @@ const MyselfPage: React.FC = () => {
|
|||||||
|
|
||||||
{/* 球局列表 */}
|
{/* 球局列表 */}
|
||||||
<View className="game_list_section">
|
<View className="game_list_section">
|
||||||
<View className="date_header">
|
|
||||||
<Text className="date_text">5月28日</Text>
|
|
||||||
<Text className="separator">/</Text>
|
|
||||||
<Text className="weekday_text">星期三</Text>
|
|
||||||
</View>
|
|
||||||
<ScrollView scrollY>
|
<ScrollView scrollY>
|
||||||
{/* 球局卡片 */}
|
<ListContainer
|
||||||
<View className="game_cards">
|
data={game_records}
|
||||||
{game_records.map((game) => (
|
recommendList={[]}
|
||||||
<View
|
loading={loading}
|
||||||
key={game.id}
|
error={null}
|
||||||
className="game_card"
|
reload={load_game_data}
|
||||||
onClick={() => handle_game_detail(game.id)}
|
/>
|
||||||
>
|
|
||||||
{/* 球局标题和类型 */}
|
|
||||||
<View className="game_header">
|
|
||||||
<Text className="game_title">{game.title}</Text>
|
|
||||||
<View className="game_type_icon">
|
|
||||||
<Image
|
|
||||||
className="type_icon"
|
|
||||||
src={require('../../../static/userInfo/tennis.svg')}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 球局时间 */}
|
|
||||||
<View className="game_time">
|
|
||||||
<Text className="time_text">
|
|
||||||
{game.date} {game.time} {game.duration}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 球局地点和类型 */}
|
|
||||||
<View className="game_location">
|
|
||||||
<Text className="location_text">{game.location}</Text>
|
|
||||||
<Text className="separator">·</Text>
|
|
||||||
<Text className="type_text">{game.type}</Text>
|
|
||||||
<Text className="separator">·</Text>
|
|
||||||
<Text className="distance_text">{game.distance}</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 球局图片 */}
|
|
||||||
<View className="game_images">
|
|
||||||
{game.images.map((image, index) => (
|
|
||||||
<Image
|
|
||||||
key={index}
|
|
||||||
className="game_image"
|
|
||||||
src={image}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 球局信息标签 */}
|
|
||||||
<View className="game_tags">
|
|
||||||
<View className="participants_info">
|
|
||||||
<View className="avatars">
|
|
||||||
{game.participants.map((participant, index) => (
|
|
||||||
<Image
|
|
||||||
key={index}
|
|
||||||
className="participant_avatar"
|
|
||||||
src={participant.avatar}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
<View className="participants_count">
|
|
||||||
<Text className="count_text">
|
|
||||||
报名人数 {game.current_participants}/{game.max_participants}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
<View className="game_info_tags">
|
|
||||||
<View className="info_tag">
|
|
||||||
<Text className="tag_text">{game.level_range}</Text>
|
|
||||||
</View>
|
|
||||||
<View className="info_tag">
|
|
||||||
<Text className="tag_text">{game.game_type}</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
13
src/pages/userInfo/orders/index.tsx
Normal file
13
src/pages/userInfo/orders/index.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { View, } from '@tarojs/components';
|
||||||
|
const OrderPage: React.FC = () => {
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="myself_page">
|
||||||
|
我的订单
|
||||||
|
</View>)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default OrderPage;
|
||||||
@@ -353,7 +353,7 @@ export const refresh_login_status = async (): Promise<boolean> => {
|
|||||||
// 获取用户详细信息
|
// 获取用户详细信息
|
||||||
export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> => {
|
export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> => {
|
||||||
try {
|
try {
|
||||||
const response = await httpService.post('/user/detail');
|
const response = await httpService.post('api/user/detail');
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取用户信息失败:', error);
|
console.error('获取用户信息失败:', error);
|
||||||
@@ -364,7 +364,7 @@ export const fetchUserProfile = async (): Promise<ApiResponse<UserInfoType>> =>
|
|||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
|
export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
|
||||||
try {
|
try {
|
||||||
const response = await httpService.post('user/update', payload);
|
const response = await httpService.post('api/user/update', payload);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('更新用户信息失败:', error);
|
console.error('更新用户信息失败:', error);
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import { UserInfo, GameRecord } from '@/components/UserInfo';
|
import { UserInfo } from '@/components/UserInfo';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { API_CONFIG, REQUEST_CONFIG } from '@/config/api';
|
import { API_CONFIG } from '@/config/api';
|
||||||
|
import httpService from './httpService';
|
||||||
|
|
||||||
// API响应接口
|
|
||||||
interface ApiResponse<T> {
|
|
||||||
code: number;
|
|
||||||
message: string;
|
|
||||||
data: T;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 用户详情接口
|
// 用户详情接口
|
||||||
interface UserDetailData {
|
interface UserDetailData {
|
||||||
|
id: number;
|
||||||
openid: string;
|
openid: string;
|
||||||
user_code: string;
|
user_code: string | null;
|
||||||
unionid: string;
|
unionid: string;
|
||||||
session_key: string;
|
session_key: string;
|
||||||
nickname: string;
|
nickname: string;
|
||||||
@@ -24,10 +20,18 @@ interface UserDetailData {
|
|||||||
language: string;
|
language: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
is_subscribed: string;
|
is_subscribed: string;
|
||||||
latitude: string;
|
latitude: number;
|
||||||
longitude: string;
|
longitude: number;
|
||||||
subscribe_time: string;
|
subscribe_time: string;
|
||||||
last_login_time: string;
|
last_login_time: string;
|
||||||
|
create_time: string;
|
||||||
|
last_modify_time: string;
|
||||||
|
stats: {
|
||||||
|
followers_count: number;
|
||||||
|
following_count: number;
|
||||||
|
hosted_games_count: number;
|
||||||
|
participated_games_count: number;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新用户信息参数接口
|
// 更新用户信息参数接口
|
||||||
@@ -84,25 +88,23 @@ export class UserService {
|
|||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
static async get_user_info(user_id?: string): Promise<UserInfo> {
|
static async get_user_info(user_id?: string): Promise<UserInfo> {
|
||||||
try {
|
try {
|
||||||
const response = await Taro.request<ApiResponse<UserDetailData>>({
|
const response = await httpService.post<UserDetailData>(API_CONFIG.USER.DETAIL, user_id ? { user_id } : {}, {
|
||||||
url: `${API_CONFIG.BASE_URL}${API_CONFIG.USER.DETAIL}`,
|
needAuth: false,
|
||||||
method: 'POST',
|
showLoading: false
|
||||||
data: user_id ? { user_id } : {},
|
|
||||||
...REQUEST_CONFIG
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.code === 0) {
|
if (response.code === 0) {
|
||||||
const userData = response.data.data;
|
const userData = response.data;
|
||||||
return {
|
return {
|
||||||
id: userData.user_code || user_id || '1',
|
id: userData.user_code || user_id || '1',
|
||||||
nickname: userData.nickname || '用户',
|
nickname: userData.nickname || '用户',
|
||||||
avatar: userData.avatar_url || require('../../static/userInfo/default_avatar.svg'),
|
avatar: userData.avatar_url || require('../static/userInfo/default_avatar.svg'),
|
||||||
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}月加入` : '未知时间加入',
|
||||||
stats: {
|
stats: {
|
||||||
following: 0, // 这些数据需要其他接口获取
|
following: userData.stats?.following_count || 0,
|
||||||
friends: 0,
|
friends: userData.stats?.followers_count || 0,
|
||||||
hosted: 0,
|
hosted: userData.stats?.hosted_games_count || 0,
|
||||||
participated: 0
|
participated: userData.stats?.participated_games_count || 0
|
||||||
},
|
},
|
||||||
tags: [
|
tags: [
|
||||||
userData.city || '未知地区',
|
userData.city || '未知地区',
|
||||||
@@ -112,10 +114,12 @@ export class UserService {
|
|||||||
bio: '这个人很懒,什么都没有写...',
|
bio: '这个人很懒,什么都没有写...',
|
||||||
location: userData.city || '未知地区',
|
location: userData.city || '未知地区',
|
||||||
occupation: '未知职业', // 需要其他接口获取
|
occupation: '未知职业', // 需要其他接口获取
|
||||||
ntrp_level: 'NTRP 3.0' // 需要其他接口获取
|
ntrp_level: 'NTRP 3.0', // 需要其他接口获取
|
||||||
|
phone: userData.phone || '',
|
||||||
|
gender: userData.gender || ''
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response.data.message || '获取用户信息失败');
|
throw new Error(response.message || '获取用户信息失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取用户信息失败:', error);
|
console.error('获取用户信息失败:', error);
|
||||||
@@ -123,7 +127,7 @@ export class UserService {
|
|||||||
return {
|
return {
|
||||||
id: user_id || '1',
|
id: user_id || '1',
|
||||||
nickname: '用户',
|
nickname: '用户',
|
||||||
avatar: require('../../static/userInfo/default_avatar.svg'),
|
avatar: require('../static/userInfo/default_avatar.svg'),
|
||||||
join_date: '未知时间加入',
|
join_date: '未知时间加入',
|
||||||
stats: {
|
stats: {
|
||||||
following: 0,
|
following: 0,
|
||||||
@@ -135,56 +139,120 @@ export class UserService {
|
|||||||
bio: '这个人很懒,什么都没有写...',
|
bio: '这个人很懒,什么都没有写...',
|
||||||
location: '未知地区',
|
location: '未知地区',
|
||||||
occupation: '未知职业',
|
occupation: '未知职业',
|
||||||
ntrp_level: 'NTRP 3.0'
|
ntrp_level: 'NTRP 3.0',
|
||||||
|
phone: '',
|
||||||
|
gender: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户球局记录
|
// 获取用户主办的球局
|
||||||
static async get_user_games(user_id: string, type: 'hosted' | 'participated'): Promise<GameRecord[]> {
|
static async get_hosted_games(user_id: string): Promise<any[]> {
|
||||||
// 模拟API调用 - 这里应该调用真实的球局接口
|
try {
|
||||||
console.log(`获取用户 ${user_id} 的${type === 'hosted' ? '主办' : '参与'}球局`);
|
const response = await httpService.post<any>(API_CONFIG.USER.HOSTED_GAMES, {
|
||||||
return new Promise((resolve) => {
|
user_id
|
||||||
setTimeout(() => {
|
}, {
|
||||||
const mock_games: GameRecord[] = [
|
needAuth: false,
|
||||||
{
|
showLoading: false
|
||||||
id: '1',
|
});
|
||||||
title: type === 'hosted' ? '女生轻松双打' : '周末双打练习',
|
|
||||||
date: '明天(周五)',
|
if (response.code === 0) {
|
||||||
time: '下午5点',
|
return response.data.rows || [];
|
||||||
duration: '2小时',
|
} else {
|
||||||
location: '仁恒河滨花园网球场',
|
throw new Error(response.message || '获取主办球局失败');
|
||||||
type: '室外',
|
}
|
||||||
distance: '3.5km',
|
} catch (error) {
|
||||||
participants: [
|
console.error('获取主办球局失败:', error);
|
||||||
{ avatar: require('../../static/userInfo/user1.svg'), nickname: '用户1' },
|
// 返回模拟数据
|
||||||
{ avatar: require('../../static/userInfo/user2.svg'), nickname: '用户2' }
|
return [
|
||||||
],
|
{
|
||||||
max_participants: 4,
|
id: 1,
|
||||||
current_participants: 2,
|
title: '女生轻松双打',
|
||||||
level_range: '2.0 至 2.5',
|
dateTime: '明天(周五) 下午5点',
|
||||||
game_type: '双打',
|
location: '仁恒河滨花园网球场',
|
||||||
images: [
|
distance: '3.5km',
|
||||||
require('../../static/userInfo/game1.svg'),
|
registeredCount: 2,
|
||||||
require('../../static/userInfo/game2.svg'),
|
maxCount: 4,
|
||||||
require('../../static/userInfo/game3.svg')
|
skillLevel: '2.0-2.5',
|
||||||
]
|
matchType: '双打',
|
||||||
}
|
images: [
|
||||||
];
|
require('../static/userInfo/game1.svg'),
|
||||||
resolve(mock_games);
|
require('../static/userInfo/game2.svg'),
|
||||||
}, 300);
|
require('../static/userInfo/game3.svg')
|
||||||
});
|
],
|
||||||
|
shinei: '室外'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户参与的球局
|
||||||
|
static async get_participated_games(user_id: string): Promise<any[]> {
|
||||||
|
try {
|
||||||
|
const response = await httpService.post<any>(API_CONFIG.USER.PARTICIPATED_GAMES, {
|
||||||
|
user_id
|
||||||
|
}, {
|
||||||
|
needAuth: false,
|
||||||
|
showLoading: false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.code === 0) {
|
||||||
|
return response.data.rows || [];
|
||||||
|
} else {
|
||||||
|
throw new Error(response.message || '获取参与球局失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取参与球局失败:', error);
|
||||||
|
// 返回模拟数据
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
title: '周末双打练习',
|
||||||
|
dateTime: '后天(周六) 上午10点',
|
||||||
|
location: '上海网球中心',
|
||||||
|
distance: '5.2km',
|
||||||
|
registeredCount: 6,
|
||||||
|
maxCount: 8,
|
||||||
|
skillLevel: '3.0-3.5',
|
||||||
|
matchType: '双打',
|
||||||
|
images: [
|
||||||
|
require('../static/userInfo/game2.svg'),
|
||||||
|
require('../static/userInfo/game3.svg')
|
||||||
|
],
|
||||||
|
shinei: '室内'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户球局记录(兼容旧方法)
|
||||||
|
static async get_user_games(user_id: string, type: 'hosted' | 'participated'): Promise<any[]> {
|
||||||
|
if (type === 'hosted') {
|
||||||
|
return this.get_hosted_games(user_id);
|
||||||
|
} else {
|
||||||
|
return this.get_participated_games(user_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关注/取消关注用户
|
// 关注/取消关注用户
|
||||||
static async toggle_follow(user_id: string, is_following: boolean): Promise<boolean> {
|
static async toggle_follow(user_id: string, is_following: boolean): Promise<boolean> {
|
||||||
// 模拟API调用 - 这里应该调用真实的关注接口
|
try {
|
||||||
return new Promise((resolve) => {
|
const endpoint = is_following ? API_CONFIG.USER.UNFOLLOW : API_CONFIG.USER.FOLLOW;
|
||||||
setTimeout(() => {
|
const response = await httpService.post<any>(endpoint, { user_id }, {
|
||||||
console.log(`用户 ${user_id} 关注状态变更:`, !is_following);
|
needAuth: false,
|
||||||
resolve(!is_following);
|
showLoading: true,
|
||||||
}, 200);
|
loadingText: is_following ? '取消关注中...' : '关注中...'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (response.code === 0) {
|
||||||
|
return !is_following;
|
||||||
|
} else {
|
||||||
|
throw new Error(response.message || '操作失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('关注操作失败:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存用户信息
|
// 保存用户信息
|
||||||
@@ -207,17 +275,16 @@ export class UserService {
|
|||||||
country: '' // 需要从用户信息中获取
|
country: '' // 需要从用户信息中获取
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await Taro.request<ApiResponse<any>>({
|
const response = await httpService.post<any>(API_CONFIG.USER.UPDATE, updateParams, {
|
||||||
url: `${API_CONFIG.BASE_URL}${API_CONFIG.USER.UPDATE}`,
|
needAuth: false,
|
||||||
method: 'POST',
|
showLoading: true,
|
||||||
data: updateParams,
|
loadingText: '保存中...'
|
||||||
...REQUEST_CONFIG
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.code === 0) {
|
if (response.code === 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response.data.message || '更新用户信息失败');
|
throw new Error(response.message || '更新用户信息失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('保存用户信息失败:', error);
|
console.error('保存用户信息失败:', error);
|
||||||
@@ -225,6 +292,29 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取用户动态
|
||||||
|
static async get_user_activities(user_id: string, page: number = 1, limit: number = 10): Promise<any[]> {
|
||||||
|
try {
|
||||||
|
const response = await httpService.post<any>('/user/activities', {
|
||||||
|
user_id,
|
||||||
|
page,
|
||||||
|
limit
|
||||||
|
}, {
|
||||||
|
needAuth: false,
|
||||||
|
showLoading: false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.code === 0) {
|
||||||
|
return response.data.activities || [];
|
||||||
|
} else {
|
||||||
|
throw new Error(response.message || '获取用户动态失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取用户动态失败:', error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 上传头像
|
// 上传头像
|
||||||
static async upload_avatar(file_path: string): Promise<string> {
|
static async upload_avatar(file_path: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
@@ -235,7 +325,7 @@ export class UserService {
|
|||||||
name: 'file'
|
name: 'file'
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = JSON.parse(uploadResponse.data) as ApiResponse<UploadResponseData>;
|
const result = JSON.parse(uploadResponse.data) as { code: number; message: string; data: UploadResponseData };
|
||||||
if (result.code === 0) {
|
if (result.code === 0) {
|
||||||
// 使用新的响应格式中的file_url字段
|
// 使用新的响应格式中的file_url字段
|
||||||
return result.data.file_url;
|
return result.data.file_url;
|
||||||
@@ -245,7 +335,7 @@ export class UserService {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('头像上传失败:', error);
|
console.error('头像上传失败:', error);
|
||||||
// 如果上传失败,返回默认头像
|
// 如果上传失败,返回默认头像
|
||||||
return require('../../static/userInfo/default_avatar.svg');
|
return require('../static/userInfo/default_avatar.svg');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user