From 46a59ba28226494544d2a2588d80ae6f4bd132f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=9D=B0?= Date: Wed, 10 Dec 2025 20:08:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20refund=20policy=20=E4=BB=8E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96=E3=80=81=E6=A2=B3?= =?UTF-8?q?=E7=90=86=E8=AE=A2=E5=8D=95=E6=93=8D=E4=BD=9C=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/refundPopup/index.tsx | 13 +++--- src/order_pages/orderDetail/index.tsx | 59 +++++++++++++-------------- src/utils/orderActions.ts | 16 ++++++-- 3 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/components/refundPopup/index.tsx b/src/components/refundPopup/index.tsx index 616a376..cc83046 100644 --- a/src/components/refundPopup/index.tsx +++ b/src/components/refundPopup/index.tsx @@ -46,8 +46,7 @@ function genRefundNotice(refund_policy) { }; } -function renderCancelContent(checkOrderInfo) { - const { refund_policy = [] } = checkOrderInfo; +function renderCancelContent(refund_policy = []) { const current = dayjs(); const policyList = [ { @@ -65,7 +64,6 @@ function renderCancelContent(checkOrderInfo) { }; }), ]; - console.log("policyList", policyList); const targetIndex = policyList.findIndex((item) => item.beforeCurrent); const { notice } = genRefundNotice(refund_policy); return ( @@ -107,7 +105,7 @@ export type RefundRef = { export default forwardRef(function RefundPopup(_props, ref) { const [visible, setVisible] = useState(false); - const [checkOrderInfo, setCheckOrderInfo] = useState({}); + const [refundPolicy, setRefundPolicy] = useState([]); const [orderData, setOrderData] = useState({}); const onDown = useRef<((result: boolean) => void) | null>(null); @@ -116,11 +114,10 @@ export default forwardRef(function RefundPopup(_props, ref) { })); async function onShow(orderItem, onFinish: (result: boolean) => void) { - const { game_info } = orderItem; + const { refund_policy } = orderItem; onDown.current = onFinish; setOrderData(orderItem); - const res = await orderService.getCheckOrderInfo(game_info.id); - setCheckOrderInfo(res.data); + setRefundPolicy(refund_policy); setVisible(true); } @@ -172,7 +169,7 @@ export default forwardRef(function RefundPopup(_props, ref) { onClick={onClose} /> - {renderCancelContent(checkOrderInfo)} + {renderCancelContent(refundPolicy)} diff --git a/src/order_pages/orderDetail/index.tsx b/src/order_pages/orderDetail/index.tsx index 9948e56..5b89268 100644 --- a/src/order_pages/orderDetail/index.tsx +++ b/src/order_pages/orderDetail/index.tsx @@ -380,8 +380,13 @@ function OrderMsg(props) { wechat_contact, price, } = detail; - const { order_no } = orderDetail; - const { order_info: { registrant_phone } = {} } = checkOrderInfo; + const { order_no, registrant_phone: registrant_phone_from_order } = + orderDetail; + const { + order_info: { registrant_phone: registrant_phone_from_check_order } = {}, + } = checkOrderInfo || {}; + const registrant_phone = + registrant_phone_from_order || registrant_phone_from_check_order; const startTime = dayjs(start_time); const endTime = dayjs(end_time); const startDate = startTime.format("YYYY年M月D日"); @@ -402,13 +407,11 @@ function OrderMsg(props) { }, { title: "报名人电话", - // content: registrant_phone, content: registrant_phone ? ( { @@ -427,7 +430,6 @@ function OrderMsg(props) { }, { title: "组织人电话", - // content: wechat_contact, content: wechat_contact && isPhoneNumber(wechat_contact) ? ( { const [id, gameId] = [Number(stringId), Number(stringGameId)]; const [detail, setDetail] = useState({}); const [location, setLocation] = useState([0, 0]); - const [checkOrderInfo, setCheckOrderInfo] = useState({}); + const [checkOrderInfo, setCheckOrderInfo] = useState(); const [orderDetail, setOrderDetail] = useState({}); const { paying, setPaying } = useOrder(); @@ -584,11 +585,11 @@ const OrderCheck = () => { if (res.code === 0) { gameDetail = res.data; } + checkOrder(gameId); } - if (gameDetail.id) { - setDetail(gameDetail); - onInit(gameDetail.id); - } + setDetail(gameDetail); + const location = await getCurrentLocation(); + setLocation([location.latitude, location.longitude]); } async function checkOrder(gid) { @@ -596,12 +597,6 @@ const OrderCheck = () => { setCheckOrderInfo(orderRes.data); } - async function onInit(gid) { - checkOrder(gid); - const location = await getCurrentLocation(); - setLocation([location.latitude, location.longitude]); - } - async function getPaymentParams() { // 检查登录状态和手机号(创建订单前检查) if (!requireLoginWithPhone()) { @@ -706,23 +701,27 @@ const OrderCheck = () => { checkOrderInfo={checkOrderInfo} /> {/* Refund policy */} - + {/* Disclaimer */} {(!id || (order_status === OrderStatus.PENDING && cancel_type === CancelType.NONE)) && ( - - )} + + )} ); }; diff --git a/src/utils/orderActions.ts b/src/utils/orderActions.ts index eb6b3b6..045a8fc 100644 --- a/src/utils/orderActions.ts +++ b/src/utils/orderActions.ts @@ -6,18 +6,28 @@ export function getOrderStatus(orderData) { if (!order_no) { return 'none' } - const { start_time } = game_info + const { start_time } = game_info || {} + if (!start_time) { console.log('活动开始时间未找到, start_time: ', start_time); } const unPay = order_status === OrderStatus.PENDING && ([CancelType.NONE].includes(cancel_type)); const refund = [RefundStatus.SUCCESS].includes(refund_status); const refunding = [RefundStatus.PENDING].includes(refund_status); const expired = order_status === OrderStatus.FINISHED; - const frozen = dayjs().add(2, 'h').isAfter(dayjs(start_time)) + const frozen = dayjs().isAfter(dayjs(start_time)) const canceled = [CancelType.TIMEOUT, CancelType.USER].includes(cancel_type); - return unPay ? 'unpay' : refund ? 'refund' : canceled ? 'canceled' : expired ? 'expired' : refunding ? 'refunding' : frozen ? 'start' : 'progress' + // return unPay ? 'unpay' : refund ? 'refund' : canceled ? 'canceled' : expired ? 'expired' : refunding ? 'refunding' : is_substitute_order ? 'progress' : frozen ? 'start' : 'progress' + if (unPay) return 'unpay'; + if (refund) return 'refund'; + if (canceled) return 'canceled'; + if (expired) return 'expired'; + if (refunding) return 'refunding'; + if (frozen) return 'start'; + // if (is_substitute_order) return 'progress'; + return 'progress'; + } // scene: list、detail