Merge branch 'feat/liujie'

This commit is contained in:
2025-11-20 23:16:24 +08:00
5 changed files with 121 additions and 65 deletions

View File

@@ -39,7 +39,7 @@ function NTRPTestEntryCard(props: {
// 获取测试结果 // 获取测试结果
const res = await evaluateService.getLastResult(); const res = await evaluateService.getLastResult();
if (res.code === 0) { if (res.code === 0) {
setTestFlag(res.data.has_ntrp_level); setTestFlag(res.data.has_test_record);
setHasTestInLastMonth(res.data.has_test_in_last_month); setHasTestInLastMonth(res.data.has_test_in_last_month);
} }
}; };
@@ -117,13 +117,21 @@ function NTRPTestEntryCard(props: {
}, },
}); });
} }
if (!testFlag && !userInfo.phone) {
Taro.navigateTo({
url: `/login_pages/index/index?redirect=${encodeURIComponent(
`/other_pages/ntrp-evaluate/index?stage=${StageType.INTRO}`
)}`,
});
return false;
}
Taro.navigateTo({ Taro.navigateTo({
url: `/other_pages/ntrp-evaluate/index?stage=${ url: `/other_pages/ntrp-evaluate/index?stage=${
testFlag ? StageType.INTRO : StageType.TEST testFlag ? StageType.INTRO : StageType.TEST
}`, }`,
}); });
}, },
[setCallback, testFlag, type, evaluateCallback] [setCallback, testFlag, type, evaluateCallback, userInfo.phone]
); );
// 如果最近一个月有测试记录,则不展示 // 如果最近一个月有测试记录,则不展示

View File

