<template>
  <div class="app-container home">
    <el-card>
      <el-row>
        <el-col :span="6">
          <el-statistic title="用户数量" :value="indexObj?.memberCount" />
        </el-col>
        <el-col :span="6">
          <el-statistic title="店铺数量" :value="indexObj?.storeCount" />
        </el-col>
        <el-col :span="6">
          <el-statistic title="商品数量" :value="indexObj?.productCount" />
        </el-col>
        <el-col :span="6">
          <el-statistic title="订单数量" :value="indexObj?.orderCount" />
        </el-col>
      </el-row>
    </el-card>
    <el-card>
      <el-row>
        <el-col :span="4">
          <el-row> {{ indexObj?.productAudit }} </el-row>
          <el-row> 待审核商品 </el-row>
        </el-col>
        <el-col :span="4">
          <el-row> {{ indexObj?.StoreAudit }} </el-row>
          <el-row> 待审核店铺 </el-row>
        </el-col>
        <el-col :span="4">
          <el-row> {{ indexObj?.vlogCount }} </el-row>
          <el-row> 待审核视频 </el-row>
        </el-col>
        <el-col :span="4">
          <el-row> {{ indexObj?.orderAudit }} </el-row>
          <el-row> 待审核退款 </el-row>
        </el-col>
        <el-col :span="4">
          <el-row> {{ indexObj?.feedbackCount }} </el-row>
          <el-row> 待审核举报 </el-row>
        </el-col>
        <el-col :span="4">
          <el-row> {{ indexObj?.WithdrawCount }} </el-row>
          <el-row> 待审核提现 </el-row>
        </el-col>
      </el-row>
    </el-card>
    <el-divider />
    <el-row>
      <el-col :span="12">
        <el-card header="分佣额">
          <el-row> 待审核提现 </el-row>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card header="收入支出（万）"></el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-card header="用户量">
          <LineChartnew :chartData="LinechartData" />
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card header="短视频"></el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-card header="店铺TOP20"></el-card>
      </el-col>
      <el-col :span="12">
        <el-card header="商品TOP20"></el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup name="Index" lang="ts">
import { getIndex } from '@/api/login';
import { indexObjOV } from '@/api/types';
import LineChartnew from '@/views/dashboard/LineChartnew.vue'; //引入折线图
const goTarget = (url: string) => {
  window.open(url, '__blank');
};
const indexObj = ref<indexObjOV>();
const LinechartData = ref({
  color: 'red',
  xAxisData: [],
  series: [
    { name: '用户量', data: [] },
    { name: '在线用户', data: [] },
    { name: '活跃', data: [] },
    { name: '下单用户', data: [] }
  ]
});
const getList = async () => {
  const res = await getIndex();
  indexObj.value = res.data;

  res.data?.monthlyUserVolume.forEach((item) => {
    LinechartData.value.xAxisData.push(item.month);
    LinechartData.value.series[0].data.push(item.registerMemberCount);
    LinechartData.value.series[1].data.push(item.loginMemberCount);
    LinechartData.value.series[2].data.push(item.addCartMemberCount);
    LinechartData.value.series[3].data.push(item.dealMemberCount);
  });
};
onMounted(() => {
  getList();
});
</script>

<style lang="scss" scoped>
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: 'open sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>
