fix: 修复退出活动弹窗文案展示

This commit is contained in:
2026-02-26 20:34:13 +08:00
parent 2656c59475
commit 0a0203e36d
2 changed files with 20 additions and 19 deletions

View File

@@ -13,7 +13,7 @@ import orderService from "@/services/orderService";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import closeIcon from "@/static/order/orderListClose.svg"; import closeIcon from "@/static/order/orderListClose.svg";
function genRefundNotice(refund_policy) { function genRefundNotice(refund_policy, order_amount) {
if (refund_policy.length === 0) { if (refund_policy.length === 0) {
return {}; return {};
} }
@@ -23,8 +23,7 @@ function genRefundNotice(refund_policy) {
if (matchPolicyIndex === -1) { if (matchPolicyIndex === -1) {
matchPolicyIndex = refund_policy.length - 1; matchPolicyIndex = refund_policy.length - 1;
} }
const { deadline_formatted, price, refund_rate } = const { time_range, price, refund_rate } = refund_policy[matchPolicyIndex];
refund_policy[matchPolicyIndex];
if (refund_rate === 1) { if (refund_rate === 1) {
return { return {
refundPrice: price, refundPrice: price,
@@ -36,17 +35,15 @@ function genRefundNotice(refund_policy) {
notice: `当前退出不可退款,后续流程未明确,@麻真瑜`, notice: `当前退出不可退款,后续流程未明确,@麻真瑜`,
}; };
} }
const refundPrice = Number(Math.ceil(price * refund_rate * 100) / 100); // 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 { return {
refundPrice, refundPrice: price,
notice: `活动开始已不足${leftHours}h,当前退出需扣除${ notice: `活动开始${time_range},当前退出需扣除${Math.ceil((order_amount - price) * 100) / 100}`,
Math.floor((price - refundPrice) * 100) / 100
}`,
}; };
} }
function renderCancelContent(refund_policy = []) { function renderCancelContent(refund_policy = [], amount) {
const current = dayjs(); const current = dayjs();
const policyList = [ const policyList = [
{ {
@@ -65,7 +62,7 @@ function renderCancelContent(refund_policy = []) {
}), }),
]; ];
const targetIndex = policyList.findIndex((item) => item.beforeCurrent); const targetIndex = policyList.findIndex((item) => item.beforeCurrent);
const { notice } = genRefundNotice(refund_policy); const { notice } = genRefundNotice(refund_policy, amount);
return ( return (
<View className={styles.refundPolicy}> <View className={styles.refundPolicy}>
{/* <View className={styles.moduleTitle}> {/* <View className={styles.moduleTitle}>
@@ -80,7 +77,7 @@ function renderCancelContent(refund_policy = []) {
className={classnames( className={classnames(
styles.policyItem, styles.policyItem,
targetIndex > index && index !== 0 ? styles.pastItem : "", targetIndex > index && index !== 0 ? styles.pastItem : "",
targetIndex === index ? styles.currentItem : "" targetIndex === index ? styles.currentItem : "",
)} )}
> >
<View className={styles.time}> <View className={styles.time}>
@@ -169,7 +166,7 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
onClick={onClose} onClick={onClose}
/> />
</View> </View>
{renderCancelContent(refundPolicy)} {renderCancelContent(refundPolicy, orderData.amount)}
<Button className={styles.action} onClick={handleConfirmQuit}> <Button className={styles.action} onClick={handleConfirmQuit}>
退 退
</Button> </Button>

View File

@@ -10,6 +10,7 @@ import orderService, {
GameOrderRes, GameOrderRes,
OrderStatus, OrderStatus,
refundTextMap, refundTextMap,
RefundStatus,
} from "@/services/orderService"; } from "@/services/orderService";
import { debounce } from "@tarojs/runtime"; import { debounce } from "@tarojs/runtime";
import { import {
@@ -76,7 +77,7 @@ function genGameNotice(order_status, start_time) {
function GameInfo(props) { function GameInfo(props) {
const { detail, currentLocation, orderDetail, init } = props; const { detail, currentLocation, orderDetail, init } = props;
const { order_status, refund_status, amount } = orderDetail; const { order_status, refund_status, amount, refund_amount } = orderDetail;
const { const {
latitude, latitude,
longitude, longitude,
@@ -111,7 +112,7 @@ function GameInfo(props) {
const startTime = dayjs(start_time); const startTime = dayjs(start_time);
const endTime = dayjs(end_time); const endTime = dayjs(end_time);
const game_length = Number( const game_length = Number(
(endTime.diff(startTime, "minutes") / 60).toFixed() (endTime.diff(startTime, "minutes") / 60).toFixed(),
); );
const startMonth = startTime.format("M"); const startMonth = startTime.format("M");
@@ -244,7 +245,10 @@ function GameInfo(props) {
<View className={styles.gameInfoContainer}> <View className={styles.gameInfoContainer}>
{["refund", "progress", "expired"].includes(orderStatus) && ( {["refund", "progress", "expired"].includes(orderStatus) && (
<View className={styles.paidInfo}> <View className={styles.paidInfo}>
{refundTextMap.get(refund_status)} ¥ {amount} {refundTextMap.get(refund_status)} ¥{" "}
{[RefundStatus.PENDING, RefundStatus.SUCCESS].includes(refund_status)
? refund_amount
: amount}
</View> </View>
)} )}
{["progress", "expired"].includes(orderStatus) && {["progress", "expired"].includes(orderStatus) &&
@@ -344,7 +348,7 @@ function GameInfo(props) {
handlePayNow: () => {}, handlePayNow: () => {},
handleViewGame, handleViewGame,
}, },
"detail" "detail",
)?.map((obj) => ( )?.map((obj) => (
<View className={classnames(styles.button, styles[obj.className])}> <View className={classnames(styles.button, styles[obj.className])}>
<Text className={styles.buttonText}>{obj.text}</Text> <Text className={styles.buttonText}>{obj.text}</Text>
@@ -504,7 +508,7 @@ function RefundPolicy(props) {
const theTimeObj = dayjs( const theTimeObj = dayjs(
isLast isLast
? refund_policy.at(-2).deadline_formatted ? refund_policy.at(-2).deadline_formatted
: item.deadline_formatted : item.deadline_formatted,
); );
const year = theTimeObj.format("YYYY"); const year = theTimeObj.format("YYYY");
const month = theTimeObj.format("M"); const month = theTimeObj.format("M");
@@ -531,7 +535,7 @@ function RefundPolicy(props) {
className={classnames( className={classnames(
styles.policyItem, styles.policyItem,
targetIndex > index && index !== 0 ? styles.pastItem : "", targetIndex > index && index !== 0 ? styles.pastItem : "",
targetIndex === index ? styles.currentItem : "" targetIndex === index ? styles.currentItem : "",
)} )}
> >
<View className={styles.time}> <View className={styles.time}>