<template>
  <a-row :gutter="[24, 24]">
    <!-- <a-col :lg="10" :md="24" :sm="24" :xl="8" :xxl="7">
      <UserInfo />
      </a-col> -->
    <a-col :lg="24" :md="24" :sm="24" :xl="24" :xxl="24">
      <Count v-if="info!=={}" :info="info" />
    </a-col>
    <!--
      <a-col :lg="24" :md="24" :sm="24" :xl="24" :xxl="24">
        <Analysis />
      </a-col> -->
  </a-row>
</template>

<script>
import { getMiddlesUserDatas } from '@/api/statistical'
import UserInfo from '@/views/home/components/UserInfo'
import Count from '@/views/home/components/Count'
import Analysis from '@/views/home/components/Analysis.vue'

export default {
  name: 'Home',
  components: {
    UserInfo, Count, Analysis
  },
  data () {
    return {
      info: {},
      serarchkey: 'today'
    }
  },
  computed: {
    currentUser () {
      return {
        name: this.$store.getters.nickname,
        avatar: this.$store.getters.avatar,
        isManage: this.$store.getters.isManage,
        username: this.$store.getters.username
      }
    }
  },
  created () {
    this.getInfo()
    //  监听是否切换了日，周，月，年
    this.eventBus.$on('updateHomeDataByType', (type) => {
      this.serarchkey = type.type
      this.getInfo()
    })
  },
  destroyed () {
    this.eventBus.$off('updateHomeDataByType')
  },
  methods: {
    getInfo () {
      getMiddlesUserDatas(this.serarchkey).then(res => {
        this.info = res
      }).catch(err => {
        this.$notification.error(err)
      })
    },
    EditShop () {
      // this.$dialog(EditShop,
      //   {
      //     on: {
      //       ok: () => {
      //         this.getInfo()
      //       }
      //     }
      //   },
      //   {
      //     title: '修改店铺信息',
      //     width: 500,
      //     maskClosable: true,
      //     closable: true,
      //     okText: '确认修改',
      //     cancelText: '取消'
      //   }
      // )
    }
  }
}
</script>

<style lang='less' scoped>
@import "Index.less";
</style>
