fix(order): 修正未付款已发货订单状态显示错误
- 订单列表卡片 OrderCard 中将已发货/已收货状态判断提前,覆盖未付款状态显示 - 订单详情页 detail.tsx 调整 getOrderDisplayStatus 和 getOrderPhase 函数,优先显示物流状态 - 确保未付款但已发货订单状态正确显示为“待收货” - 改动不影响正常付款和发货流程,仅修正异常状态显示问题
This commit is contained in:
@@ -104,3 +104,10 @@
|
||||
- 右上角按钮用 `absolute top-3 right-4 z-20` 定位,半透明白色圆形背景 + base64 SVG 图标
|
||||
- 小程序不支持 `<svg>` 标签,用 `Image` 组件 + `data:image/svg+xml;base64,...` data URI 渲染图标
|
||||
- 用户取消扫码(errMsg 含 'cancel')静默处理
|
||||
|
||||
## 修复未付款已发货订单状态显示错误
|
||||
- **问题**:订单列表卡片(OrderCard)和详情页(detail.tsx)状态判断时 `!payStatus`(待付款)优先于 `deliveryStatus` 判断,导致"未付款但已发货"(payStatus=false + deliveryStatus=20) 的订单显示"待付款"而非"待收货"
|
||||
- **修改文件**:
|
||||
- `src/components/common/OrderCard/index.tsx`:`getCardStatus` 把 `deliveryStatus===20/30` 判断提前到 `!payStatus` 之前
|
||||
- `src/pages/order/detail.tsx`:`getOrderDisplayStatus` 和 `getOrderPhase` 两个函数都做同样调整,物流状态优先于付款状态
|
||||
- **影响范围**:仅影响"未付款但已发货"的异常场景,正常流程不受影响
|
||||
|
||||
@@ -25,12 +25,14 @@ const getCardStatus = (order: ShopOrder): { text: string; color: string } => {
|
||||
// 终态:orderStatus=1 必须最先判断,盖过 deliveryStatus/payStatus
|
||||
if (orderStatus === 1) return { text: '已完成', color: '#0e932e' }
|
||||
|
||||
// 物流状态优先于付款状态(已发货/已收货的订单,即使未付款也显示物流状态)
|
||||
if (deliveryStatus === 20) return { text: '待收货', color: '#4b9cf5' }
|
||||
if (deliveryStatus === 30) return { text: '已收货', color: '#0e932e' }
|
||||
|
||||
// 货到付款(8):下单时后端已 setPayStatus(true),不会走到这里
|
||||
// 线下付款(9):保持 payStatus=false(待商家确认收款),应显示"待付款"与 Tab 一致
|
||||
if (!payStatus && !isCod) return { text: '待付款', color: '#ee0a24' }
|
||||
if (deliveryStatus === 10) return { text: '待发货', color: '#4b9cf5' }
|
||||
if (deliveryStatus === 20) return { text: '待收货', color: '#4b9cf5' }
|
||||
if (deliveryStatus === 30) return { text: '已收货', color: '#0e932e' }
|
||||
|
||||
return { text: '已付款', color: '#0e932e' }
|
||||
}
|
||||
|
||||
@@ -71,7 +71,12 @@ const getOrderDisplayStatus = (order: ShopOrder): { title: string; bgColor: stri
|
||||
return { bgColor: '#ee0a24', title: '退款被拒绝', subtitle: '退款申请已被拒绝' }
|
||||
}
|
||||
|
||||
// 正常订单流程
|
||||
// 物流状态优先于付款状态(已发货/已收货的订单,即使未付款也显示物流状态)
|
||||
if (deliveryStatus === 20 || deliveryStatus === 30) {
|
||||
return { bgColor: '#4b9cf5', title: '待收货', subtitle: '商品运输中,请注意查收' }
|
||||
}
|
||||
|
||||
// 未发货时按付款状态显示
|
||||
if (!payStatus && !isCod && !isOffline) {
|
||||
return { bgColor: '#ff7d00', title: '待付款', subtitle: '请尽快完成支付' }
|
||||
}
|
||||
@@ -84,9 +89,6 @@ const getOrderDisplayStatus = (order: ShopOrder): { title: string; bgColor: stri
|
||||
if (deliveryStatus === 10) {
|
||||
return { bgColor: '#4b9cf5', title: '待发货', subtitle: '商家正在准备商品' }
|
||||
}
|
||||
if (deliveryStatus === 20 || deliveryStatus === 30) {
|
||||
return { bgColor: '#4b9cf5', title: '待收货', subtitle: '商品运输中,请注意查收' }
|
||||
}
|
||||
if (orderStatus === OrderStatus.Completed) {
|
||||
return { bgColor: '#0e932e', title: '已完成', subtitle: '交易已完成,感谢购买' }
|
||||
}
|
||||
@@ -111,12 +113,14 @@ const getOrderPhase = (order: ShopOrder): OrderPhase => {
|
||||
return orderStatus === OrderStatus.Cancelled || orderStatus === OrderStatus.RefundSuccess ? 'cancelled' : 'refund'
|
||||
}
|
||||
|
||||
// 物流状态优先于付款状态(已发货/已收货的订单,即使未付款也进入 shipped 阶段)
|
||||
if (deliveryStatus === 20 || deliveryStatus === 30) return 'shipped'
|
||||
|
||||
// 线下付款且未确认收款:等待商家确认,不显示"立即支付"按钮
|
||||
if (isOffline && !payStatus) return 'offline_pending'
|
||||
// 货到付款订单:payStatus=true 但还未实际付款,直接进入 unshipped 阶段(不需要"立即支付"按钮)
|
||||
if (!payStatus && !isCod) return 'unpaid'
|
||||
if (deliveryStatus === 10) return 'unshipped'
|
||||
if (deliveryStatus === 20 || deliveryStatus === 30) return 'shipped'
|
||||
if (orderStatus === OrderStatus.Completed) return 'completed'
|
||||
|
||||
return 'unshipped'
|
||||
|
||||
Reference in New Issue
Block a user