<template>
  <div class="boxxontent">
    <div class="title">
      <div><span>数据统计分析</span></div>
    </div>
    <div class="list" v-if="showDom">
      <div class="li">
        <div>一键报警次数</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>次
        </div>
      </div>
      <div class="li">
        <div>红外报警次数</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>次
        </div>
      </div>
      <div class="li">
        <div>设备报警总数</div>
        <div>
          <NumberGrow :value="alertTotal"></NumberGrow>次
        </div>
      </div>
      <div class="li">
        <div>蹲位空闲</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>个
        </div>
      </div>
      <div class="li">
        <div>井盖异常</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>个
        </div>
      </div>
    </div>
    <div class="list" v-if="showDom">
      <div class="li">
        <div>总用电(kWh)</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>KWH
        </div>
      </div>
      <div class="li">
        <div>总用水(m³）</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>m³
        </div>
      </div>
      <div class="li">
        <div>垃圾桶满溢</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>个
        </div>
      </div>
      <div class="li">
        <div>空气质量差</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>个
        </div>
      </div>
      <div class="li">
        <div>温湿度异常</div>
        <div>
          <NumberGrow :value="0"></NumberGrow>个
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  // import Chart from './chart.vue'
  import NumberGrow from "../../NumberGrow.vue"
  import {
    httpGet
  } from "../../../../api";
  export default {
    data() {
      return {
        showDom:true,
        colors: [{
            color: '#01bd8d',
            percentage: 99
          },
          {
            color: '#da0051',
            percentage: 1
          },
        ],
        collectUS: {
          houseSensor400: 0,
          lock200: 0,
          lock300: 0,
          site200: 0,
          site300: 0,
          site400: 0,
          userCount: 0
        },
        seriesData: {
          abnormalTotal: 0,
          batteryLevel1: 0,
          batteryLevel2: 0,
          batteryLevel3: 0,
          batteryLevel4: 0,
          batteryLevel5: 0,
          closeTotal: 0,
          offlineTotal: 0,
          onlineTotal: 0,
          openTotal: 0,
          projects: 0,
          total: 0
        },
        alertTotal:0,
        timer:null
      };
    },
    components: {
      // Chart,
      NumberGrow
    },
    created() {
      let statisticsDate = JSON.parse(localStorage.getItem('statisticsDate'))
      this.collectUS = statisticsDate.collectUS
      this.seriesData = statisticsDate.seriesData
      for(let t in statisticsDate.collectUS){
        let q=t.indexOf('lock')
        if(q!=-1){
          this.alertTotal+=statisticsDate.collectUS[t]
        }
      }
    },
    mounted() {
      let that=this
      this.timer=setInterval(function(){
        that.showDom=false
        that.setShow()
      },10000)
    },
    methods: {
      setShow(){
        this.$nextTick(()=>{
          this.showDom=true
        })
      },

    },
    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;
    margin: 1vh 0 2vh;
  }

  .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;
  }

  .sunmDevice {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    width: 90%;
    margin: .6vh 0;

  }

  .sunmDevice .progbox {
    position: relative;
    display: inline-block;
    text-align: center;
  }

  .sunmDevice .progbox>>>.el-progress__text {
    color: #fff;
    font-size: .8vw !important;
  }

  .sunmDevice .progbox>>>.el-progress-circle {
    width: 6vw !important;
    height: 6vw !important;
  }

  .sunmDevice .progbox>span {
    position: absolute;
    bottom: .6vh;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: .8vw;
    width: 100%;
  }

  .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%;
    margin: 1vh 0;
  }

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

  .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: #da0051;
  }

  .list .li:nth-child(5) {
    color: #ff5500;
  }

  .list .li:last-child {
    border-right: none;
    color: #55ffff;
  }
</style>
