From 0107072bfc93c55a4d5d8392cc35aa4d8ee9baca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9D=B0?= Date: Mon, 20 Oct 2025 15:47:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dcommompopup=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=BA=95=E8=BE=B9=E8=B7=9D=E5=9C=A8=E5=AE=89=E5=8D=93?= =?UTF-8?q?=E4=B8=8A=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=81=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=A1=B5=E5=81=B6=E5=B0=94=E5=87=BA=E7=8E=B0=E4=B8=8D?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E9=9B=B7=E8=BE=BE=E5=9B=BE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommonPopup/index.module.scss | 8 +-- src/components/Radar/index.tsx | 50 ++++--------------- .../ntrp-evaluate/index.module.scss | 6 +++ src/other_pages/ntrp-evaluate/index.tsx | 49 ++++++++++++++---- 4 files changed, 60 insertions(+), 53 deletions(-) diff --git a/src/components/CommonPopup/index.module.scss b/src/components/CommonPopup/index.module.scss index 7784154..7caeab6 100644 --- a/src/components/CommonPopup/index.module.scss +++ b/src/components/CommonPopup/index.module.scss @@ -48,7 +48,7 @@ border-bottom: 1px solid rgba(0, 0, 0, 0.06); .common-popup__title { - font-family: 'PingFang SC'; + font-family: "PingFang SC"; font-weight: 600; font-size: 22px; line-height: 1.27em; @@ -62,7 +62,7 @@ display: flex; align-items: center; justify-content: center; - background: #FFFFFF; + background: #ffffff; border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 50%; cursor: pointer; @@ -100,7 +100,7 @@ display: flex; gap: 8px; background: #fff; - padding-bottom: env(safe-area-inset-bottom); + padding-bottom: max(10px, env(safe-area-inset-bottom)); } .common-popup__btn { @@ -134,4 +134,4 @@ border-radius: 12px !important; padding: 4px 10px; } -} \ No newline at end of file +} diff --git a/src/components/Radar/index.tsx b/src/components/Radar/index.tsx index a03702c..bd81a80 100644 --- a/src/components/Radar/index.tsx +++ b/src/components/Radar/index.tsx @@ -1,25 +1,12 @@ -import Taro, { useReady } from "@tarojs/taro"; -import { View, Canvas, Button } from "@tarojs/components"; -import { useEffect, useRef, forwardRef, useImperativeHandle } from "react"; +import Taro from "@tarojs/taro"; +import { View, Canvas } from "@tarojs/components"; +import { useEffect, forwardRef, useImperativeHandle } from "react"; const RadarChart: React.FC = forwardRef((props, ref) => { const { data } = props; - const renderFnRef = useRef(); - // const labels = [ - // "正手球质", - // "正手控制", - // "反手球质", - // "反手控制", - // "底线相持", - // "场地覆盖", - // "发球接发", - // "接随机球", - // "战术设计", - // ]; - // const values = [50, 75, 60, 20, 40, 70, 65, 35, 75]; const maxValue = 100; - const levels = 4; + const levels = 5; const radius = 100; const center = { x: 160, y: 160 }; @@ -35,14 +22,10 @@ const RadarChart: React.FC = forwardRef((props, ref) => { }, { texts: [], vals: [] } ); - renderFnRef.current && renderFnRef.current(texts, vals); + renderCanvas(texts, vals); } }, [data]); - useReady(() => { - renderFnRef.current = renderCanvas; - }); - function renderCanvas(labels, values) { const query = Taro.createSelectorQuery(); query @@ -57,12 +40,15 @@ const RadarChart: React.FC = forwardRef((props, ref) => { ctx.scale(dpr, dpr); // === 绘制圆形网格 === - for (let i = 1; i <= levels; i++) { + for (let i = levels; i >= 1; i--) { const r = (radius / levels) * i; ctx.beginPath(); ctx.arc(center.x, center.y, r, 0, Math.PI * 2); - if (i % 2 === 0) { - ctx.fillStyle = "rgba(0, 150, 200, 0.1)"; + if (i % 2 === 1) { + ctx.fillStyle = "#fff"; + ctx.fill(); + } else { + ctx.fillStyle = "#CAFCF0"; ctx.fill(); } ctx.strokeStyle = "#bbb"; @@ -143,19 +129,6 @@ const RadarChart: React.FC = forwardRef((props, ref) => { }), })); - // 保存为图片 - const saveImage = () => { - Taro.canvasToTempFilePath({ - canvasId: "radarCanvas", - success: (res) => { - Taro.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: () => Taro.showToast({ title: "保存成功" }), - }); - }, - }); - }; - return ( { id="radarCanvas" style={{ width: "320px", height: "320px", background: "transparent" }} /> - {/* */} ); }); diff --git a/src/other_pages/ntrp-evaluate/index.module.scss b/src/other_pages/ntrp-evaluate/index.module.scss index 815e830..a354819 100644 --- a/src/other_pages/ntrp-evaluate/index.module.scss +++ b/src/other_pages/ntrp-evaluate/index.module.scss @@ -459,6 +459,12 @@ display: flex; align-items: center; justify-content: center; + font-feature-settings: "liga" off, "clig" off; + font-family: "PingFang SC"; + font-size: 16px; + font-style: normal; + font-weight: 600; + line-height: normal; } &.disabled { diff --git a/src/other_pages/ntrp-evaluate/index.tsx b/src/other_pages/ntrp-evaluate/index.tsx index 4b8a238..65508ce 100644 --- a/src/other_pages/ntrp-evaluate/index.tsx +++ b/src/other_pages/ntrp-evaluate/index.tsx @@ -11,6 +11,7 @@ import evaluateService, { } from "@/services/evaluateService"; import { useUserInfo, useUserActions } from "@/store/userStore"; import { useEvaluate, EvaluateScene } from "@/store/evaluateStore"; +import { useGlobalState } from "@/store/global"; import { delay, getCurrentFullPath } from "@/utils"; import CloseIcon from "@/static/ntrp/ntrp_close_icon.svg"; import DocCopy from "@/static/ntrp/ntrp_doc_copy.svg"; @@ -76,17 +77,38 @@ function adjustRadarLabels( return result as [string, number][]; } -function isEmptyArrowFunction(fn) { - return ( - typeof fn === "function" && - !fn.hasOwnProperty("prototype") && // 排除普通函数 - fn.toString().replace(/\s+/g, "") === "()=>{}" - ); +function isOnCancelEmpty(onCancelFunc) { + if (typeof onCancelFunc !== "function") { + console.log("onCancel 不是函数"); + return false; + } + + try { + const funcString = onCancelFunc.toString().trim(); + + // 常见空函数模式 + const emptyFunctionPatterns = [ + "functiononCancel(){}", + "function onCancel() {}", + "onCancel(){}", + "()=>{}", + "functiononCancel(){ }", + "() => {}", + ]; + + const normalized = funcString.replace(/\s/g, ""); + return emptyFunctionPatterns.includes(normalized); + } catch (error) { + console.error("检查 onCancel 函数时出错:", error); + return false; + } } function CommonGuideBar(props) { const { title, confirm } = props; const { onCancel } = useEvaluate(); + const { statusNavbarHeightInfo } = useGlobalState(); + const { statusBarHeight, navBarHeight } = statusNavbarHeightInfo; // const userInfo = useUserInfo() function handleClose() { @@ -94,7 +116,8 @@ function CommonGuideBar(props) { if (confirm) { } try { - if (isEmptyArrowFunction(onCancel)) { + console.log(onCancel, isOnCancelEmpty(onCancel)); + if (isOnCancelEmpty(onCancel)) { Taro.redirectTo({ url: "/game_pages/list/index" }); } onCancel(); @@ -104,7 +127,13 @@ function CommonGuideBar(props) { } return ( - + @@ -335,7 +364,6 @@ function Test() { } function handIndexChange(direction) { - console.log(disabled, direction); if (disabled && direction > 0) { return; } @@ -421,12 +449,13 @@ function Result() { useEffect(() => { getResultById(); fetchUserInfo(); - }, []); + }, [id]); async function getResultById() { const res = await evaluateService.getTestResult({ record_id: Number(id) }); if (res.code === 0) { setResult(res.data); + // delay(1000); setRadarData( adjustRadarLabels( Object.entries(res.data.radar_data.abilities).map(([key, value]) => [