refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
'use client';
|
|
|
|
|
|
|
2026-03-01 20:12:32 +08:00
|
|
|
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
import OrderFilterBar from '@/components/OrderFilterBar';
|
2026-03-01 17:58:08 +08:00
|
|
|
|
import {
|
|
|
|
|
|
formatStatus,
|
|
|
|
|
|
formatCreatedAt,
|
|
|
|
|
|
getStatusBadgeClass,
|
|
|
|
|
|
type MyOrder,
|
|
|
|
|
|
type OrderStatusFilter,
|
|
|
|
|
|
} from '@/lib/pay-utils';
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
|
|
|
|
|
|
interface MobileOrderListProps {
|
|
|
|
|
|
isDark: boolean;
|
|
|
|
|
|
hasToken: boolean;
|
|
|
|
|
|
orders: MyOrder[];
|
2026-03-01 20:12:32 +08:00
|
|
|
|
hasMore: boolean;
|
|
|
|
|
|
loadingMore: boolean;
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
onRefresh: () => void;
|
2026-03-01 20:12:32 +08:00
|
|
|
|
onLoadMore: () => void;
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-01 20:12:32 +08:00
|
|
|
|
export default function MobileOrderList({
|
|
|
|
|
|
isDark,
|
|
|
|
|
|
hasToken,
|
|
|
|
|
|
orders,
|
|
|
|
|
|
hasMore,
|
|
|
|
|
|
loadingMore,
|
|
|
|
|
|
onRefresh,
|
|
|
|
|
|
onLoadMore,
|
|
|
|
|
|
}: MobileOrderListProps) {
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
const [activeFilter, setActiveFilter] = useState<OrderStatusFilter>('ALL');
|
2026-03-01 20:12:32 +08:00
|
|
|
|
const sentinelRef = useRef<HTMLDivElement>(null);
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
|
|
|
|
|
|
const filteredOrders = useMemo(() => {
|
|
|
|
|
|
if (activeFilter === 'ALL') return orders;
|
|
|
|
|
|
return orders.filter((item) => item.status === activeFilter);
|
|
|
|
|
|
}, [orders, activeFilter]);
|
|
|
|
|
|
|
2026-03-01 20:12:32 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (!hasMore || loadingMore) return;
|
|
|
|
|
|
const sentinel = sentinelRef.current;
|
|
|
|
|
|
if (!sentinel) return;
|
|
|
|
|
|
|
|
|
|
|
|
const observer = new IntersectionObserver(
|
|
|
|
|
|
(entries) => {
|
|
|
|
|
|
if (entries[0].isIntersecting) {
|
|
|
|
|
|
onLoadMore();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{ threshold: 0.1 },
|
|
|
|
|
|
);
|
|
|
|
|
|
observer.observe(sentinel);
|
|
|
|
|
|
return () => observer.disconnect();
|
|
|
|
|
|
}, [hasMore, loadingMore, onLoadMore]);
|
|
|
|
|
|
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
|
<div className="flex items-center justify-between">
|
2026-03-01 17:58:08 +08:00
|
|
|
|
<h3 className={['text-base font-semibold', isDark ? 'text-slate-100' : 'text-slate-900'].join(' ')}>
|
|
|
|
|
|
我的订单
|
|
|
|
|
|
</h3>
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
onClick={onRefresh}
|
|
|
|
|
|
className={[
|
|
|
|
|
|
'rounded-lg border px-2.5 py-1 text-xs font-medium',
|
2026-03-01 17:58:08 +08:00
|
|
|
|
isDark
|
|
|
|
|
|
? 'border-slate-600 text-slate-200 hover:bg-slate-800'
|
|
|
|
|
|
: 'border-slate-300 text-slate-700 hover:bg-slate-100',
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
].join(' ')}
|
|
|
|
|
|
>
|
|
|
|
|
|
刷新
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<OrderFilterBar isDark={isDark} activeFilter={activeFilter} onChange={setActiveFilter} />
|
|
|
|
|
|
|
|
|
|
|
|
{!hasToken ? (
|
2026-03-01 17:58:08 +08:00
|
|
|
|
<div
|
|
|
|
|
|
className={[
|
|
|
|
|
|
'rounded-xl border border-dashed px-4 py-8 text-center text-sm',
|
|
|
|
|
|
isDark ? 'border-amber-500/40 text-amber-200' : 'border-amber-300 text-amber-700',
|
|
|
|
|
|
].join(' ')}
|
|
|
|
|
|
>
|
|
|
|
|
|
当前链接未携带登录 token,无法查询“我的订单”。
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
) : filteredOrders.length === 0 ? (
|
2026-03-01 17:58:08 +08:00
|
|
|
|
<div
|
|
|
|
|
|
className={[
|
|
|
|
|
|
'rounded-xl border border-dashed px-4 py-8 text-center text-sm',
|
|
|
|
|
|
isDark ? 'border-slate-600 text-slate-400' : 'border-slate-300 text-slate-500',
|
|
|
|
|
|
].join(' ')}
|
|
|
|
|
|
>
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
暂无符合条件的订单记录
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
{filteredOrders.map((order) => (
|
|
|
|
|
|
<div
|
|
|
|
|
|
key={order.id}
|
2026-03-01 17:58:08 +08:00
|
|
|
|
className={[
|
|
|
|
|
|
'rounded-xl border px-3 py-3',
|
|
|
|
|
|
isDark ? 'border-slate-700 bg-slate-900/70' : 'border-slate-200 bg-white',
|
|
|
|
|
|
].join(' ')}
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
>
|
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
|
<span className="text-2xl font-semibold">¥{order.amount.toFixed(2)}</span>
|
2026-03-01 17:58:08 +08:00
|
|
|
|
<span
|
|
|
|
|
|
className={['rounded-full px-2 py-0.5 text-xs', getStatusBadgeClass(order.status, isDark)].join(' ')}
|
|
|
|
|
|
>
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
{formatStatus(order.status)}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className={['mt-1 text-sm', isDark ? 'text-slate-300' : 'text-slate-600'].join(' ')}>
|
|
|
|
|
|
{order.paymentType}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className={['mt-0.5 text-xs', isDark ? 'text-slate-400' : 'text-slate-500'].join(' ')}>
|
|
|
|
|
|
{formatCreatedAt(order.createdAt)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
))}
|
2026-03-01 20:12:32 +08:00
|
|
|
|
|
|
|
|
|
|
{/* 无限滚动哨兵 */}
|
|
|
|
|
|
{hasMore && (
|
|
|
|
|
|
<div ref={sentinelRef} className="py-3 text-center">
|
|
|
|
|
|
{loadingMore ? (
|
2026-03-05 23:10:44 +08:00
|
|
|
|
<span className={['text-xs', isDark ? 'text-slate-400' : 'text-slate-500'].join(' ')}>加载中...</span>
|
2026-03-01 20:12:32 +08:00
|
|
|
|
) : (
|
|
|
|
|
|
<span className={['text-xs', isDark ? 'text-slate-600' : 'text-slate-300'].join(' ')}>
|
|
|
|
|
|
上滑加载更多
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{!hasMore && orders.length > 0 && (
|
|
|
|
|
|
<div className={['py-2 text-center text-xs', isDark ? 'text-slate-600' : 'text-slate-400'].join(' ')}>
|
|
|
|
|
|
已显示全部订单
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
refactor: extract pay page components and migrate zpay → easypay
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|