<template>
    <ele-page class="workplace-page">
        <goodsStat :detail="orderStatInfo" />
        <orderStat :detail="orderStatInfo" />
        <saleCard />
    </ele-page>
</template>

<script setup>
    import {
        ref,
        computed,
        onMounted,
        onBeforeUnmount,
        getCurrentInstance
    } from 'vue';
    import { EleMessage } from 'ele-admin-plus/es';
    import goodsStat from '@/views/index/components/goods-stat.vue';
    import orderStat from '@/views/index/components/order-stat.vue';
    import saleCard from '@/views/index/components/sale-card.vue';

    const { proxy } = getCurrentInstance();
    const orderStatInfo = ref({});

    // 获取订单统计信息
    const getOrderStatInfo = async () => {
        proxy.$http
            .get('/order/orderstat/getTopPageOrderStatInfo')
            .then((res) => {
                console.log(res, 'x');
                if (res.data.code === 200) {
                    orderStatInfo.value = res.data.data;
                } else {
                    EleMessage.error(res.data.msg || '获取订单统计信息失败');
                }
            });
    };

    onMounted(() => {
        getOrderStatInfo();
    });

    onBeforeUnmount(() => {});
</script>

<style lang="scss" scoped></style>
