<template>
  <div class="left-chart-1">
    <!-- <dv-border-box-1 class="lc1-details">定位监护长者<span>430</span></dv-border-box-1> -->
    <!-- <div class="lc1-details">定位监护长者<span>{{ number }}</span></div> -->
    <div class="lc1-details">
      定位监护长者
      <dv-digital-flop :config="config1" style="width: 200px; height: 50px" />
    </div>
    <div class="left-list">
      <div class="left-container">
        <div class="container-topdown">
          <img src="./img/sos.png" alt="" />
          <div class="word">SOS告警</div>
        </div>
        <div class="container-topdown">
          <div class="number">{{ data.un_alarmSOSSolve }}</div>
          <div class="word">未处理</div>
        </div>
        <div class="container-topdown">
          <div class="number color">{{ data.alarmSOSSolve }}</div>
          <div class="word">已处理</div>
        </div>
      </div>
      <div class="left-container">
        <div class="container-topdown">
          <img src="./img/weilan.png" alt="" />
          <div class="word">围栏告警</div>
        </div>
        <div class="container-topdown">
          <div class="number">{{ data.un_alarmRailSolve }}</div>
          <div class="word">未处理</div>
        </div>
        <div class="container-topdown">
          <div class="number color">{{ data.alarmRailSolve }}</div>
          <div class="word">已处理</div>
        </div>
      </div>
      <div class="left-container">
        <div class="container-topdown">
          <img src="./img/xinlv.png" alt="" />
          <div class="word">心率告警</div>
        </div>
        <div class="container-topdown">
          <div class="number">{{ data.un_alarmHeartSolve }}</div>
          <div class="word">未处理</div>
        </div>
        <div class="container-topdown">
          <div class="number color">{{ data.alarmHeartSolve }}</div>
          <div class="word">已处理</div>
        </div>
      </div>
      <div class="left-container">
        <div class="container-topdown">
          <img src="./img/diedao.png" alt="" />
          <div class="word">跌倒告警</div>
        </div>
        <div class="container-topdown">
          <div class="number">{{ data.un_alarmFallSolve }}</div>
          <div class="word">未处理</div>
        </div>
        <div class="container-topdown">
          <div class="number color">{{ data.alarmFallSolve }}</div>
          <div class="word">已处理</div>
        </div>
      </div>
      <div class="left-container">
        <div class="container-topdown">
          <img src="./img/didian.png" alt="" />
          <div class="word">低电提醒</div>
        </div>
        <div class="container-topdown">
          <div class="number">{{ data.un_alarmLowSolve }}</div>
          <div class="word">未处理</div>
        </div>
        <div class="container-topdown">
          <div class="number color">{{ data.alarmLowSolve }}</div>
          <div class="word">已处理</div>
        </div>
      </div>
      <div class="left-container">
        <div class="container-topdown">
          <img src="./img/shebei.png" alt="" />
          <div class="word">设备状态</div>
        </div>
        <div class="container-topdown">
          <div class="number">{{ data.un_alarmStatusSolve }}</div>
          <div class="word">未处理</div>
        </div>
        <div class="container-topdown">
          <div class="number color">{{ data.alarmStatusSolve }}</div>
          <div class="word">已处理</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { count, alarm } from "@/api/system/datav";
export default {
  name: "LeftChart1",
  data() {
    return {
      config: {
        // data: [
        //   {
        //     label:222,
        //     name: '收费系统',
        //     value: 167
        //   },
        //   {
        //     label:222,
        //     name: '通信系统',
        //     value: 67
        //   },
        //   {
        //     label:222,
        //     name: '监控系统',
        //     value: 123
        //   },
        //   {
        //     label:222,
        //     name: '供配系统',
        //     value: 55
        //   },
        //   {
        //     label:222,
        //     name: '其他',
        //     value: 98
        //   },
        //   {
        //     label:222,
        //     name: '其他',
        //     value: 98
        //   },
        // ],
        colors: ["#00baff", "#3de7c9", "#fff", "#ffc530", "#469f4b"],
        unit: "件",
      },
      number: null,
      data: {},
      config1: {},
      currentValue:0,
      digits: [0, 0, 0],
      animationInterval: null,
    };
  },
  mounted() {
    this.initData();
    // setInterval(() => {
    //   this.power(360);
    // }, 500);
    // this.flipToValue(this.number); // 初始化显示数字
    this.startAnimation()
  },
  methods: {
    async initData() {
      await count().then((res) => {
        console.log(res, 999);
        this.number = res.data;
      });
      alarm().then((res) => {
        console.log(res, 444);
        this.data = res.data;
      });
      this.config1 = {
        number: [this.number],
        content: `${String(this.number)}`,
      };
      console.log(typeof String(this.number),777);
    },
    // power(n) {
    //   this.config1.number[0] = Math.floor(Math.random() * n + 1);
    //   this.config1 = { ...this.config1 }; //对象解构，更新props
    // },
    // startAnimation() {
    //   this.animationInterval = setInterval(() => {
    //     const increment = this.number > this.currentValue ? 1 : -1;
    //     this.currentValue += increment;
    //     console.log(this.currentValue, increment,4545444);
    //     this.flipToValue(this.currentValue);
    //     // this.number = this.currentValue

    //     if (this.currentValue === this.number) {
    //       clearInterval(this.animationInterval);
    //       setTimeout(() => {
    //         this.currentValue = 0; // 重置当前值
    //         this.startAnimation(); // 开始新一轮动画
    //       }, 5000); // 5秒后重新开始
    //     }
    //   }, 50);
    // },
    // updateDigit(index, value) {
    //   this.$set(this.digits, index, value);
    // },
    // flipToValue(value) {
    //   const valueStr = String(value).padStart(3, '0');
    //   for (let i = 0; i < 3; i++) {
    //     this.updateDigit(i, Number(valueStr[i]));
    //   }
    // },
  },
};
</script>

<style lang="scss">
.left-chart-1 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-grow: 0;
  flex-direction: column;
  // border:1px solid green;

  .lc1-details {
    // width: 250px;
    height: 90px;
    font-size: 14px;
    padding: 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 5px;
    // border: 1px solid red;
    background-color: #062961;

    span {
      color: #096dd9;
      font-weight: bold;
      font-size: 35px;
      margin-left: 20px;
    }
  }
  .left-list {
    .left-container {
      // width: 100%;
      text-align: center;
      border-radius: 5px;
      border: 1px solid #1ae1e6;
      // height: 50px;
      // background-color: green;
      margin-top: 10px;
      display: flex;
      background-color: #5d6986;
      // color:red;
      .container-topdown {
        width: 100%;
        height: 57px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        img {
          width: 20px;
          height: 20px;
        }
        .word {
          font-size: 12px;
        }
        .number {
          color: #fcca00;
          font-size: 20px;
          font-weight: bold;
        }
        .color {
          color: #fff;
        }
      }
    }
  }
}
</style>
