<template>
  <div class="p-4">
    <GrowCard :loading="loading" :list="growCardList" class="enter-y" />
    <!-- <lineEcharts2  name="chartRef2" class="!my-4 enter-y" :loading="loading" /> -->
    <scenelineEcharts class="!my-4 enter-y" ref="myRefs" :loading="loading" /> 
    <activelineEchart class="!my-4 enter-y" ref="myRefs" :loading="loading" /> 
  </div>
</template>
<script lang="ts" setup>
import { userTotal, } from '/@/api/statistics/index';
import { ref, onMounted, reactive } from 'vue';
import { GrowCardItem } from '../data';
import GrowCard from '../components/GrowCard.vue';
import scenelineEcharts from '../components/scenelineEcharts.vue';
import activelineEchart from '../components/activelineEchart.vue';
const loading = ref(true);
const growCardList = ref<GrowCardItem[]>([]);
const echartData = reactive({
    xdata:[],
    downOrder:[],
    incrementOrder:[],
    partOrder:[],
  })
const SearchData = reactive({
    startTime:'',
    endTime:'',
    dataType:0,
    type:0,
  })
onMounted(() => {
  getData();
});
// async function getList() {
//     let downlist = [],xdata = []
//     loading.value = true;
//     const {downOrder,incrementOrder,partOrder} = await sceneTrend(SearchData);
//     downOrder.map(ele => {
//       xdata.push(ele.groupKey)
//       downlist.push(ele.count)
//     })
//     echartData.xdata = xdata
//     echartData.downOrder = downlist
//     echartData.incrementOrder = incrementOrder.map(ele => ele.count)
//     echartData.partOrder = partOrder &&partOrder.map(ele => ele.count)|| []
//     loading.value = false;
//   }
async function getData() {
  try {
    loading.value = true;
    const {totalUserCount,preMonthAddCount,todayAddCount,todayActiveCount} = await userTotal();
    let list:GrowCardItem[] = [
      {
        title: '累计用户',
        // icon: 'fa6-solid:users-gear',
        icon: 'visit-count|svg',
        value: totalUserCount,
        unit: '人',
        color: 'green',
        action: '年',
      },
      {
        title: '上月新增用户',
        icon: 'akar-icons:person-add',
        value: preMonthAddCount,
        unit: '人',
        color: 'blue',
        action: '月',
      },
      {
        title: '今日新增用户',
        icon: 'carbon:user-role',
        value: todayAddCount,
        unit: '人',
        color: 'orange',
        action: '日',
      },
      {
        title: '今日活跃用户',
        icon: 'ooui:user-active',
        value: todayActiveCount,
        unit: '人',
        color: 'orange',
        action: '日',
      },
    ];
    growCardList.value =list
    loading.value = false;
  } catch (error) {
    loading.value = false;
  }
}
</script>
