<template>
  <div class="parking_data">
    <!-- 标题区域 -->
    <div class="title">
      <div class="title_text">数据监测</div>
      <img src="@/assets/images/33.png" />
    </div>

    <!-- 内容区域 -->
    <div class="content">
      <!-- 停车场数据区域 -->
      <div class="content_box">
        <div class="msg_box left">
          <div class="box_key">收费</div>
          <div class="box_value" ref="feeDom">{{ fee }}</div>
        </div>

        <div class="msg_box right">
          <div class="box_key">免费</div>
          <div class="box_value" ref="freeDom">{{ free }}</div>
        </div>

        <div class="msg_num">
          <div class="box_value" ref="countDom">{{ parkingCount }}</div>
          <div class="box_key">停车场</div>
        </div>
      </div>

      <!-- 停车位数据区域 -->
      <div class="content_box">
        <div class="msg_box left2">
          <div class="box_key">当前占用</div>
          <div class="box_value" ref="useDom">{{ use }}</div>
        </div>

        <div class="msg_box right2">
          <div class="box_key">当前空余</div>
          <div class="box_value" ref="emptyDom">{{ empty }}</div>
        </div>

        <div class="msg_num">
          <div class="box_value" ref="countDom2">{{ count }}</div>
          <div class="box_key">停车位</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { countUpNum } from "@/utils/countUpNum.ts";

// 收费数据
const fee = ref<number>(16);
const feeDom = ref();

// 免费数据
const free = ref<number>(4);
const freeDom = ref();

// 当前占用数据
const use = ref<number>(499);
const useDom = ref();

// 当前空余数据
const empty = ref<number>(67);
const emptyDom = ref();

// 总数量
const parkingCount = ref<number>(20);
const count = ref<number>(566);
const countDom = ref();
const countDom2 = ref();

onMounted(() => {
  getCountUpNum();
});

// 让数字跳动
const getCountUpNum = () => {
  countUpNum(feeDom.value, fee.value);
  countUpNum(freeDom.value, free.value);
  countUpNum(useDom.value, use.value);
  countUpNum(emptyDom.value, empty.value);
  countUpNum(countDom.value, parkingCount.value);
  countUpNum(countDom2.value, count.value);
};
</script>

<style lang="scss" scoped>
.parking_data {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;

  .title {
    position: relative;
    width: 100%;
    height: 41px;
    line-height: 41px;

    .title_text {
      position: absolute;
      left: 15px;
      z-index: 1;
      font-size: 23.5px;
      font-weight: bold;
      color: #e0efff;
    }

    img {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 16px;
    }
  }

  .content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    height: 555px;

    .content_box {
      position: relative;
      width: 500px;
      height: 202px;
      background-image: url(@/assets/images/38.png);
      background-size: 100% 100%;

      .msg_box {
        position: absolute;
        top: 50px;
        height: 110px;
        text-align: center;

        .box_key {
          font-size: 28px;
        }

        .box_value {
          margin-top: 40px;
          font-size: 42.5px;
        }
      }

      .left {
        left: 30px;
      }

      .left2 {
        left: 0;
      }

      .right {
        right: 30px;
      }

      .right2 {
        right: 0;
      }

      .msg_num {
        position: absolute;
        top: 50px;
        left: 218px;
        height: 110px;
        text-align: center;

        .box_value {
          margin-top: 30px;
          font-size: 24px;
          font-weight: bold;
        }

        .box_key {
          margin-top: 10px;
          font-size: 16px;
          color: #d8d8d8;
        }
      }
    }
  }
}
</style>
