<template>
  <div class="boxxontent">
    <div class="title">
      <div><span>一周开锁次数</span></div>
    </div>
    <div class="progress">
      <div class="sunmDevice">
        <Chart :cdata="cdata" v-if="showDom"/>
      </div>
    </div>
  </div>
</template>

<script>
  import Chart from './chart.vue'
  import {
    httpGet
  } from "../../../../api";
  import moment from "moment"
  export default {
    data() {
      return {
        showDom:true,
        timer:null,
        cdata: {
          datate:[0,0,0,0,0,0,0],
          seriesData: [820, 932, 901, 934, 1290, 1330, 1320],
        },
      };
    },
    components: {
      Chart,
    },
    created() {
      var weekopenlock = JSON.parse(localStorage.getItem('statisticsDate')).weekopenlock.reverse()
      weekopenlock=weekopenlock.splice(0,7).reverse()
      var datate=[],seriesData=[]
      weekopenlock.map((li,index)=>{
        if(index<7){
          datate.push(li.order)
          seriesData.push(li.count)
        }
      })
      this.cdata.datate=datate
      this.cdata.seriesData=seriesData
    },
    mounted() {
      var 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;
  }

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