修改 ntrp 个人页展示逻辑
This commit is contained in:
@@ -9,11 +9,14 @@ import ListContainer from "@/container/listContainer";
|
||||
import { TennisMatch } from "@/../types/list/types";
|
||||
import { withAuth, NTRPTestEntryCard } from "@/components";
|
||||
import { EvaluateScene } from "@/store/evaluateStore";
|
||||
import { useUserInfo } from "@/store/userStore";
|
||||
import { useUserInfo, useUserActions } from "@/store/userStore";
|
||||
import { usePickerOption } from "@/store/pickerOptionsStore";
|
||||
import evaluateService from "@/services/evaluateService";
|
||||
import { waitForAuthInit } from "@/utils/authInit";
|
||||
|
||||
const MyselfPage: React.FC = () => {
|
||||
const pickerOption = usePickerOption();
|
||||
|
||||
// 获取页面参数
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const user_id = instance.router?.params?.userid || "";
|
||||
@@ -33,6 +36,11 @@ const MyselfPage: React.FC = () => {
|
||||
// 关注状态
|
||||
const [is_following, setIsFollowing] = useState(false);
|
||||
|
||||
// 最近一个月是否有测试记录
|
||||
const [has_test_in_last_month, setHasTestInLastMonth] = useState(false);
|
||||
|
||||
const { fetchUserInfo } = useUserActions();
|
||||
|
||||
// 当前激活的标签页
|
||||
const [active_tab, setActiveTab] = useState<"hosted" | "participated">(
|
||||
"hosted"
|
||||
@@ -70,6 +78,28 @@ const MyselfPage: React.FC = () => {
|
||||
pickerOption.getProfessions();
|
||||
}, []);
|
||||
|
||||
// 获取测试结果,判断最近一个月是否有测试记录
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
if (!is_current_user) return; // 只对当前用户获取测试记录
|
||||
// 先等待静默登录完成
|
||||
await waitForAuthInit();
|
||||
// 然后再获取用户信息
|
||||
if (!user_info.id) {
|
||||
await fetchUserInfo();
|
||||
}
|
||||
|
||||
|
||||
// 获取测试结果
|
||||
const res = await evaluateService.getLastResult();
|
||||
if (res.code === 0) {
|
||||
console.log( "getLastResult", res.data);
|
||||
setHasTestInLastMonth(res.data.has_test_in_last_month);
|
||||
}
|
||||
};
|
||||
init();
|
||||
}, [is_current_user, user_info.id]);
|
||||
|
||||
// 页面加载时获取数据
|
||||
// useEffect(() => {
|
||||
// load_user_data();
|
||||
@@ -215,9 +245,11 @@ const MyselfPage: React.FC = () => {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="test-entry-card-box">
|
||||
<NTRPTestEntryCard type={EvaluateScene.user} />
|
||||
</View>
|
||||
{has_test_in_last_month && is_current_user && (
|
||||
<View className="test-entry-card-box">
|
||||
<NTRPTestEntryCard type={EvaluateScene.user} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 球局类型标签页 */}
|
||||
<View className="game_tabs_section">
|
||||
|
||||
Reference in New Issue
Block a user