1
This commit is contained in:
8
src/user_pages/edit/index.config.ts
Normal file
8
src/user_pages/edit/index.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '编辑资料',
|
||||
navigationBarBackgroundColor: '#ffffff',
|
||||
navigationBarTextStyle: 'black',
|
||||
backgroundColor: '#f5f5f5',
|
||||
enablePullDownRefresh: false,
|
||||
disableScroll: false,
|
||||
})
|
||||
279
src/user_pages/edit/index.scss
Normal file
279
src/user_pages/edit/index.scss
Normal file
@@ -0,0 +1,279 @@
|
||||
// 编辑资料页面样式
|
||||
.edit_profile_page {
|
||||
min-height: 100vh;
|
||||
background: radial-gradient(circle at 50% 0%, rgba(238, 255, 220, 1) 0%, rgba(255, 255, 255, 1) 37%);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 导航栏
|
||||
.navbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
height: 98px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
backdrop-filter: blur(10px);
|
||||
border-radius: 44px 44px 0px 0px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 21px 16px 0px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.navbar_left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
|
||||
.back_icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar_title {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 17px;
|
||||
line-height: 1.4em;
|
||||
color: #000000;
|
||||
text-align: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.navbar_right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
|
||||
.save_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
line-height: 1.4em;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 主要内容区域
|
||||
.main_content {
|
||||
position: relative;
|
||||
z-index: 5;
|
||||
flex: 1;
|
||||
margin-top: 98px;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
padding: 0px 16px;
|
||||
padding-bottom: 48px;
|
||||
|
||||
// 头像编辑区域
|
||||
.avatar_section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 48px;
|
||||
margin-top: 98px;
|
||||
|
||||
.avatar_container {
|
||||
position: relative;
|
||||
|
||||
|
||||
|
||||
.avatar {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
object-fit: cover;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.12), 0px 0px 1px 0px rgba(0, 0, 0, 0.2);
|
||||
border: 0.5px solid rgba(255, 255, 255, 0.65);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.avatar_overlay {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: #000000;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
||||
z-index: 10;
|
||||
|
||||
.upload_icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单区域
|
||||
.form_section {
|
||||
margin-bottom: 48px;
|
||||
box-shadow: 0px 4px 36px 0px rgba(0, 0, 0, 0.06);
|
||||
|
||||
.form_group {
|
||||
background: #FFFFFF;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
|
||||
&:not(:first-child) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.form_item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
min-height: 44px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.item_left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
|
||||
.item_icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.item_label {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
line-height: 1.71em;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
|
||||
.item_right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
justify-content: flex-end;
|
||||
|
||||
.item_input {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.71em;
|
||||
color: #000000;
|
||||
border: none;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
|
||||
&::placeholder {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
.item_value {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.71em;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.bio_textarea {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.71em;
|
||||
color: #000000;
|
||||
border: none;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
min-height: 20px;
|
||||
resize: none;
|
||||
|
||||
&::placeholder {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
.arrow_icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
opacity: 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
.divider {
|
||||
position: absolute;
|
||||
left: 36px;
|
||||
right: 12px;
|
||||
height: 0.5px;
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
border-radius: 99px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 退出登录区域
|
||||
.logout_section {
|
||||
margin-top: 16px;
|
||||
|
||||
.logout_button {
|
||||
background: #FFFFFF;
|
||||
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||
border-radius: 16px;
|
||||
padding: 2px 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
min-height: 48px;
|
||||
|
||||
.logout_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
line-height: 1.4em;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载状态
|
||||
.loading_container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 200px;
|
||||
|
||||
.loading_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 16px;
|
||||
line-height: 1.4em;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
}
|
||||
}
|
||||
458
src/user_pages/edit/index.tsx
Normal file
458
src/user_pages/edit/index.tsx
Normal file
@@ -0,0 +1,458 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { View, Text, Image, ScrollView, Picker, Input } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import './index.scss';
|
||||
import { UserInfo } from '@/components/UserInfo';
|
||||
import { UserService } from '@/services/userService';
|
||||
import { clear_login_state } from '@/services/loginService';
|
||||
import { convert_db_gender_to_display } from '@/utils/genderUtils';
|
||||
import { EditModal } from '@/components';
|
||||
|
||||
const EditProfilePage: React.FC = () => {
|
||||
// 用户信息状态
|
||||
const [user_info, setUserInfo] = useState<UserInfo>({
|
||||
id: '1',
|
||||
nickname: '加载中...',
|
||||
avatar: require('@/static/userInfo/default_avatar.svg'),
|
||||
join_date: '加载中...',
|
||||
stats: {
|
||||
following: 0,
|
||||
friends: 0,
|
||||
hosted: 0,
|
||||
participated: 0
|
||||
},
|
||||
personal_profile: '加载中...',
|
||||
location: '加载中...',
|
||||
occupation: '加载中...',
|
||||
ntrp_level: 'NTRP 3.0',
|
||||
phone: '',
|
||||
gender: ''
|
||||
});
|
||||
|
||||
// 表单状态
|
||||
const [form_data, setFormData] = useState({
|
||||
nickname: '',
|
||||
personal_profile: '',
|
||||
location: '',
|
||||
occupation: '',
|
||||
ntrp_level: '4.0',
|
||||
phone: '',
|
||||
gender: '',
|
||||
birthday: '2000-01-01'
|
||||
});
|
||||
|
||||
// 加载状态
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// 编辑弹窗状态
|
||||
const [edit_modal_visible, setEditModalVisible] = useState(false);
|
||||
const [editing_field, setEditingField] = useState<string>('');
|
||||
|
||||
// 页面加载时初始化数据
|
||||
useEffect(() => {
|
||||
load_user_info();
|
||||
}, []);
|
||||
|
||||
// 加载用户信息
|
||||
const load_user_info = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const user_data = await UserService.get_user_info();
|
||||
setUserInfo(user_data);
|
||||
setFormData({
|
||||
nickname: user_data.nickname || '',
|
||||
personal_profile: user_data.personal_profile || '',
|
||||
location: user_data.location || '',
|
||||
occupation: user_data.occupation || '',
|
||||
ntrp_level: user_data.ntrp_level || 'NTRP 4.0',
|
||||
phone: user_data.phone || '',
|
||||
gender: user_data.gender || '',
|
||||
birthday: '2000-01-01' // 默认生日,实际应该从用户数据获取
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('加载用户信息失败:', error);
|
||||
Taro.showToast({
|
||||
title: '加载用户信息失败',
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 处理头像上传
|
||||
const handle_avatar_upload = () => {
|
||||
Taro.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0];
|
||||
try {
|
||||
const avatar_url = await UserService.upload_avatar(tempFilePath);
|
||||
setUserInfo(prev => ({ ...prev, avatar: avatar_url }));
|
||||
Taro.showToast({
|
||||
title: '头像上传成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('头像上传失败:', error);
|
||||
Taro.showToast({
|
||||
title: '头像上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 处理编辑弹窗
|
||||
const handle_open_edit_modal = (field: string) => {
|
||||
if (field === 'nickname') {
|
||||
// 手动输入
|
||||
setEditingField(field);
|
||||
setEditModalVisible(true);
|
||||
} else {
|
||||
setEditingField(field);
|
||||
setEditModalVisible(true);
|
||||
}
|
||||
};
|
||||
|
||||
const handle_edit_modal_save = async (value: string) => {
|
||||
try {
|
||||
// 调用更新用户信息接口,只传递修改的字段
|
||||
const update_data = { [editing_field]: value };
|
||||
await UserService.update_user_info(update_data);
|
||||
|
||||
// 更新本地状态
|
||||
setFormData(prev => ({ ...prev, [editing_field]: value }));
|
||||
setUserInfo(prev => ({ ...prev, [editing_field]: value }));
|
||||
|
||||
// 关闭弹窗
|
||||
setEditModalVisible(false);
|
||||
setEditingField('');
|
||||
|
||||
// 显示成功提示
|
||||
Taro.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
Taro.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handle_edit_modal_cancel = () => {
|
||||
setEditModalVisible(false);
|
||||
setEditingField('');
|
||||
};
|
||||
|
||||
// 处理字段编辑
|
||||
const handle_field_edit = async (field: string, value: string) => {
|
||||
try {
|
||||
// 调用更新用户信息接口,只传递修改的字段
|
||||
const update_data = { [field]: value };
|
||||
await UserService.update_user_info(update_data);
|
||||
|
||||
// 更新本地状态
|
||||
setFormData(prev => ({ ...prev, [field]: value }));
|
||||
setUserInfo(prev => ({ ...prev, [field]: value }));
|
||||
|
||||
// 显示成功提示
|
||||
Taro.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error);
|
||||
Taro.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 处理性别选择
|
||||
const handle_gender_change = (e: any) => {
|
||||
const gender_value = e.detail.value;
|
||||
// 使用工具函数转换:页面选择器值(0/1) -> 数据库值('0'/'1')
|
||||
const gender_db_value = gender_value === 0 ? '0' : '1';
|
||||
handle_field_edit('gender', gender_db_value);
|
||||
};
|
||||
|
||||
// 处理生日选择
|
||||
const handle_birthday_change = (e: any) => {
|
||||
const birthday_value = e.detail.value;
|
||||
handle_field_edit('birthday', birthday_value);
|
||||
};
|
||||
|
||||
// 处理职业输入 - 实时更新本地状态
|
||||
const handle_occupation_input = (e: any) => {
|
||||
const occupation_value = e.detail.value;
|
||||
setFormData(prev => ({ ...prev, occupation: occupation_value }));
|
||||
};
|
||||
|
||||
// 处理职业输入 - 失去焦点时保存到服务器
|
||||
const handle_occupation_blur = (e: any) => {
|
||||
const occupation_value = e.detail.value;
|
||||
handle_field_edit('occupation', occupation_value);
|
||||
};
|
||||
|
||||
// 处理地区输入 - 实时更新本地状态
|
||||
const handle_location_input = (e: any) => {
|
||||
const location_value = e.detail.value;
|
||||
setFormData(prev => ({ ...prev, location: location_value }));
|
||||
};
|
||||
|
||||
// 处理地区输入 - 失去焦点时保存到服务器
|
||||
const handle_location_blur = (e: any) => {
|
||||
const location_value = e.detail.value;
|
||||
handle_field_edit('location', location_value);
|
||||
};
|
||||
|
||||
// 处理手机号输入 - 实时更新本地状态
|
||||
const handle_phone_input = (e: any) => {
|
||||
const phone_value = e.detail.value;
|
||||
setFormData(prev => ({ ...prev, phone: phone_value }));
|
||||
};
|
||||
|
||||
// 处理手机号输入 - 失去焦点时保存到服务器
|
||||
const handle_phone_blur = (e: any) => {
|
||||
const phone_value = e.detail.value;
|
||||
handle_field_edit('phone', phone_value);
|
||||
};
|
||||
|
||||
|
||||
// 处理退出登录
|
||||
const handle_logout = () => {
|
||||
Taro.showModal({
|
||||
title: '确认退出',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 清除用户数据
|
||||
clear_login_state();
|
||||
|
||||
Taro.reLaunch({
|
||||
url: '/login_pages/index/index'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="edit_profile_page">
|
||||
{/* 导航栏 */}
|
||||
|
||||
{/* 主要内容 */}
|
||||
<ScrollView className="main_content" scrollY>
|
||||
{loading ? (
|
||||
<View className="loading_container">
|
||||
<Text className="loading_text">加载中...</Text>
|
||||
</View>
|
||||
) : (
|
||||
<>
|
||||
{/* 头像编辑区域 */}
|
||||
<View className="avatar_section">
|
||||
<View className="avatar_container" onClick={handle_avatar_upload}>
|
||||
<Image className="avatar" src={user_info.avatar} />
|
||||
<View className="avatar_overlay">
|
||||
<Image
|
||||
className="upload_icon"
|
||||
src={require('@/static/userInfo/edit2.svg')}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
|
||||
</View>
|
||||
|
||||
{/* 基本信息编辑 */}
|
||||
<View className="form_section">
|
||||
{/* 名字 */}
|
||||
<View className="form_group">
|
||||
<View className="form_item" onClick={() => handle_open_edit_modal('nickname')}>
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/user1.svg')} />
|
||||
<Text className="item_label">名字</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Text className="item_value">{form_data.nickname || '188的王晨'}</Text>
|
||||
<Image className="arrow_icon" src={require('@/static/list/icon-list-right-arrow.svg')} />
|
||||
</View>
|
||||
</View>
|
||||
<View className="divider"></View>
|
||||
</View>
|
||||
|
||||
{/* 性别 */}
|
||||
<View className="form_group">
|
||||
<Picker
|
||||
mode="selector"
|
||||
range={['男', '女']}
|
||||
value={form_data.gender === '0' ? 0 : form_data.gender === '1' ? 1 : 0}
|
||||
onChange={handle_gender_change}
|
||||
>
|
||||
<View className="form_item">
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/user2.svg')} />
|
||||
<Text className="item_label">性别</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Text className="item_value">
|
||||
{convert_db_gender_to_display(form_data.gender)}
|
||||
</Text>
|
||||
<Image className="arrow_icon" src={require('@/static/list/icon-list-right-arrow.svg')} />
|
||||
</View>
|
||||
</View>
|
||||
</Picker>
|
||||
<View className="divider"></View>
|
||||
</View>
|
||||
|
||||
{/* 生日 */}
|
||||
<View className="form_group">
|
||||
<Picker
|
||||
mode="date"
|
||||
value={form_data.birthday}
|
||||
onChange={handle_birthday_change}
|
||||
>
|
||||
<View className="form_item">
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/tennis.svg')} />
|
||||
<Text className="item_label">生日</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Text className="item_value">{form_data.birthday}</Text>
|
||||
<Image className="arrow_icon" src={require('@/static/list/icon-list-right-arrow.svg')} />
|
||||
</View>
|
||||
</View>
|
||||
</Picker>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 简介编辑 */}
|
||||
<View className="form_section">
|
||||
<View className="form_group">
|
||||
<View className="form_item" onClick={() => handle_open_edit_modal('personal_profile')}>
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/message.svg')} />
|
||||
<Text className="item_label">简介</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Text className="item_value">
|
||||
{form_data.personal_profile || '介绍一下自己'}
|
||||
</Text>
|
||||
<Image className="arrow_icon" src={require('@/static/list/icon-list-right-arrow.svg')} />
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 地区、NTRP水平、职业 */}
|
||||
<View className="form_section">
|
||||
<View className="form_group">
|
||||
{/* 地区 */}
|
||||
<View className="form_item">
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/location.svg')} />
|
||||
<Text className="item_label">地区</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Input
|
||||
className="item_input"
|
||||
value={form_data.location}
|
||||
placeholder="请输入地区"
|
||||
onInput={handle_location_input}
|
||||
onBlur={handle_location_blur}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View className="divider"></View>
|
||||
|
||||
{/* NTRP水平 */}
|
||||
<View className="form_item">
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/tennis.svg')} />
|
||||
<Text className="item_label">NTRP 水平</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Text className="item_value">{form_data.ntrp_level}</Text>
|
||||
<Image className="arrow_icon" src={require('@/static/list/icon-list-right-arrow.svg')} />
|
||||
</View>
|
||||
</View>
|
||||
<View className="divider"></View>
|
||||
|
||||
{/* 职业 */}
|
||||
<View className="form_item">
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/sc.svg')} />
|
||||
<Text className="item_label">职业</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Input
|
||||
className="item_input"
|
||||
value={form_data.occupation}
|
||||
placeholder="请输入职业"
|
||||
onInput={handle_occupation_input}
|
||||
onBlur={handle_occupation_blur}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 手机号 */}
|
||||
<View className="form_section">
|
||||
<View className="form_group">
|
||||
<View className="form_item">
|
||||
<View className="item_left">
|
||||
<Image className="item_icon" src={require('@/static/userInfo/message.svg')} />
|
||||
<Text className="item_label">手机</Text>
|
||||
</View>
|
||||
<View className="item_right">
|
||||
<Input
|
||||
className="item_input"
|
||||
value={form_data.phone}
|
||||
placeholder="请输入手机号"
|
||||
type="number"
|
||||
onInput={handle_phone_input}
|
||||
onBlur={handle_phone_blur}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View className="divider"></View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 退出登录 */}
|
||||
<View className="logout_section">
|
||||
<View className="logout_button" onClick={handle_logout}>
|
||||
<Text className="logout_text">退出登录</Text>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</ScrollView>
|
||||
|
||||
{/* 编辑弹窗 */}
|
||||
<EditModal
|
||||
visible={edit_modal_visible}
|
||||
type={editing_field}
|
||||
title={editing_field === 'nickname' ? '编辑名字' : '编辑简介'}
|
||||
placeholder={editing_field === 'nickname' ? '请输入您的名字' : '介绍一下你的喜好,或者训练习惯'}
|
||||
initialValue={form_data[editing_field as keyof typeof form_data] || ''}
|
||||
maxLength={editing_field === 'nickname' ? 20 : 100}
|
||||
onSave={handle_edit_modal_save}
|
||||
onCancel={handle_edit_modal_cancel}
|
||||
validationMessage={editing_field === 'nickname' ? '请填写 1-20 个字符' : '请填写 2-100 个字符'}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default EditProfilePage;
|
||||
9
src/user_pages/myself/index.config.ts
Normal file
9
src/user_pages/myself/index.config.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default {
|
||||
navigationBarTitleText: '个人主页',
|
||||
navigationBarBackgroundColor: '#FFFFFF',
|
||||
navigationBarTextStyle: 'black',
|
||||
backgroundColor: '#FAFAFA',
|
||||
enablePullDownRefresh: false,
|
||||
disableScroll: false,
|
||||
navigationStyle: 'custom'
|
||||
}
|
||||
359
src/user_pages/myself/index.scss
Normal file
359
src/user_pages/myself/index.scss
Normal file
@@ -0,0 +1,359 @@
|
||||
@use '../../scss/common.scss' as *;
|
||||
|
||||
// 个人页面样式
|
||||
.myself_page {
|
||||
min-height: 100vh;
|
||||
background: radial-gradient(circle at 50% 0%, rgba(238, 255, 220, 1) 0%, rgba(255, 255, 255, 1) 37%);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 主要内容区域
|
||||
.main_content {
|
||||
position: relative;
|
||||
z-index: 5;
|
||||
flex: 1;
|
||||
margin-top: 0;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
padding: 0px 15px 15px 15px ;
|
||||
|
||||
// 用户信息区域
|
||||
.user_info_section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
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 {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
.stats_container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
|
||||
.stat_item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.stat_number {
|
||||
@include text-medium;
|
||||
}
|
||||
|
||||
.stat_label {
|
||||
@include text-small;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 标签和简介
|
||||
.tags_bio_section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
.tags_container {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.tag_item {
|
||||
@include tag-base;
|
||||
|
||||
.tag_icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.tag_text {
|
||||
@include text-tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bio_text {
|
||||
@include text-body;
|
||||
white-space: pre-line;
|
||||
}
|
||||
}
|
||||
|
||||
// 球局订单和收藏功能
|
||||
.quick_actions_section {
|
||||
margin-bottom: 16px;
|
||||
|
||||
.action_card {
|
||||
@include card-base;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
|
||||
.action_content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 20px 0;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.02);
|
||||
}
|
||||
|
||||
.action_icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.action_text {
|
||||
@include text-style(15px, 600, 1.4em);
|
||||
color: $color-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.action_divider {
|
||||
width: 1px;
|
||||
height: 16px;
|
||||
background: $color-primary-lightest-5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局类型标签页
|
||||
.game_tabs_section {
|
||||
|
||||
.tab_container {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
padding: 12px 15px;
|
||||
|
||||
.tab_item {
|
||||
padding: 12px 0;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
.tab_text {
|
||||
@include text-primary;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
&.active {
|
||||
.tab_text {
|
||||
color: $color-primary;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.active) {
|
||||
.tab_text {
|
||||
color: $color-primary-lightest-2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局列表区域
|
||||
.game_list_section {
|
||||
.date_header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 10px 15px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.date_text {
|
||||
@include text-style(14px, 600, 1.4em, 2.71%);
|
||||
color: $color-primary-light;
|
||||
}
|
||||
|
||||
.separator {
|
||||
@include text-style(18px, 400, 1.4em, 2.11%);
|
||||
color: $color-primary-lightest;
|
||||
}
|
||||
|
||||
.weekday_text {
|
||||
@include text-style(14px, 600, 1.4em, 2.71%);
|
||||
color: $color-primary-light;
|
||||
}
|
||||
}
|
||||
|
||||
// 球局卡片
|
||||
.game_cards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
padding: 0 5px 15px;
|
||||
|
||||
.game_card {
|
||||
@include card-base;
|
||||
padding: 0 0 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
// 球局标题和类型
|
||||
.game_header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 15px 0;
|
||||
|
||||
.game_title {
|
||||
@include text-style(16px, 600, 1.5em);
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
.game_type_icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
|
||||
.type_icon {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局时间
|
||||
.game_time {
|
||||
padding: 6px 15px 0;
|
||||
|
||||
.time_text {
|
||||
@include text-caption;
|
||||
}
|
||||
}
|
||||
|
||||
// 球局地点和类型
|
||||
.game_location {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 4px 15px 0;
|
||||
|
||||
.location_text,
|
||||
.type_text,
|
||||
.distance_text {
|
||||
@include text-caption;
|
||||
}
|
||||
|
||||
.separator {
|
||||
@include text-style(14px, 400, 1.3em);
|
||||
color: $color-text-tertiary;
|
||||
}
|
||||
}
|
||||
|
||||
// 球局图片
|
||||
.game_images {
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
right: 5px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
box-shadow: 0px 4px 24px 0px rgba(0, 0, 0, 0.2);
|
||||
|
||||
.game_image {
|
||||
position: absolute;
|
||||
width: 56.44px;
|
||||
height: 56.44px;
|
||||
border-radius: 9px;
|
||||
border: 1.5px solid $color-white;
|
||||
|
||||
&:nth-child(1) {
|
||||
top: 4.18px;
|
||||
left: 19.18px;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
top: 26.5px;
|
||||
left: 38px;
|
||||
width: 61.86px;
|
||||
height: 61.86px;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
top: 32.5px;
|
||||
left: 0;
|
||||
width: 62.04px;
|
||||
height: 62.04px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局信息标签
|
||||
.game_tags {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 6px;
|
||||
padding: 8px 15px 0;
|
||||
|
||||
.participants_info {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
|
||||
.avatars {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: -8px;
|
||||
|
||||
.participant_avatar {
|
||||
@include avatar-base(20px);
|
||||
border: 1px solid $color-white;
|
||||
}
|
||||
}
|
||||
|
||||
.participants_count {
|
||||
@include tag-base;
|
||||
padding: 6px;
|
||||
|
||||
.count_text {
|
||||
@include text-tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.game_info_tags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
|
||||
.info_tag {
|
||||
@include tag-base;
|
||||
|
||||
.tag_text {
|
||||
@include text-tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
220
src/user_pages/myself/index.tsx
Normal file
220
src/user_pages/myself/index.tsx
Normal file
@@ -0,0 +1,220 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { View, Text, Image, ScrollView } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.scss";
|
||||
import GuideBar from "@/components/GuideBar";
|
||||
import { UserInfoCard, UserInfo } from "@/components/UserInfo/index";
|
||||
import { UserService } from "@/services/userService";
|
||||
import ListContainer from "@/container/listContainer";
|
||||
import { TennisMatch } from "@/../types/list/types";
|
||||
import { withAuth } from "@/components";
|
||||
|
||||
const MyselfPage: React.FC = () => {
|
||||
// 获取页面参数
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const user_id = instance.router?.params?.userid || "";
|
||||
|
||||
// 判断是否为当前用户
|
||||
const is_current_user = !user_id;
|
||||
|
||||
// 用户信息状态
|
||||
const [user_info, set_user_info] = useState<UserInfo>({
|
||||
id: "1",
|
||||
nickname: "加载中...",
|
||||
avatar: require("@/static/userInfo/default_avatar.svg"),
|
||||
join_date: "加载中...",
|
||||
stats: {
|
||||
following: 0,
|
||||
friends: 0,
|
||||
hosted: 0,
|
||||
participated: 0,
|
||||
},
|
||||
bio: "加载中...",
|
||||
location: "加载中...",
|
||||
occupation: "加载中...",
|
||||
ntrp_level: "NTRP 3.0",
|
||||
});
|
||||
|
||||
// 球局记录状态
|
||||
const [game_records, set_game_records] = useState<TennisMatch[]>([]);
|
||||
const [loading, set_loading] = useState(true);
|
||||
|
||||
// 关注状态
|
||||
const [is_following, setIsFollowing] = useState(false);
|
||||
|
||||
// 当前激活的标签页
|
||||
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);
|
||||
} else {
|
||||
games_data = await UserService.get_participated_games(user_id);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
games_data = await UserService.get_participated_games(user_id);
|
||||
}
|
||||
set_game_records(games_data);
|
||||
} catch (error) {
|
||||
console.error("加载球局数据失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
// 处理关注/取消关注
|
||||
const handle_follow = async () => {
|
||||
try {
|
||||
const new_following_state = await UserService.toggle_follow(
|
||||
user_id,
|
||||
is_following,
|
||||
);
|
||||
setIsFollowing(new_following_state);
|
||||
|
||||
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_orders = () => {
|
||||
Taro.navigateTo({
|
||||
url: "/order_pages/orderList/index",
|
||||
});
|
||||
};
|
||||
|
||||
// 处理收藏
|
||||
const handle_favorites = () => {
|
||||
Taro.navigateTo({
|
||||
url: "/other_pages/favorites/index",
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="myself_page">
|
||||
{/* 主要内容 */}
|
||||
<View className="main_content">
|
||||
{/* 用户信息区域 */}
|
||||
<View className="user_info_section">
|
||||
{loading ? (
|
||||
<View className="loading_container">
|
||||
<Text className="loading_text">加载中...</Text>
|
||||
</View>
|
||||
) : (
|
||||
<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="action_card">
|
||||
<View className="action_content" onClick={handle_game_orders}>
|
||||
<Image
|
||||
className="action_icon"
|
||||
src={require("@/static/userInfo/order_btn.svg")}
|
||||
/>
|
||||
<Text className="action_text">我的订单</Text>
|
||||
</View>
|
||||
<View className="action_divider"></View>
|
||||
<View className="action_content" onClick={handle_favorites}>
|
||||
<Image
|
||||
className="action_icon"
|
||||
src={require("@/static/userInfo/sc.svg")}
|
||||
/>
|
||||
<Text className="action_text">收藏</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 球局类型标签页 */}
|
||||
<View className="game_tabs_section">
|
||||
<View className="tab_container">
|
||||
<View
|
||||
className={`tab_item ${active_tab === "hosted" ? "active" : ""}`}
|
||||
onClick={() => setActiveTab("hosted")}
|
||||
>
|
||||
<Text className="tab_text">我主办的</Text>
|
||||
</View>
|
||||
<View
|
||||
className={`tab_item ${active_tab === "participated" ? "active" : ""}`}
|
||||
onClick={() => setActiveTab("participated")}
|
||||
>
|
||||
<Text className="tab_text">我参与的</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 球局列表 */}
|
||||
<View className="game_list_section">
|
||||
<ScrollView scrollY>
|
||||
<ListContainer
|
||||
data={game_records}
|
||||
recommendList={[]}
|
||||
loading={loading}
|
||||
error={null}
|
||||
reload={load_game_data}
|
||||
/>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
<GuideBar currentPage="personal" />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default withAuth(MyselfPage);
|
||||
4
src/user_pages/other/index.config.ts
Normal file
4
src/user_pages/other/index.config.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '用户主页',
|
||||
navigationStyle: 'custom'
|
||||
})
|
||||
490
src/user_pages/other/index.scss
Normal file
490
src/user_pages/other/index.scss
Normal file
@@ -0,0 +1,490 @@
|
||||
// 他人用户页面样式
|
||||
.other_user_page {
|
||||
min-height: 100vh;
|
||||
background: radial-gradient(circle at 50% 0%, rgba(238, 255, 220, 1) 0%, rgba(255, 255, 255, 1) 37%);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 主要内容区域
|
||||
.main_content {
|
||||
position: relative;
|
||||
z-index: 5;
|
||||
flex: 1;
|
||||
margin-top: 0;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
padding: 15px 15px 15px;
|
||||
|
||||
// 用户信息区域
|
||||
.user_info_section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
// 基本信息
|
||||
.basic_info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
|
||||
.avatar_container {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.12), 0px 0px 1px 0px rgba(0, 0, 0, 0.2);
|
||||
|
||||
.avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.info_container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
|
||||
.nickname {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 1.9%;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.join_date {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 2.7%;
|
||||
color: rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 统计数据
|
||||
.stats_section {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
|
||||
.stats_container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
|
||||
.stat_item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.stat_number {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 18px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 2.1%;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
}
|
||||
|
||||
.stat_label {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 3.2%;
|
||||
color: rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.action_buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
.follow_button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 12px 16px 12px 12px;
|
||||
height: 40px;
|
||||
background: #000000;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&.following {
|
||||
background: #FFFFFF;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.button_icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.button_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
color: #FFFFFF;
|
||||
|
||||
.following & {
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.message_button {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #FFFFFF;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.12);
|
||||
border-radius: 999px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
.button_icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 标签和简介
|
||||
.tags_bio_section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
.tags_container {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.tag_item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 8px;
|
||||
height: 20px;
|
||||
background: #FFFFFF;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.16);
|
||||
border-radius: 999px;
|
||||
|
||||
.tag_icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.tag_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
line-height: 1.8em;
|
||||
letter-spacing: -2.1%;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bio_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 1.571em;
|
||||
color: rgba(0, 0, 0, 0.65);
|
||||
white-space: pre-line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局类型标签页
|
||||
.game_tabs_section {
|
||||
margin-bottom: 16px;
|
||||
|
||||
.tab_container {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
padding: 12px 15px;
|
||||
|
||||
.tab_item {
|
||||
padding: 12px 0;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
.tab_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 1.9%;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
&.active {
|
||||
.tab_text {
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.active) {
|
||||
.tab_text {
|
||||
color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局列表区域
|
||||
.game_list_section {
|
||||
.date_header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 10px 15px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.date_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 2.71%;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
}
|
||||
|
||||
.separator {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 18px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 2.11%;
|
||||
color: rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.weekday_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
letter-spacing: 2.71%;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
}
|
||||
}
|
||||
|
||||
// 球局卡片
|
||||
.game_cards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
padding: 0 5px 15px;
|
||||
|
||||
.game_card {
|
||||
background: #FFFFFF;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.08);
|
||||
border-radius: 20px;
|
||||
padding: 0 0 12px;
|
||||
box-shadow: 0px 4px 36px 0px rgba(0, 0, 0, 0.06);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
// 球局标题和类型
|
||||
.game_header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 15px 0;
|
||||
|
||||
.game_title {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
line-height: 1.5em;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.game_type_icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
|
||||
.type_icon {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局时间
|
||||
.game_time {
|
||||
padding: 6px 15px 0;
|
||||
|
||||
.time_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
line-height: 1.5em;
|
||||
color: rgba(60, 60, 67, 0.6);
|
||||
}
|
||||
}
|
||||
|
||||
// 球局地点和类型
|
||||
.game_location {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 4px 15px 0;
|
||||
|
||||
.location_text,
|
||||
.type_text,
|
||||
.distance_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
line-height: 1.5em;
|
||||
color: rgba(60, 60, 67, 0.6);
|
||||
}
|
||||
|
||||
.separator {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 1.3em;
|
||||
color: rgba(60, 60, 67, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
// 球局图片
|
||||
.game_images {
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
right: 5px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
box-shadow: 0px 4px 24px 0px rgba(0, 0, 0, 0.2);
|
||||
|
||||
.game_image {
|
||||
position: absolute;
|
||||
width: 56.44px;
|
||||
height: 56.44px;
|
||||
border-radius: 9px;
|
||||
border: 1.5px solid #FFFFFF;
|
||||
|
||||
&:nth-child(1) {
|
||||
top: 4.18px;
|
||||
left: 19.18px;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
top: 26.5px;
|
||||
left: 38px;
|
||||
width: 61.86px;
|
||||
height: 61.86px;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
top: 32.5px;
|
||||
left: 0;
|
||||
width: 62.04px;
|
||||
height: 62.04px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 球局信息标签
|
||||
.game_tags {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 6px;
|
||||
padding: 8px 15px 0;
|
||||
|
||||
.participants_info {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
|
||||
.avatars {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: -8px;
|
||||
|
||||
.participant_avatar {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #FFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
.participants_count {
|
||||
background: #FFFFFF;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.16);
|
||||
border-radius: 999px;
|
||||
padding: 6px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.count_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
line-height: 1.8em;
|
||||
letter-spacing: -2.1%;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.game_info_tags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
|
||||
.info_tag {
|
||||
background: #FFFFFF;
|
||||
border: 0.5px solid rgba(0, 0, 0, 0.16);
|
||||
border-radius: 999px;
|
||||
padding: 6px 8px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.tag_text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
line-height: 1.8em;
|
||||
letter-spacing: -2.1%;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
159
src/user_pages/other/index.tsx
Normal file
159
src/user_pages/other/index.tsx
Normal file
@@ -0,0 +1,159 @@
|
||||
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 {
|
||||
UserInfoCard,
|
||||
GameCard,
|
||||
GameTabs,
|
||||
UserInfo,
|
||||
GameRecord,
|
||||
} from "@/components/UserInfo";
|
||||
import { UserService } from "@/services/userService";
|
||||
|
||||
const OtherUserPage: React.FC = () => {
|
||||
// 获取页面参数
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const user_id = instance.router?.params?.userid;
|
||||
|
||||
// 模拟用户数据
|
||||
const [user_info, setUserInfo] = useState<UserInfo>({
|
||||
id: user_id || "1",
|
||||
nickname: "网球爱好者",
|
||||
avatar: require("@/static/userInfo/default_avatar.svg"),
|
||||
join_date: "2024年3月加入",
|
||||
stats: {
|
||||
following: 89,
|
||||
friends: 15,
|
||||
hosted: 12,
|
||||
participated: 35,
|
||||
},
|
||||
tags: ["北京朝阳", "金融从业者", "NTRP 3.5"],
|
||||
bio: "热爱网球的金融从业者,周末喜欢约球\n技术还在提升中,欢迎一起切磋\n平时在朝阳公园附近活动",
|
||||
location: "北京朝阳",
|
||||
occupation: "金融从业者",
|
||||
ntrp_level: "NTRP 3.5",
|
||||
});
|
||||
|
||||
// 模拟球局数据
|
||||
const [game_records, setGameRecords] = useState<GameRecord[]>([]);
|
||||
|
||||
// 关注状态
|
||||
const [is_following, setIsFollowing] = useState(false);
|
||||
|
||||
// 当前激活的标签页
|
||||
const [active_tab, setActiveTab] = useState<"hosted" | "participated">(
|
||||
"hosted",
|
||||
);
|
||||
|
||||
// 页面加载时获取用户信息
|
||||
useEffect(() => {
|
||||
const load_user_data = async () => {
|
||||
if (user_id) {
|
||||
try {
|
||||
const user_data = await UserService.get_user_info(user_id);
|
||||
setUserInfo(user_data);
|
||||
|
||||
const games_data = await UserService.get_user_games(
|
||||
user_id,
|
||||
active_tab,
|
||||
);
|
||||
setGameRecords(games_data);
|
||||
} catch (error) {
|
||||
console.error("加载用户数据失败:", error);
|
||||
Taro.showToast({
|
||||
title: "加载失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
load_user_data();
|
||||
}, [user_id, active_tab]);
|
||||
|
||||
// 处理关注/取消关注
|
||||
const handle_follow = async () => {
|
||||
try {
|
||||
const new_follow_status = await UserService.toggle_follow(
|
||||
user_info.id,
|
||||
is_following,
|
||||
);
|
||||
setIsFollowing(new_follow_status);
|
||||
Taro.showToast({
|
||||
title: new_follow_status ? "关注成功" : "已取消关注",
|
||||
icon: "success",
|
||||
duration: 1500,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("关注操作失败:", error);
|
||||
Taro.showToast({
|
||||
title: "操作失败",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 处理发送消息
|
||||
const handle_send_message = () => {
|
||||
Taro.navigateTo({
|
||||
url: `/mode_user/message/chat/index?user_id=${user_info.id}&nickname=${user_info.nickname}`,
|
||||
});
|
||||
};
|
||||
|
||||
// 处理球局详情
|
||||
const handle_game_detail = (game_id: string) => {
|
||||
Taro.navigateTo({
|
||||
url: `/game_pages/detail/index?id=${game_id}&from=personal`,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="other_user_page">
|
||||
{/* 主要内容 */}
|
||||
<View className="main_content">
|
||||
{/* 用户信息区域 */}
|
||||
<View className="user_info_section">
|
||||
<UserInfoCard
|
||||
user_info={user_info}
|
||||
is_current_user={false}
|
||||
is_following={is_following}
|
||||
on_follow={handle_follow}
|
||||
on_message={handle_send_message}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* 球局类型标签页 */}
|
||||
<GameTabs
|
||||
active_tab={active_tab}
|
||||
on_tab_change={setActiveTab}
|
||||
is_current_user={false}
|
||||
/>
|
||||
|
||||
{/* 球局列表 */}
|
||||
<View className="game_list_section">
|
||||
<View className="date_header">
|
||||
<Text className="date_text">5月29日</Text>
|
||||
<Text className="separator">/</Text>
|
||||
<Text className="weekday_text">星期六</Text>
|
||||
</View>
|
||||
|
||||
{/* 球局卡片 */}
|
||||
<View className="game_cards">
|
||||
{game_records.map((game) => (
|
||||
<GameCard
|
||||
key={game.id}
|
||||
game={game}
|
||||
on_click={handle_game_detail}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<GuideBar currentPage="personal" />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default OtherUserPage;
|
||||
Reference in New Issue
Block a user