<script setup>
import Recharge from "./components/Recharge.vue";
import Reflect from "./components/Reflect.vue";
import {onMounted, reactive} from "vue";
import useTableQuery from "../../../../hooks/useTableQuery.js";
import Api from "../../../../api/index.js";

const columns = [
    {
        title: '充值日期',
        dataIndex: 'key'
    },
    {
        title: '充值时间',
        dataIndex: 'key'
    },
    {
        title: '交易流水号',
        dataIndex: 'key'
    },
    {
        title: '动账渠道',
        dataIndex: 'key'
    },
    {
        title: '动账用途',
        dataIndex: 'key'
    },
    {
        title: '充值金额(元)',
        dataIndex: 'key'
    },
    {
        title: '付款人账户',
        dataIndex: 'key'
    },
    {
        title: '收款人账户',
        dataIndex: 'key'
    },
];

const vo = reactive({
    page: '',
    rows: [],
    total: 0,
});
const po = reactive({
    wd: null,
});

const {loading, pagination, initFetchData} = useTableQuery({
    parameter: po,
    api: Api.system.getData,
    callback: (data) => {
        Object.assign(vo, data);
        console.log(vo);
    }
});

const businessInfo = reactive({
    money: 0,
    coin: 0,
    recharge: 0,
    withdrawal: 0,
    consume: 0,
});
const getData = async () => {
    const {data} = await Api.merchant.getBusinessInfo();
    Object.assign(businessInfo, data);
}
onMounted(() => {
    getData();
})
</script>

<template>
    <!-- 概览 -->
    <div class="mb-[20px]">
        <a-breadcrumb
            :routes="[{path: '/home/my-wallet', label: '我的钱包'}, {path: '/', label: '概览'},]">
        </a-breadcrumb>
    </div>

    <div class="flex-grow flex flex-col gap-[20px]">
        <div class="mock-card grid grid-cols-5 gap-[20px]" id="statistic-card">
            <div class="bg-[rgb(var(--arcoblue-1))] p-[20px]">
                <a-statistic title="钱包余额(元)" :value="businessInfo.money" :precision="2" :value-from="0"
                             animation></a-statistic>
            </div>
            <div class="bg-[rgb(var(--arcoblue-1))] p-[20px]">
                <a-statistic title="任务款余额(元)" :value="businessInfo.coin" :precision="2" :value-from="0"
                             animation></a-statistic>
            </div>
            <div class="bg-[rgb(var(--arcoblue-1))] p-[20px]">
                <a-statistic title="累计充值(元)" :value="businessInfo.recharge" :precision="2" :value-from="0"
                             animation></a-statistic>
            </div>
            <div class="bg-[rgb(var(--arcoblue-1))] p-[20px]">
                <a-statistic title="累计消耗(元)" :value="businessInfo.consume" :precision="2" :value-from="0"
                             animation></a-statistic>
            </div>
            <div class="bg-[rgb(var(--arcoblue-1))] p-[20px]">
                <a-statistic title="累计提现(元)" :value="businessInfo.withdrawal" :precision="2" :value-from="0"
                             animation></a-statistic>
            </div>
        </div>

        <a-card>
            <a-tabs type="rounded">
                <a-tab-pane key="Recharge" title="我的充值">
                    <Recharge></Recharge>
                </a-tab-pane>
                <a-tab-pane key="Reflect" title="我的提现">
                    <Reflect :businessInfo="businessInfo"></Reflect>
                </a-tab-pane>
            </a-tabs>
        </a-card>

        <div class="mock-card">
            <div class="title">充值记录</div>
            <a-table
                @page-change="(e) => pagination.current = e"
                :pagination="pagination"
                :data="vo.rows"
                :loading="loading"
                :columns="columns">
            </a-table>
        </div>
    </div>
</template>

<style lang="scss" scoped>
#statistic-card {
    :deep(.arco-statistic-value) {
        color: rgb(var(--arcoblue-6));
    }
}

.title {
    color: rgb(29, 33, 41);
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    letter-spacing: 0;
    margin-bottom: 20px;
}
</style>
