<template>
  <div class="boxxontent">
    <div class="title">
      <div><span>终端总数</span></div>
    </div>
    <div class="progress">
      <div class="sunmDevice">
        <Chart :cdata="cdata" v-if="show" />
      </div>
    </div>
    <div class="list" v-if="show">
      <div class="li">
        <div>设备总数</div>
        <div>
          <NumberGrow :value="seriesData.total"></NumberGrow>个
        </div>
      </div>
      <div class="li" @click="jumpDevicePage('1')" title="点击查看在线设备">
        <div>在线设备</div>
        <div>
          <NumberGrow :value="seriesData.onlineTotal"></NumberGrow>个
        </div>
      </div>
      <div class="li" @click="jumpDevicePage('0')" title="点击查看离线设备">
        <div>离线设备</div>
        <div>
          <NumberGrow :value="seriesData.offlineTotal"></NumberGrow>个
        </div>
      </div>
     <div class="li" title="智能门锁">
        <div>智能门锁</div>
        <div>
          <NumberGrow :value="lookStatistic"></NumberGrow>个
        </div>
      </div>
      <div class="li" @click="jumpDevicePage('2')" title="点击查看异常设备">
        <div>异常设备</div>
        <div>
          <NumberGrow :value="seriesData.isAppBind"></NumberGrow>个
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import Chart from './chart.vue'
  import NumberGrow from "../../NumberGrow.vue"
  import {
    httpGetno
  } from "../../../../api/index.js"
  export default {
    data() {
      return {
        show: true,
        cdata: {
          xData: [
            "故障设备",
            "离线设备",
            "在线设备",
          ],
          seriesData: [{
              value: 0,
              name: "故障设备"
            },
            {
              value: 0,
              name: "离线设备"
            },
            {
              value: 0,
              name: "在线设备"
            },
          ],
        },
        lookStatistic:0,
        seriesData: {
          abnormalTotal: 0,
          batteryLevel1: 0,
          batteryLevel2: 0,
          batteryLevel3: 0,
          batteryLevel4: 0,
          batteryLevel5: 0,
          offlineTotal: 0,
          onlineTotal: 0,
          operationTotal: 0,
          projects: 0,
          total: 0,
          timer:null
        },
      };
    },
    components: {
      Chart,
      NumberGrow
    },
    created() {
      this.seriesData = JSON.parse(localStorage.getItem('statisticsDate')).seriesData
      this.lookStatistic=Number(localStorage.getItem('lookStatistic'))||0
      // this.show=false
      // this.$nextTick(()=>{
      //   this.show=true
      // })
      var cdata = this.cdata
      cdata.seriesData[0].value = this.seriesData.abnormalTotal;
      cdata.seriesData[1].value = this.seriesData.offlineTotal;
      cdata.seriesData[2].value = this.seriesData.onlineTotal;
      this.cdata = cdata
    },
    mounted() {
      var that=this
      this.timer=setInterval(function(){
        that.show=false
        that.setShow()
      },10000)
    },
    methods: {
      setShow(){
        this.$nextTick(()=>{
          this.show=true
        })
      },
		jumpDevicePage(type){
        this.$router.replace({
          path: '/allDevice',
		  name:"allDevice",
          params: {
			  isOnline:type//0离线，1在线，2异常
          },
        });
		}
      // 获取设备概况
    },
    beforeRouteLeave(to, from, next) {
      clearInterval(this.timer)
      next()
    },
    beforeDestroy() {
      clearInterval(this.timer)
    },
  };
</script>

<style lang="scss" scoped>
  .boxxontent {
    margin: 0 20px;
    box-sizing: border-box;
  }

  .boxxontent .title {
    background: linear-gradient(to right, #042f89, transparent);
    padding: .4vw 1vw;
  }

  .boxxontent .title div {
    background: linear-gradient(to right, #007aff, #01cdf0 20%, #028ae1 80%);
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    font-size: 1vw;
    line-height: 1vw;
    font-weight: bold;
  }


  .list {
    border: 1px solid #034480;
    border-radius: .1rem;
    padding: .4vw .2vw;
    text-align: center;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    width: 100%;
  }

  .list .li {
    border-right: 1px dashed #034480;
    width: 100%;
    font-size: .8vw;
    line-height: 1.4vw;
	cursor: pointer;
  }

  .list .li>div:nth-child(1) {
    font-size: .6vw;
  }
  .list .li>div:nth-child(2) {
    font-size: 1vw;
  }

  .list .li:first-child {
    color: #0dde79;
  }

  .list .li:nth-child(2) {
    color: #0dcad8;
  }

  .list .li:nth-child(3) {
    color: #ffcb20;
  }

  .list .li:nth-child(4) {
    color: #0dde79;
  }
  .list .li:nth-child(5) {
    color: #da0051;
    border-right: none;
  }
</style>
