From c823c1fa1871ca4d1d7785ca7860c39a0bc052a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Thu, 20 Nov 2025 22:32:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20ntrp=20=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E9=A1=B5=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/NTRPTestEntryCard/index.tsx | 7 ++++ src/user_pages/myself/index.tsx | 40 +++++++++++++++++++--- src/utils/helper.ts | 1 - 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/components/NTRPTestEntryCard/index.tsx b/src/components/NTRPTestEntryCard/index.tsx index 8bbfc10..7e2aa82 100644 --- a/src/components/NTRPTestEntryCard/index.tsx +++ b/src/components/NTRPTestEntryCard/index.tsx @@ -1,5 +1,6 @@ import React, { useState, useEffect, useCallback, memo } from "react"; import { View, Image, Text } from "@tarojs/components"; +import { requireLoginWithPhone } from "@/utils/helper"; import Taro from "@tarojs/taro"; import { useUserInfo, useUserActions } from "@/store/userStore"; // import { getCurrentFullPath } from "@/utils"; @@ -47,6 +48,12 @@ function NTRPTestEntryCard(props: { const handleTest = useCallback( function () { + // 没有绑定手机号,线条转登陆 + if (!requireLoginWithPhone()) { + return; + } + + switch (type) { case EvaluateScene.list: setCallback({ diff --git a/src/user_pages/myself/index.tsx b/src/user_pages/myself/index.tsx index 1726d30..04a2a98 100644 --- a/src/user_pages/myself/index.tsx +++ b/src/user_pages/myself/index.tsx @@ -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 = () => { - - - + {has_test_in_last_month && is_current_user && ( + + + + )} {/* 球局类型标签页 */} diff --git a/src/utils/helper.ts b/src/utils/helper.ts index 24d062e..d5eaf1d 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -58,7 +58,6 @@ export const requireLogin = (): boolean => { export const requireLoginWithPhone = (): boolean => { // 先检查登录状态 const isLoggedIn = check_login_status(); - if (!isLoggedIn) { navigateToLogin(); return false;