diff --git a/src/views/user-center/bill/index.vue b/src/views/user-center/bill/index.vue index 49a697f..22ce8d2 100644 --- a/src/views/user-center/bill/index.vue +++ b/src/views/user-center/bill/index.vue @@ -3,47 +3,17 @@ import { useTable } from '@/hooks/common/table'; import { SimpleScrollbar } from '~/packages/materials/src'; import { computed, shallowRef } from 'vue'; import { useElementSize } from '@vueuse/core'; - -interface BillInfo { - billId: string; - username: string; - amount: number; - paymentMethod: string; -} - -// 模拟API调用函数 -const doGetBillInfo = async (params: any) => { - // TODO: 替换为实际的API调用 - return { - data: { - rows: [ - { - billId: 'BILL001', - username: '张三', - amount: 199.99, - paymentMethod: 'alipay', - }, - { - billId: 'BILL002', - username: '李四', - amount: 299.50, - paymentMethod: 'wechat', - }, - ], - total: 2 - } - }; -}; +import { fetchBillList } from '@/service/api/auth'; +import { Tag as ATag } from 'ant-design-vue'; +import BillSearch from '@/views/user-center/bill/modules/bill-search.vue'; const wrapperEl = shallowRef(null); const { height: wrapperElHeight } = useElementSize(wrapperEl); -const scrollConfig = computed(() => { - return { - y: wrapperElHeight.value - 72, - x: 800 - }; -}); +const scrollConfig = computed(() => ({ + y: wrapperElHeight.value - 72, + x: 1200 +})); const { columns, @@ -52,49 +22,73 @@ const { loading, getData, mobilePagination, + searchParams, + resetSearchParams } = useTable({ - apiFn: doGetBillInfo, + apiFn: fetchBillList, immediate: true, apiParams: { pageNum: 1, pageSize: 10, - }, - rowKey: 'billId', - columns: (): AntDesign.TableColumn>[] => [ + userName: '', + type: undefined, + status: undefined + } as Api.Auth.BillParams, + rowKey: 'id', + pagination: true, + columns: (): AntDesign.TableColumn[] => [ { - key: 'billId', - dataIndex: 'billId', - title: '账单ID', - align: 'center', - }, - { - key: 'username', - dataIndex: 'username', + key: 'userName', + dataIndex: 'userName', title: '用户名', align: 'center', + width: 120 }, { - key: 'amount', - dataIndex: 'amount', + key: 'type', + dataIndex: 'type', + title: '订单类型', + align: 'center', + width: 120, + customRender: ({ text }) => { + const typeMap: Record = { + 0: '套餐订单', + 1: '充值订单' + }; + return typeMap[text] || text; + } + }, + { + key: 'packageName', + dataIndex: 'packageName', + title: '套餐名称', + align: 'center', + width: 150, + customRender: ({ text }) => text || '-' + }, + { + key: 'orderAmount', + dataIndex: 'orderAmount', title: '金额', align: 'center', - customRender: ({ record }: { record: BillInfo }) => { - return `¥${record.amount.toFixed(2)}`; - }, + width: 120, + customRender: ({ text }) => `¥${Number(text).toFixed(2)}` }, { - key: 'paymentMethod', - dataIndex: 'paymentMethod', - title: '支付方式', + key: 'status', + dataIndex: 'status', + title: '状态', align: 'center', - customRender: ({ record }: { record: BillInfo }) => { - const methodMap: Record = { - 'alipay': '支付宝', - 'wechat': '微信支付', - 'card': '银行卡', + width: 100, + customRender: ({ text }) => { + const statusMap: Record = { + 0: { text: '待支付', color: 'warning' }, + 1: { text: '已支付', color: 'success' }, + 2: { text: '已取消', color: 'error' } }; - return methodMap[record.paymentMethod] || record.paymentMethod; - }, + const status = statusMap[text] || { text, color: 'default' }; + return {status.text}; + } }, ] }); @@ -103,6 +97,11 @@ const {