This commit is contained in:
张成
2025-09-07 22:52:13 +08:00
parent 446c7564a7
commit 50982b7c02
3 changed files with 25 additions and 21 deletions

View File

@@ -22,7 +22,7 @@ class App extends Component<AppProps> {
// 初始化字典数据 // 初始化字典数据
this.initDictionaryData() this.initDictionaryData()
this.getNavBarHeight() this.getNavBarHeight()
this.getLocation() // this.getLocation()
} }
componentDidShow() { } componentDidShow() { }

View File

@@ -21,8 +21,12 @@ export interface UserInfo {
ntrp_level: string; ntrp_level: string;
phone?: string; phone?: string;
gender?: string; gender?: string;
latitude?: number,
longitude?: number,
} }
// 用户信息卡片组件属性 // 用户信息卡片组件属性
interface UserInfoCardProps { interface UserInfoCardProps {
user_info: UserInfo; user_info: UserInfo;
@@ -34,12 +38,12 @@ interface UserInfoCardProps {
} }
// 处理编辑用户信息 // 处理编辑用户信息
const on_edit = () => { const on_edit = () => {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/userInfo/edit/index' url: '/pages/userInfo/edit/index'
}); });
}; };
// 用户信息卡片组件 // 用户信息卡片组件
export const UserInfoCard: React.FC<UserInfoCardProps> = ({ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
user_info, user_info,
@@ -60,11 +64,11 @@ 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' onClick={on_edit}> <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')}
/> </View> /> </View>
</View> </View>
{/* 统计数据 */} {/* 统计数据 */}
@@ -112,7 +116,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
/> />
</Button> </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}>
@@ -126,7 +130,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
<View className="tags_bio_section"> <View className="tags_bio_section">
<View className="tags_container"> <View className="tags_container">
<View className="tag_item"> <View className="tag_item">
{user_info.gender === "0" && ( {user_info.gender === "0" && (
<Image <Image
className="tag_icon" className="tag_icon"
@@ -155,7 +159,7 @@ export const UserInfoCard: React.FC<UserInfoCardProps> = ({
<Text className="tag_text">{user_info.location || '未设置'}</Text> <Text className="tag_text">{user_info.location || '未设置'}</Text>
</View> </View>
</View> </View>
<Text className="bio_text">{user_info.personal_profile}</Text> <Text className="bio_text">{user_info.personal_profile}</Text>
</View> </View>
</View> </View>
); );

View File

@@ -40,8 +40,8 @@ interface UpdateUserParams {
avatar_url: string; avatar_url: string;
gender: string; gender: string;
phone: string; phone: string;
latitude: number; latitude?: number;
longitude: number; longitude?: number;
city: string; city: string;
province: string; province: string;
country: string; country: string;
@@ -379,17 +379,17 @@ export class UserService {
static async save_user_info(user_info: Partial<UserInfo> & { phone?: string; gender?: string }): Promise<boolean> { static async save_user_info(user_info: Partial<UserInfo> & { phone?: string; gender?: string }): Promise<boolean> {
try { try {
// 获取当前位置信息 // 获取当前位置信息
const location = await Taro.getLocation({ // const location = await Taro.getLocation({
type: 'wgs84' // type: 'wgs84'
}); // });
const updateParams: UpdateUserParams = { const updateParams: UpdateUserParams = {
nickname: user_info.nickname || '', nickname: user_info.nickname || '',
avatar_url: user_info.avatar || '', avatar_url: user_info.avatar || '',
gender: user_info.gender || '', gender: user_info.gender || '',
phone: user_info.phone || '', phone: user_info.phone || '',
latitude: location.latitude, latitude: user_info.latitude||'',
longitude: location.longitude, longitude: user_info.longitude||'',
city: user_info.location || '', city: user_info.location || '',
province: '', // 需要从用户信息中获取 province: '', // 需要从用户信息中获取
country: '' // 需要从用户信息中获取 country: '' // 需要从用户信息中获取