加入群聊

This commit is contained in:
2025-12-01 16:39:09 +08:00
parent 4c9a0da9ac
commit e49f0cca76
6 changed files with 47 additions and 121 deletions

View File

@@ -450,7 +450,7 @@ function Result() {
const { params } = useRouter(); const { params } = useRouter();
const { id } = params; const { id } = params;
const userInfo = useUserInfo(); const userInfo = useUserInfo();
const { fetchUserInfo } = useUserActions(); const { fetchUserInfo, updateUserInfo } = useUserActions();
const { type, next, clear } = useEvaluate(); const { type, next, clear } = useEvaluate();
const radarRef = useRef(); const radarRef = useRef();
@@ -500,6 +500,7 @@ function Result() {
ntrp_level, ntrp_level,
update_type: "test_result", update_type: "test_result",
}); });
updateUserInfo({ ntrp_level: ntrp_level });
} catch (e) { } catch (e) {
Taro.showToast({ title: e.message, icon: "none" }); Taro.showToast({ title: e.message, icon: "none" });
} }

View File

@@ -83,7 +83,7 @@ interface TestResult {
level_description: string; level_description: string;
radar_data: RadarData; radar_data: RadarData;
test_duration: number; // 单位秒 test_duration: number; // 单位秒
create_time: string; // 时间字符串 create_time: string; // 时间字符串
} }
// data 对象 // data 对象
@@ -103,7 +103,10 @@ class EvaluateService {
} }
// 提交答案 // 提交答案
async submit(req: { answers: { question_id: number, answer_index: number }[], test_duration: number }): Promise<ApiResponse<TestResultData>> { async submit(req: {
answers: { question_id: number; answer_index: number }[];
test_duration: number;
}): Promise<ApiResponse<TestResultData>> {
return httpService.post("/ntrp/submit", req, { showLoading: true }); return httpService.post("/ntrp/submit", req, { showLoading: true });
} }
@@ -113,7 +116,9 @@ class EvaluateService {
} }
// 获取测试详情 // 获取测试详情
async getTestResult(req: { record_id: number }): Promise<ApiResponse<TestResultData>> { async getTestResult(req: {
record_id: number;
}): Promise<ApiResponse<TestResultData>> {
return httpService.post("/ntrp/detail", req, { showLoading: true }); return httpService.post("/ntrp/detail", req, { showLoading: true });
} }
@@ -123,8 +128,14 @@ class EvaluateService {
} }
// 更新NTRP等级 // 更新NTRP等级
async updateNtrp(req: { record_id: number, ntrp_level: string, update_type: string }): Promise<ApiResponse<any>> { async updateNtrp(req: {
return httpService.post("/ntrp/update_user_level", req, { showLoading: true }); record_id: number;
ntrp_level: string;
update_type: string;
}): Promise<ApiResponse<any>> {
return httpService.post("/ntrp/update_user_level", req, {
showLoading: true,
});
} }
} }

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -23,7 +23,6 @@ const EditProfilePage: React.FC = () => {
// 表单状态基于store中的用户信息初始化 // 表单状态基于store中的用户信息初始化
const getInitialFormData = () => { const getInitialFormData = () => {
const info = user_info as UserInfoType; const info = user_info as UserInfoType;
debugger;
return { return {
nickname: info?.nickname ?? "", nickname: info?.nickname ?? "",
personal_profile: info?.personal_profile ?? "", personal_profile: info?.personal_profile ?? "",

View File

@@ -5,17 +5,13 @@
position: relative; position: relative;
overflow-y: auto; overflow-y: auto;
box-sizing: border-box; box-sizing: border-box;
background: radial-gradient(circle at 50% 0, background: radial-gradient(
/* 光晕圆心在顶部中间 */ circle at 50% 0,
rgba(191, 255, 239, 0.9) 0px, /* 光晕圆心在顶部中间 */ rgba(191, 255, 239, 0.9) 0px,
/* 中间更深的浅蓝 */ /* 中间更深的浅蓝 */ rgba(191, 255, 239, 0.5) 200px,
rgba(191, 255, 239, 0.5) 200px, /* 100px 处开始淡化 */ #fafafa 300px,
/* 100px 处开始淡化 */ /* 到 200px 变成白色 */ #fafafa 100% /* 200px 以下全白 */
#fafafa 300px, );
/* 到 200px 变成白色 */
#fafafa 100%
/* 200px 以下全白 */
);
} }
// 主要内容区域 // 主要内容区域
@@ -23,7 +19,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
color: rgba(0, 0, 0, 0.40); color: rgba(0, 0, 0, 0.4);
text-align: center; text-align: center;
font-family: "PingFang SC"; font-family: "PingFang SC";
font-size: 14px; font-size: 14px;
@@ -40,6 +36,7 @@
} }
.qrcode { .qrcode {
width: 240px;
margin: 32px 0 -20px; margin: 32px 0 -20px;
} }
@@ -47,4 +44,4 @@
font-weight: 400; font-weight: 400;
margin-bottom: 78px; margin-bottom: 78px;
} }
} }

