Merge branch 'feat/liujie'
This commit is contained in:
@@ -48,7 +48,7 @@
|
|||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
.common-popup__title {
|
.common-popup__title {
|
||||||
font-family: 'PingFang SC';
|
font-family: "PingFang SC";
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
line-height: 1.27em;
|
line-height: 1.27em;
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background: #FFFFFF;
|
background: #ffffff;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.06);
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding-bottom: env(safe-area-inset-bottom);
|
padding-bottom: max(10px, env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
.common-popup__btn {
|
.common-popup__btn {
|
||||||
@@ -134,4 +134,4 @@
|
|||||||
border-radius: 12px !important;
|
border-radius: 12px !important;
|
||||||
padding: 4px 10px;
|
padding: 4px 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,12 @@
|
|||||||
import Taro, { useReady } from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { View, Canvas, Button } from "@tarojs/components";
|
import { View, Canvas } from "@tarojs/components";
|
||||||
import { useEffect, useRef, forwardRef, useImperativeHandle } from "react";
|
import { useEffect, forwardRef, useImperativeHandle } from "react";
|
||||||
|
|
||||||
const RadarChart: React.FC = forwardRef((props, ref) => {
|
const RadarChart: React.FC = forwardRef((props, ref) => {
|
||||||
const { data } = props;
|
const { data } = props;
|
||||||
|
|
||||||
const renderFnRef = useRef();
|
|
||||||
// const labels = [
|
|
||||||
// "正手球质",
|
|
||||||
// "正手控制",
|
|
||||||
// "反手球质",
|
|
||||||
// "反手控制",
|
|
||||||
// "底线相持",
|
|
||||||
// "场地覆盖",
|
|
||||||
// "发球接发",
|
|
||||||
// "接随机球",
|
|
||||||
// "战术设计",
|
|
||||||
// ];
|
|
||||||
// const values = [50, 75, 60, 20, 40, 70, 65, 35, 75];
|
|
||||||
const maxValue = 100;
|
const maxValue = 100;
|
||||||
const levels = 4;
|
const levels = 5;
|
||||||
const radius = 100;
|
const radius = 100;
|
||||||
const center = { x: 160, y: 160 };
|
const center = { x: 160, y: 160 };
|
||||||
|
|
||||||
@@ -35,14 +22,10 @@ const RadarChart: React.FC = forwardRef((props, ref) => {
|
|||||||
},
|
},
|
||||||
{ texts: [], vals: [] }
|
{ texts: [], vals: [] }
|
||||||
);
|
);
|
||||||
renderFnRef.current && renderFnRef.current(texts, vals);
|
renderCanvas(texts, vals);
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
useReady(() => {
|
|
||||||
renderFnRef.current = renderCanvas;
|
|
||||||
});
|
|
||||||
|
|
||||||
function renderCanvas(labels, values) {
|
function renderCanvas(labels, values) {
|
||||||
const query = Taro.createSelectorQuery();
|
const query = Taro.createSelectorQuery();
|
||||||
query
|
query
|
||||||
@@ -57,12 +40,15 @@ const RadarChart: React.FC = forwardRef((props, ref) => {
|
|||||||
ctx.scale(dpr, dpr);
|
ctx.scale(dpr, dpr);
|
||||||
|
|
||||||
// === 绘制圆形网格 ===
|
// === 绘制圆形网格 ===
|
||||||
for (let i = 1; i <= levels; i++) {
|
for (let i = levels; i >= 1; i--) {
|
||||||
const r = (radius / levels) * i;
|
const r = (radius / levels) * i;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(center.x, center.y, r, 0, Math.PI * 2);
|
ctx.arc(center.x, center.y, r, 0, Math.PI * 2);
|
||||||
if (i % 2 === 0) {
|
if (i % 2 === 1) {
|
||||||
ctx.fillStyle = "rgba(0, 150, 200, 0.1)";
|
ctx.fillStyle = "#fff";
|
||||||
|
ctx.fill();
|
||||||
|
} else {
|
||||||
|
ctx.fillStyle = "#CAFCF0";
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
ctx.strokeStyle = "#bbb";
|
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 (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<Canvas
|
<Canvas
|
||||||
@@ -163,7 +136,6 @@ const RadarChart: React.FC = forwardRef((props, ref) => {
|
|||||||
id="radarCanvas"
|
id="radarCanvas"
|
||||||
style={{ width: "320px", height: "320px", background: "transparent" }}
|
style={{ width: "320px", height: "320px", background: "transparent" }}
|
||||||
/>
|
/>
|
||||||
{/* <Button onClick={saveImage}>保存为图片</Button> */}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -459,6 +459,12 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: 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 {
|
&.disabled {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import evaluateService, {
|
|||||||
} from "@/services/evaluateService";
|
} from "@/services/evaluateService";
|
||||||
import { useUserInfo, useUserActions } from "@/store/userStore";
|
import { useUserInfo, useUserActions } from "@/store/userStore";
|
||||||
import { useEvaluate, EvaluateScene } from "@/store/evaluateStore";
|
import { useEvaluate, EvaluateScene } from "@/store/evaluateStore";
|
||||||
|
import { useGlobalState } from "@/store/global";
|
||||||
import { delay, getCurrentFullPath } from "@/utils";
|
import { delay, getCurrentFullPath } from "@/utils";
|
||||||
import CloseIcon from "@/static/ntrp/ntrp_close_icon.svg";
|
import CloseIcon from "@/static/ntrp/ntrp_close_icon.svg";
|
||||||
import DocCopy from "@/static/ntrp/ntrp_doc_copy.svg";
|
import DocCopy from "@/static/ntrp/ntrp_doc_copy.svg";
|
||||||
@@ -76,17 +77,38 @@ function adjustRadarLabels(
|
|||||||
return result as [string, number][];
|
return result as [string, number][];
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEmptyArrowFunction(fn) {
|
function isOnCancelEmpty(onCancelFunc) {
|
||||||
return (
|
if (typeof onCancelFunc !== "function") {
|
||||||
typeof fn === "function" &&
|
console.log("onCancel 不是函数");
|
||||||
!fn.hasOwnProperty("prototype") && // 排除普通函数
|
return false;
|
||||||
fn.toString().replace(/\s+/g, "") === "()=>{}"
|
}
|
||||||
);
|
|
||||||
|
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) {
|
function CommonGuideBar(props) {
|
||||||
const { title, confirm } = props;
|
const { title, confirm } = props;
|
||||||
const { onCancel } = useEvaluate();
|
const { onCancel } = useEvaluate();
|
||||||
|
const { statusNavbarHeightInfo } = useGlobalState();
|
||||||
|
const { statusBarHeight, navBarHeight } = statusNavbarHeightInfo;
|
||||||
// const userInfo = useUserInfo()
|
// const userInfo = useUserInfo()
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
@@ -94,7 +116,8 @@ function CommonGuideBar(props) {
|
|||||||
if (confirm) {
|
if (confirm) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (isEmptyArrowFunction(onCancel)) {
|
console.log(onCancel, isOnCancelEmpty(onCancel));
|
||||||
|
if (isOnCancelEmpty(onCancel)) {
|
||||||
Taro.redirectTo({ url: "/game_pages/list/index" });
|
Taro.redirectTo({ url: "/game_pages/list/index" });
|
||||||
}
|
}
|
||||||
onCancel();
|
onCancel();
|
||||||
@@ -104,7 +127,13 @@ function CommonGuideBar(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.header}>
|
<View
|
||||||
|
className={styles.header}
|
||||||
|
style={{
|
||||||
|
height: navBarHeight + "px",
|
||||||
|
paddingTop: statusBarHeight + "px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<View className={styles.closeIcon} onClick={handleClose}>
|
<View className={styles.closeIcon} onClick={handleClose}>
|
||||||
<Image className={styles.closeImg} src={CloseIcon} />
|
<Image className={styles.closeImg} src={CloseIcon} />
|
||||||
</View>
|
</View>
|
||||||
@@ -335,7 +364,6 @@ function Test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handIndexChange(direction) {
|
function handIndexChange(direction) {
|
||||||
console.log(disabled, direction);
|
|
||||||
if (disabled && direction > 0) {
|
if (disabled && direction > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -421,12 +449,13 @@ function Result() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getResultById();
|
getResultById();
|
||||||
fetchUserInfo();
|
fetchUserInfo();
|
||||||
}, []);
|
}, [id]);
|
||||||
|
|
||||||
async function getResultById() {
|
async function getResultById() {
|
||||||
const res = await evaluateService.getTestResult({ record_id: Number(id) });
|
const res = await evaluateService.getTestResult({ record_id: Number(id) });
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
setResult(res.data);
|
setResult(res.data);
|
||||||
|
// delay(1000);
|
||||||
setRadarData(
|
setRadarData(
|
||||||
adjustRadarLabels(
|
adjustRadarLabels(
|
||||||
Object.entries(res.data.radar_data.abilities).map(([key, value]) => [
|
Object.entries(res.data.radar_data.abilities).map(([key, value]) => [
|
||||||
|
|||||||
Reference in New Issue
Block a user