<template>
  <div class="dashboard-container">
    <div class="scoped-rank">
      <div class="sr-top-left">
        <dv-decoration-3 style="width:250px;height:30px;" />
        <div style="width: 100%;padding-top: 10px;text-align: center;">{{timeTips}}{{sysUser.nickname}}</div>
      </div>
      <div class="sr-top-right">
        <dv-decoration-12 style="width:150px;height:150px;margin-left: 20px;" />
        <dv-decoration-11 style="width:200px;height:60px;color: #1dc1f5;">楼盘点击总榜</dv-decoration-11>
      </div>
      <dv-decoration-10 style="width:100%;height:5px;margin: 30px 0;"/>
      <dv-border-box-1>
        <div class="sr-wrap">
          <dv-scroll-ranking-board :config="config" style="width:500px;height:300px" />
        </div>
      </dv-border-box-1>
      <dv-decoration-6 style="width:100%;height:30px;margin: 30px 0;" />
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'Dashboard',
  data () {
    return {
      config: {
        data: [],
        unit: '次',
      },
      timeTips: '',
    }
  },
  created () {
    let now = new Date()
    let hour = now.getHours()
    if(hour < 6){this.timeTips = '凌晨好！'}
    else if (hour < 9){this.timeTips = '早上好！'}
    else if (hour < 12){this.timeTips = '上午好！'}
    else if (hour < 14){this.timeTips = '中午好！'}
    else if (hour < 17){this.timeTips = '下午好！'}
    else if (hour < 19){this.timeTips = '傍晚好！'}
    else if (hour < 22){this.timeTips = '晚上好！'}
    this.$api.other.admindexranklist().then(res => {
      console.log(res)
      const estateClickRank = res.estate_click_rank || []
      const newArr = estateClickRank.map(item => {
        return {
          value: Number(item.click_num),
          name: item.estate_name,
        }
      })
      let config = this.config
      config.data = [...newArr]
      this.config = {...config}
    })
  },
  computed: {
    ...mapGetters([
      'sysUser',
    ])
  }
}
</script>

<style lang="scss" scoped>
// .dashboard {
//   &-container {
//     margin: 30px;
//   }
//   &-text {
//     font-size: 30px;
//     line-height: 46px;
//   }
// }
.dashboard-container {
  width: 100%;
  height: calc(100vh - 84px);
  background: #1f2d3d;
}
.scoped-rank {
  width: 600px;
  box-sizing: border-box;
  padding: 20px;
  display: inline-block;
  .sr-top-left {
    display: inline-block;
    vertical-align: middle;
    padding-right: 20px;
    color: #1e9bec;
    font-weight: bold;
  }
  .sr-top-right {
    display: inline-block;
    vertical-align: middle;
    width: 200px;
  }
  .sr-wrap {
    padding: 30px;
  }
}
</style>
