用户端“补发货”的bug修复
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
import AppImage from '@dukang/shared-ui/AppImage';
|
import AppImage from '@dukang/shared-ui/AppImage';
|
||||||
import AppToast from '../components/AppToast';
|
import AppToast from '../components/AppToast';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
@@ -118,7 +118,6 @@ function fullReceiverAddress(order: Order) {
|
|||||||
|
|
||||||
export default function OrderDetailPage() {
|
export default function OrderDetailPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const [params] = useSearchParams();
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [order, setOrder] = useState<Order | null>(null);
|
const [order, setOrder] = useState<Order | null>(null);
|
||||||
const [showCs, setShowCs] = useState(false);
|
const [showCs, setShowCs] = useState(false);
|
||||||
@@ -126,7 +125,7 @@ export default function OrderDetailPage() {
|
|||||||
const [shareToast, setShareToast] = useState('');
|
const [shareToast, setShareToast] = useState('');
|
||||||
const [confirming, setConfirming] = useState(false);
|
const [confirming, setConfirming] = useState(false);
|
||||||
|
|
||||||
const isReship = order?.orderType === 'RESHIPMENT' || params.get('type') === 'reship';
|
const isReship = order?.orderType === 'RESHIPMENT';
|
||||||
|
|
||||||
async function loadOrder() {
|
async function loadOrder() {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
|||||||
@@ -20,9 +20,17 @@ const STATUS_LABEL: Record<string, string> = {
|
|||||||
SHIPPING: '配送中',
|
SHIPPING: '配送中',
|
||||||
PENDING_RECEIVE: '待收货',
|
PENDING_RECEIVE: '待收货',
|
||||||
COMPLETED: '已完成',
|
COMPLETED: '已完成',
|
||||||
RESHIP: '补发中',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isReshipOrder(order: Record<string, unknown>) {
|
||||||
|
return String(order.orderType) === 'RESHIPMENT';
|
||||||
|
}
|
||||||
|
|
||||||
|
function orderStatusLabel(order: Record<string, unknown>) {
|
||||||
|
if (isReshipOrder(order)) return '补发中';
|
||||||
|
return STATUS_LABEL[String(order.status)] || String(order.status);
|
||||||
|
}
|
||||||
|
|
||||||
export default function OrderListPage() {
|
export default function OrderListPage() {
|
||||||
const [params, setParams] = useSearchParams();
|
const [params, setParams] = useSearchParams();
|
||||||
const tab = params.get('tab') || 'all';
|
const tab = params.get('tab') || 'all';
|
||||||
@@ -38,18 +46,24 @@ export default function OrderListPage() {
|
|||||||
<PageHeader title="我的订单" onBack={() => navigate('/mine')} />
|
<PageHeader title="我的订单" onBack={() => navigate('/mine')} />
|
||||||
<OrderStatusTabs tabs={TABS} active={tab} onChange={(key) => setParams({ tab: key })} />
|
<OrderStatusTabs tabs={TABS} active={tab} onChange={(key) => setParams({ tab: key })} />
|
||||||
{data.list.length === 0 && <div className="empty">暂无订单</div>}
|
{data.list.length === 0 && <div className="empty">暂无订单</div>}
|
||||||
{data.list.map((o, i) => {
|
{data.list.map((o) => {
|
||||||
const items = (o.items as Array<Record<string, unknown>>) || [];
|
const items = (o.items as Array<Record<string, unknown>>) || [];
|
||||||
const item = items[0];
|
const item = items[0];
|
||||||
const isReshipDemo = i === 0 && tab === 'all';
|
const isReship = isReshipOrder(o);
|
||||||
const isPendingPay = String(o.status) === 'PENDING_PAY';
|
const isPendingPay = String(o.status) === 'PENDING_PAY';
|
||||||
return (
|
return (
|
||||||
<div key={String(o.id)} className="card">
|
<div key={String(o.id)} className="card">
|
||||||
<div className="card-row" style={{ marginBottom: 8 }}>
|
<div className="card-row" style={{ marginBottom: 8 }}>
|
||||||
<span className="label-md text-muted">订单号: {String(o.orderNo)}</span>
|
<span className="label-md text-muted">
|
||||||
<span className="status-tag">{STATUS_LABEL[String(o.status)] || String(o.status)}</span>
|
订单号: {String(o.orderNo)}
|
||||||
|
{isReship && (
|
||||||
|
<span className="tag-reship" style={{ marginLeft: 8 }}>
|
||||||
|
补发单
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="status-tag">{orderStatusLabel(o)}</span>
|
||||||
</div>
|
</div>
|
||||||
{isReshipDemo && <span className="tag-reship" style={{ marginBottom: 8, display: 'inline-block' }}>补发示例</span>}
|
|
||||||
{item && (
|
{item && (
|
||||||
<div className="card-row">
|
<div className="card-row">
|
||||||
<AppImage
|
<AppImage
|
||||||
@@ -74,11 +88,8 @@ export default function OrderListPage() {
|
|||||||
去付款
|
去付款
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<Link
|
<Link to={`/orders/${o.id}`} className="btn btn-outline btn-pill">
|
||||||
to={`/orders/${o.id}${isReshipDemo ? '?type=reship' : ''}`}
|
查看详情
|
||||||
className="btn btn-outline btn-pill"
|
|
||||||
>
|
|
||||||
{isReshipDemo ? '查看进度' : '查看详情'}
|
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user