View File

@@ -2,92 +2,27 @@ import React, { useState, useEffect } from "react";
import { View, Text, Image } from "@tarojs/components"; import { View, Text, Image } from "@tarojs/components";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import "./index.scss"; import "./index.scss";
import { UserService, UserInfoType } from "@/services/userService";
import * as LoginService from "@/services/loginService";
import { useGlobalState } from "@/store/global"; import { useGlobalState } from "@/store/global";
import { GeneralNavbar } from "@/components"; import { GeneralNavbar } from "@/components";
import httpService from "@/services/httpService";
const OtherUserPage: React.FC = () => { const JoinGroupPage: React.FC = () => {
// 获取页面参数
const instance = Taro.getCurrentInstance();
const user_id = instance.router?.params?.userid;
// 获取导航栏高度信息 // 获取导航栏高度信息
const { statusNavbarHeightInfo } = useGlobalState() || {}; const { statusNavbarHeightInfo } = useGlobalState() || {};
const { totalHeight = 98 } = statusNavbarHeightInfo || {}; const { totalHeight = 98 } = statusNavbarHeightInfo || {};
// 模拟用户数据 const [url, setUrl] = useState("");
const [user_info, setUserInfo] = useState<Partial<UserInfoType>>({
id: parseInt(user_id || "1") || 1,
gender: "",
nickname: "网球爱好者",
avatar_url: require("@/static/userInfo/default_avatar.svg"),
join_date: "2024年3月加入",
stats: {
following_count: 0,
followers_count: 0,
hosted_games_count: 0,
participated_games_count: 0,
},
tags: ["北京朝阳", "金融从业者", "NTRP 3.5"],
bio: "热爱网球的金融从业者,周末喜欢约球\n技术还在提升中欢迎一起切磋\n平时在朝阳公园附近活动",
city: "北京",
district: "朝阳",
occupation: "金融从业者",
ntrp_level: "NTRP 3.5",
is_following: false,
ongoing_games: [],
personal_profile: "",
});
// 页面加载时获取用户信息
useEffect(() => { useEffect(() => {
const load_user_data = async () => { const getQrCode = async () => {
if (user_id) { const res = await httpService.post("/parameter/many_key", {
try { keys: "QRCode",
// const user_data = await UserService.get_user_info(user_id); });
const res = await LoginService.getUserInfoById(user_id); setUrl(res.data.QRCode);
const { data: userData } = res;
// setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")});
setUserInfo({
id: parseInt(user_id || "") || 0,
nickname: userData.nickname || "",
avatar_url: userData.avatar_url || "",
join_date: userData.subscribe_time
? `${new Date(userData.subscribe_time).getFullYear()}${new Date(userData.subscribe_time).getMonth() + 1
}月加入`
: "",
stats: {
following_count: userData.stats?.following_count || 0,
followers_count: userData.stats?.followers_count || 0,
hosted_games_count: userData.stats?.hosted_games_count || 0,
participated_games_count:
userData.stats?.participated_games_count || 0,
},
personal_profile: userData.personal_profile || "",
province: userData.province || "",
city: userData.city || "",
district: userData.district || "",
occupation: userData.occupation || "",
ntrp_level: "",
phone: userData.phone || "",
gender: userData.gender || "",
birthday: userData.birthday || "",
});
setIsFollowing(userData.is_following || false);
} catch (error) {
console.error("加载用户数据失败:", error);
Taro.showToast({
title: "加载失败",
icon: "none",
});
}
}
}; };
getQrCode();
load_user_data(); // drawImageToCanvas();
}, [user_id]); }, []);
return ( return (
<View className="page_container"> <View className="page_container">
@@ -104,8 +39,13 @@ const OtherUserPage: React.FC = () => {
<View className="main_content" style={{ paddingTop: `${totalHeight}px` }}> <View className="main_content" style={{ paddingTop: `${totalHeight}px` }}>
<Text className="title-text"></Text> <Text className="title-text"></Text>
<Text></Text> <Text></Text>
<Image className="qrcode" mode="scaleToFill" src={require("@/static/userInfo/group-qrcode.svg")} showMenuByLongpress></Image> <Image
<Text className="hint-text">👆</Text> className="qrcode"
mode="scaleToFill"
src={url}
showMenuByLongpress
></Image>
<Text className="hint-text">👆使</Text>
<Text></Text> <Text></Text>
<Text></Text> <Text></Text>
<Text></Text> <Text></Text>
@@ -115,4 +55,4 @@ const OtherUserPage: React.FC = () => {
); );
}; };
export default OtherUserPage; export default JoinGroupPage;