<template>
  <div>
    <avue-data-tabs :option="option" ></avue-data-tabs>
  </div>
</template>

<script>
import {mapGetters} from "vuex";
import request from "@/router/axios";

export default {
  name: "wel",
  data() {
    return {
      option: {
        span: 6,
        data: [
          {
            click: function (item) {
              console.log(JSON.stringify(item));
            },
            title: '今日红包总数',
            subtitle: "",
            count: 0,
            // allcount: 5213,
            // text: '当前用户总数',
            color: 'rgb(27, 201, 142)',
            key: "总"
          },
          {
            click: function (item) {
              console.log(JSON.stringify(item));
            },
            title: '今日红包总金额',
            subtitle: '',
            decimals:2,
            count: 0,
            color: 'rgb(230, 71, 88)',
            key: '金'
          },
          {
            click: function (item) {
              console.log(JSON.stringify(item));
            },
            title: '已领总数',
            count: 4,
            color: 'rgb(178, 159, 255)',
            key: '领'
          },
          {
            click: function (item) {
              console.log(JSON.stringify(item));
            },
            title: '已领总金额',
            decimals:2,
            subtitle: '',
            count: 0,
            color: 'rgb(145, 200, 30)',
            key: '领'
          },
          {
            click: function (item) {
              console.log(JSON.stringify(item));
            },
            title: '未领总数',
            count: 0,
            color: 'rgb(178, 159, 255)',
            key: '未'
          },
          {
            click: function (item) {
              console.log(JSON.stringify(item));
            },
            title: '未领总金额',
            subtitle: '',
            decimals:2,
            count: 0,
            color: 'rgb(145, 200, 30)',
            key: '未'
          }
        ]
      }
    };
  },
  computed: {
    ...mapGetters(["userInfo"]),
  },
  mounted() {
    this.init();
  },
  methods: {
    handleChange(val) {
      window.console.log(val);
    },
    init() {
      request({
        url: '/api/re/manager/todayStatistics',
        method: 'get'
      }).then(res => {
        const data = res.data.data;
        this.option.data.forEach(e => {

          if ('今日红包总数' === e.title) {
            e.count = data.redEnvelopeItemCount;
          }
          if ('今日红包总金额' === e.title) {
            e.count = data.totalRedEnvelopeAmount;
          }
          if ('已领总数' === e.title) {
            e.count = data.receiveItemCount;
          }
          if ('已领总金额' === e.title) {
            e.count = data.totalReceivedRedEnvelopeAmount;
          }
          if ('未领总数' === e.title) {
            e.count = data.remainItemCount;
          }
          if ('未领总金额' === e.title) {
            e.count = data.totalRemainItemAmount;
          }
        })
      })


    }
  },
};
</script>

<style>
.el-font-size {
  font-size: 14px;
}
</style>
