更新充值和购买支付宝接口和传参,我的账单列表更新&解决banner拉伸&更新登录的访问令牌

This commit is contained in:
Eamon-meng
2025-06-27 10:57:50 +08:00
parent 570a1ffa65
commit 9057d6c2fc
10 changed files with 127 additions and 366 deletions

View File

@@ -16,12 +16,14 @@ import zod from 'zod'
import {zodResolver} from '@hookform/resolvers/zod'
import {Label} from '@/components/ui/label'
import Page from '@/components/page'
import {PaymentStatusCell} from './payment'
import {CheckCircle, AlertCircle} from 'lucide-react'
import {Input} from '@/components/ui/input'
const filterSchema = zod.object({
type: zod.enum(['all', '3', '1', '2']).default('all'),
create_after: zod.date().optional(),
create_before: zod.date().optional(),
trade_id: zod.string().optional(),
})
type FilterSchema = zod.infer<typeof filterSchema>
@@ -44,9 +46,10 @@ export default function BillsPage(props: BillsPageProps) {
const type = typeValue === 'all' ? undefined : parseInt(typeValue)
const create_after = form.getValues('create_after')
const create_before = form.getValues('create_before')
const trade_id = form.getValues('trade_id')
const res = await listBills({
page, size, type, create_after, create_before,
page, size, type, create_after, create_before, trade_id,
})
if (res.success) {
@@ -70,6 +73,9 @@ export default function BillsPage(props: BillsPageProps) {
resolver: zodResolver(filterSchema),
defaultValues: {
type: 'all',
trade_id: '',
create_after: undefined,
create_before: undefined,
},
})
@@ -85,6 +91,16 @@ export default function BillsPage(props: BillsPageProps) {
</div>
<Form form={form} onSubmit={onSubmit} className="flex items-end gap-4 flex-wrap">
<FormField name="trade_id" label={<span className="text-sm"></span>}>
{({id, field}) => (
<Input
{...field}
id={id}
className="h-9 text-sm"
placeholder="输入订单号"
/>
)}
</FormField>
<FormField name="type" label={<span className="text-sm"></span>}>
{({id, field}) => (
<Select value={field.value} onValueChange={field.onChange}>
@@ -154,42 +170,67 @@ export default function BillsPage(props: BillsPageProps) {
columns={[
{
accessorKey: 'bill_no', header: `账单编号`,
}, {
accessorKey: 'type', header: `类型`, cell: ({row}) => (
<div className="flex gap-2 items-center">
{row.original.type === 1 && (
<div className="flex gap-2 items-center bg-orange-50 w-fit px-2 py-1 rounded-md">
<CreditCard size={16}/>
<span></span>
</div>
)}
{row.original.type === 2 && (
<div className="flex gap-2 items-center bg-green-50 w-fit px-2 py-1 rounded-md">
<CreditCard size={16}/>
<span>退</span>
</div>
)}
{row.original.type === 3 && (
<div className="flex gap-2 items-center bg-blue-50 w-fit px-2 py-1 rounded-md">
<CreditCard size={16}/>
<span></span>
</div>
)}
</div>
),
},
{
accessorKey: 'info', header: `账单详情`,
accessorKey: 'info',
header: `账单详情`,
cell: ({row}) => {
const bill = row.original
return (
<div className="flex items-center gap-2">
{/* 类型展示 */}
<div className="flex-shrink-0">
{bill.type === 1 && (
<div className="flex gap-2 items-center bg-orange-50 w-fit px-2 py-1 rounded-md">
<CreditCard size={16}/>
<span></span>
</div>
)}
{bill.type === 2 && (
<div className="flex gap-2 items-center bg-green-50 w-fit px-2 py-1 rounded-md">
<CreditCard size={16}/>
<span>退</span>
</div>
)}
{bill.type === 3 && (
<div className="flex gap-2 items-center bg-blue-50 w-fit px-2 py-1 rounded-md">
<CreditCard size={16}/>
<span></span>
</div>
)}
</div>
{/* 账单详情 */}
<div className="text-sm">
{bill.info}
</div>
</div>
)
},
},
{
accessorKey: 'status',
header: `状态`,
cell: ({row}) => (
<PaymentStatusCell trade={{
...row.original.trade,
amount: row.original.amount,
}}/>
),
cell: ({row}) => {
const trade = row.original.trade
if (!trade) return <span>-</span>
return (
<div className="flex items-center gap-2">
{trade?.status === 1 ? (
<CheckCircle size={16} className="text-done"/>
) : trade?.status === 2 ? (
<AlertCircle size={16} className="text-weak"/>
) : trade?.status === 3 ? (
<AlertCircle size={16} className="text-fail"/>
) : null}
<span>
{trade?.status === 1 ? '已完成'
: trade?.status === 2 ? '已取消'
: trade?.status === 3 ? '已退款' : '-'}
</span>
</div>
)
},
},
{
accessorKey: 'amount',
@@ -198,17 +239,25 @@ export default function BillsPage(props: BillsPageProps) {
const amount = typeof row.original.amount === 'string'
? parseFloat(row.original.amount)
: row.original.amount || 0
const trade = row.original.trade
return (
<div className="flex gap-1">
<span className="text-sm">
{!row.original.trade && '余额'}
{row.original.trade && row.original.trade.method === 1 && '支付宝'}
{row.original.trade && row.original.trade.method === 2 && '微信'}
</span>
<span className={amount > 0 ? 'text-green-400' : 'text-orange-400'}>
{amount.toFixed(2)}
</span>
<div className="flex flex-col gap-1">
<div className="flex gap-1">
<span className="text-sm">
{!row.original.trade && '余额'}
{row.original.trade && row.original.trade.method === 1 && '支付宝'}
{row.original.trade && row.original.trade.method === 2 && '微信'}
</span>
<span className={amount > 0 ? 'text-green-400' : 'text-orange-400'}>
{amount.toFixed(2)}
</span>
</div>
{trade?.inner_no && (
<div className="text-xs text-gray-500">
: {trade.inner_no}
</div>
)}
</div>
)
},