@@ -1,31 +1,48 @@
import React, { useState, useRef, forwardRef, useImperativeHandle } from 'react'; import React, {
import { View, Text, Button, Image } from '@tarojs/components' useState,
import Taro from '@tarojs/taro'; useRef,
import dayjs from 'dayjs' forwardRef,
import { CommonPopup } from '@/components'; useImperativeHandle,
import orderService from '@/services/orderService'; } from "react";
import styles from './index.module.scss' import { View, Text, Button, Image } from "@tarojs/components";
import closeIcon from '@/static/order/orderListClose.svg' import Taro from "@tarojs/taro";
import dayjs from "dayjs";
import { CommonPopup } from "@/components";
import orderService from "@/services/orderService";
import styles from "./index.module.scss";
import closeIcon from "@/static/order/orderListClose.svg";
function genRefundNotice (refund_policy) { function genRefundNotice(refund_policy) {
if (refund_policy.length === 0) { if (refund_policy.length === 0) {
return {} return {};
} }
const now = dayjs() const now = dayjs();
const deadlines = refund_policy.map(item => dayjs(item.deadline_formatted)) const deadlines = refund_policy.map((item) => dayjs(item.deadline_formatted));
let matchPolicyIndex = deadlines.findIndex(d => d.isAfter(now)) let matchPolicyIndex = deadlines.findIndex((d) => d.isAfter(now));
if (matchPolicyIndex === -1) { if (matchPolicyIndex === -1) {
matchPolicyIndex = refund_policy.length - 1 matchPolicyIndex = refund_policy.length - 1;
} }
const { deadline_formatted, price, refund_rate } = refund_policy[matchPolicyIndex] const { deadline_formatted, price, refund_rate } =
refund_policy[matchPolicyIndex];
if (refund_rate === 1) { if (refund_rate === 1) {
return { refundPrice: price, notice: `本次可全额退款, ¥${price} 将原路退回,请查收` } return {
refundPrice: price,
notice: `本次可全额退款, ¥${price} 将原路退回,请查收`,
};
} else if (refund_rate === 0) { } else if (refund_rate === 0) {
return { refundPrice: 0, notice: `当前退出不可退款,后续流程未明确,@麻真瑜` } return {
refundPrice: 0,
notice: `当前退出不可退款,后续流程未明确,@麻真瑜`,
};
} }
const refundPrice = price * refund_rate const refundPrice = Number(Math.ceil(price * refund_rate * 100) / 100);
const leftHours = dayjs(deadline_formatted).diff(dayjs(), 'hour') const leftHours = dayjs(deadline_formatted).diff(dayjs(), "hour");
return { refundPrice, notice: `距活动开始已不足${leftHours}h当前退出您需扣除${price - refundPrice}` } return {
refundPrice,
notice: `距活动开始已不足${leftHours}h当前退出您需扣除${
Math.floor((price - refundPrice) * 100) / 100
}`,
};
} }
function renderCancelContent(checkOrderInfo) { function renderCancelContent(checkOrderInfo) {
@@ -42,7 +59,7 @@ function renderCancelContent(checkOrderInfo) {
}; };
}), }),
]; ];
const { notice } = genRefundNotice(refund_policy) const { notice } = genRefundNotice(refund_policy);
return ( return (
<View className={styles.refundPolicy}> <View className={styles.refundPolicy}>
{/* <View className={styles.moduleTitle}> {/* <View className={styles.moduleTitle}>
@@ -63,37 +80,35 @@ function renderCancelContent(checkOrderInfo) {
} }
export type RefundRef = { export type RefundRef = {
show: (item: any, callback: (result: boolean) => void) => void show: (item: any, callback: (result: boolean) => void) => void;
} };
export default forwardRef<RefundRef>(function RefundPopup(_props, ref) { export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false);
const [checkOrderInfo, setCheckOrderInfo] = useState({}) const [checkOrderInfo, setCheckOrderInfo] = useState({});
const [orderData, setOrderData] = useState({}) const [orderData, setOrderData] = useState({});
const onDown = useRef<((result: boolean) => void) | null>(null) const onDown = useRef<((result: boolean) => void) | null>(null);
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
show: onShow, show: onShow,
})) }));
async function onShow (orderItem, onFinish: (result: boolean) => void) { async function onShow(orderItem, onFinish: (result: boolean) => void) {
const { const { game_info } = orderItem;
game_info, onDown.current = onFinish;
} = orderItem setOrderData(orderItem);
onDown.current = onFinish
setOrderData(orderItem)
const res = await orderService.getCheckOrderInfo(game_info.id); const res = await orderService.getCheckOrderInfo(game_info.id);
setCheckOrderInfo(res.data); setCheckOrderInfo(res.data);
setVisible(true) setVisible(true);
} }
function onClose () { function onClose() {
setVisible(false) setVisible(false);
onDown.current?.(false) onDown.current?.(false);
} }
async function handleConfirmQuit () { async function handleConfirmQuit() {
const { order_no, amount } = orderData const { order_no, amount } = orderData;
try { try {
const refundRes = await orderService.applicateRefund({ const refundRes = await orderService.applicateRefund({
order_no, order_no,
@@ -106,15 +121,15 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
Taro.showToast({ Taro.showToast({
title: "退出成功", title: "退出成功",
icon: "none", icon: "none",
}) });
onDown.current?.(true) onDown.current?.(true);
} catch (e) { } catch (e) {
Taro.showToast({ Taro.showToast({
title: e.message, title: e.message,
icon: "error", icon: "error",
}); });
} finally { } finally {
onClose() onClose();
} }
} }
return ( return (
@@ -129,11 +144,17 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
<View className={styles.container}> <View className={styles.container}>
<View className={styles.header}> <View className={styles.header}>
<Text className={styles.title}>退</Text> <Text className={styles.title}>退</Text>
<Image className={styles.closeIcon} src={closeIcon} onClick={onClose} /> <Image
className={styles.closeIcon}
src={closeIcon}
onClick={onClose}
/>
</View> </View>
{renderCancelContent(checkOrderInfo)} {renderCancelContent(checkOrderInfo)}
<Button className={styles.action} onClick={handleConfirmQuit}>退</Button> <Button className={styles.action} onClick={handleConfirmQuit}>
退
</Button>
</View> </View>
</CommonPopup> </CommonPopup>
) );
}) });

View File

@@ -65,12 +65,13 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 8px; gap: 8px;
height: 162px; height: 100%;
flex-wrap: nowrap; flex-wrap: nowrap;
.participants-list-item { .participants-list-item {
display: flex; display: flex;
width: 108px; width: 108px;
height: 100%;
padding: 16px 4px 10px 4px; padding: 16px 4px 10px 4px;
box-sizing: border-box; box-sizing: border-box;
flex-direction: column; flex-direction: column;

View File

@@ -295,7 +295,7 @@
} }
.actions { .actions {
margin: 74px 22px 0; margin: 52px 22px 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px; gap: 10px;

View File

@@ -150,7 +150,9 @@ function Intro() {
const { last_test_result = null } = ntrpData || {}; const { last_test_result = null } = ntrpData || {};
const { ntrp_level, create_time, id } = last_test_result || {}; const { ntrp_level, create_time, id } = last_test_result || {};
const lastTestTime = create_time ? dayjs(create_time).format("YYYY年M月D日") : ""; const lastTestTime = create_time
? dayjs(create_time).format("YYYY年M月D日")
: "";
useEffect(() => { useEffect(() => {
const init = async () => { const init = async () => {
@@ -192,7 +194,8 @@ function Intro() {
}); });
} }
Taro.redirectTo({ Taro.redirectTo({
url: `/other_pages/ntrp-evaluate/index?stage=${type}${type === StageType.RESULT ? `&id=${id}` : "" url: `/other_pages/ntrp-evaluate/index?stage=${type}${
type === StageType.RESULT ? `&id=${id}` : ""
}`, }`,
}); });
} }
@@ -200,7 +203,7 @@ function Intro() {
return ( return (
<View className={styles.introContainer}> <View className={styles.introContainer}>
<CommonGuideBar /> <CommonGuideBar />
{ntrpData?.has_ntrp_level ? ( {ntrpData?.has_test_record ? (
<View className={styles.result}> <View className={styles.result}>
<View className={styles.avatarWrap}> <View className={styles.avatarWrap}>
<View className={styles.avatar}> <View className={styles.avatar}>
@@ -234,7 +237,9 @@ function Intro() {
</View> </View>
<View className={styles.levelWrap}> <View className={styles.levelWrap}>
<Text>NTRP</Text> <Text>NTRP</Text>
<Text className={styles.level}>{formatNtrpDisplay(ntrp_level || "")}</Text> <Text className={styles.level}>
{formatNtrpDisplay(ntrp_level || "")}
</Text>
</View> </View>
<View className={styles.slogan}> <View className={styles.slogan}>
<Text>线+</Text> <Text>线+</Text>
@@ -495,6 +500,10 @@ function Result() {
} }
function handleReTest() { function handleReTest() {
if (!userInfo.phone) {
handleAuth();
return false;
}
Taro.redirectTo({ Taro.redirectTo({
url: `/other_pages/ntrp-evaluate/index?stage=${StageType.TEST}`, url: `/other_pages/ntrp-evaluate/index?stage=${StageType.TEST}`,
}); });
@@ -507,6 +516,15 @@ function Result() {
} }
async function handleGoon() { async function handleGoon() {
if (!userInfo?.phone) {
Taro.redirectTo({
url: `/login_pages/index/index?redirect=${encodeURIComponent(
`/main_pages/index`
)}`,
});
clear();
return;
}
if (type) { if (type) {
next({ flag: false, score: result?.ntrp_level as string }); next({ flag: false, score: result?.ntrp_level as string });
await delay(1500); await delay(1500);
@@ -566,7 +584,8 @@ function Result() {
async function handleSaveImage() { async function handleSaveImage() {
console.log(userInfo); console.log(userInfo);
if (!userInfo?.id) { if (!userInfo?.phone) {
handleAuth();
return; return;
} }
Taro.getSetting().then(async (res) => { Taro.getSetting().then(async (res) => {
@@ -615,16 +634,19 @@ function Result() {
}); });
function handleAuth() { function handleAuth() {
if (userInfo?.id) { if (userInfo?.phone) {
return true; return true;
} }
const currentPage = getCurrentFullPath(); const currentPage = getCurrentFullPath();
Taro.redirectTo({ Taro.redirectTo({
url: `/login_pages/index/index${currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : "" url: `/login_pages/index/index${
currentPage ? `?redirect=${encodeURIComponent(currentPage)}` : ""
}`, }`,
}); });
} }
function handleGo() {}
return ( return (
<View className={styles.resultContainer}> <View className={styles.resultContainer}>
<CommonGuideBar /> <CommonGuideBar />
@@ -652,7 +674,9 @@ function Result() {
</View> </View>
<View className={styles.levelWrap}> <View className={styles.levelWrap}>
<Text>NTRP</Text> <Text>NTRP</Text>
<Text className={styles.level}>{formatNtrpDisplay(result?.ntrp_level)}</Text> <Text className={styles.level}>
{formatNtrpDisplay(result?.ntrp_level)}
</Text>
</View> </View>
<View className={styles.slogan}> <View className={styles.slogan}>
<Text>线+</Text> <Text>线+</Text>
@@ -666,9 +690,11 @@ function Result() {
<Text></Text> <Text></Text>
</View> </View>
</View> </View>
{userInfo?.id ? ( {userInfo?.phone ? (
<View className={styles.updateTip}> <View className={styles.updateTip}>
<Text> NTRP {formatNtrpDisplay(result?.ntrp_level || "")} </Text> <Text>
NTRP {formatNtrpDisplay(result?.ntrp_level || "")}{" "}
</Text>
<Text className={styles.grayTip}>()</Text> <Text className={styles.grayTip}>()</Text>
</View> </View>
) : ( ) : (
@@ -679,14 +705,14 @@ function Result() {
<View className={styles.actions}> <View className={styles.actions}>
<View className={styles.viewGame} onClick={handleGoon}> <View className={styles.viewGame} onClick={handleGoon}>
<Button className={styles.viewGameBtn}> <Button className={styles.viewGameBtn}>
{sourceTypeToTextMap.get(type) || "去看看球局"} {sourceTypeToTextMap.get(type) || "去看看适合你的球局"}
</Button> </Button>
</View> </View>
<View className={styles.otherActions}> <View className={styles.otherActions}>
<View className={styles.share}> <View className={styles.share}>
<Button <Button
className={styles.shareBtn} className={styles.shareBtn}
openType={userInfo?.id ? "share" : undefined} openType={userInfo?.phone ? "share" : undefined}
onClick={handleAuth} onClick={handleAuth}
></Button> ></Button>
<View className={styles.shareBtnCover}> <View className={styles.shareBtnCover}>