From f8672dec341986ef40bd8bb06d6143fe39eda01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sat, 7 Feb 2026 15:44:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(order):=20=E4=BF=AE=E5=A4=8D=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=80=E6=AC=BE=E6=97=B6=E9=97=B4=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E9=99=90=E5=88=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在开发环境中切换回本地API接口配置 - 修正首页商品卡片按钮链接到正确的购买页面 - 添加退款时间窗口检查函数来限制退款申请时机 - 更新订单详情页退款按钮显示条件,确保仅在有效期内显示 - 在用户订单列表中实现相同的退款时间窗口验证逻辑 - 确保退款功能仅在支付后60分钟内可访问 --- config/env.ts | 4 ++-- src/pages/index/index.tsx | 2 +- src/shop/orderDetail/index.tsx | 15 ++++++++++++++- src/user/order/components/OrderList.tsx | 13 ++++++++++++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/config/env.ts b/config/env.ts index f630969..78c1e6e 100644 --- a/config/env.ts +++ b/config/env.ts @@ -2,8 +2,8 @@ export const ENV_CONFIG = { // 开发环境 development: { - // API_BASE_URL: 'http://127.0.0.1:9200/api', - API_BASE_URL: 'https://mp-api.websoft.top/api', + API_BASE_URL: 'http://127.0.0.1:9200/api', + // API_BASE_URL: 'https://mp-api.websoft.top/api', APP_NAME: '开发环境', DEBUG: 'true', }, diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 1c6565e..ed9d2c4 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -313,7 +313,7 @@ function Home() { Taro.navigateTo({ url: '/user/ticket/index' })} + onClick={() => Taro.navigateTo({ url: 'shop/orderConfirm/index?goodsId=10074' })} > 买水票更优惠 diff --git a/src/shop/orderDetail/index.tsx b/src/shop/orderDetail/index.tsx index b0345d5..5fd937c 100644 --- a/src/shop/orderDetail/index.tsx +++ b/src/shop/orderDetail/index.tsx @@ -10,6 +10,17 @@ import dayjs from "dayjs"; import PaymentCountdown from "@/components/PaymentCountdown"; import './index.scss' +// 申请退款:支付成功后仅允许在指定时间窗内发起(前端展示层限制,后端仍应校验) +const isWithinRefundWindow = (payTime?: string, windowMinutes: number = 60): boolean => { + if (!payTime) return false; + const raw = String(payTime).trim(); + const t = /^\d+$/.test(raw) + ? dayjs(Number(raw) < 1e12 ? Number(raw) * 1000 : Number(raw)) // 兼容秒/毫秒时间戳 + : dayjs(raw); + if (!t.isValid()) return false; + return dayjs().diff(t, 'minute') <= windowMinutes; +}; + const OrderDetail = () => { const [order, setOrder] = useState(null); const [orderGoodsList, setOrderGoodsList] = useState([]); @@ -228,7 +239,9 @@ const OrderDetail = () => { {!order.payStatus && } {!order.payStatus && } - {order.orderStatus === 1 && } + {order.orderStatus === 1 && order.payStatus && isWithinRefundWindow(order.payTime, 60) && ( + + )} {canConfirmReceive && (