<template>
  <div class="box">
    <!-- 左边区域 -->
    <div class="box_left">
      <div class="left_time">{{ currentTime }}</div>
      <div class="left_date">{{ currentDate }}</div>
    </div>

    <!-- 中间区域 -->
    <div class="box_center">智慧宿舍可视化大屏</div>

    <!-- 右边区域 -->
    <div class="box_right">
      <!-- 天气区域 -->
      <div class="right_weather">
        <img class="weather_img" src="@/assets/images/sun.png" />
        <div class="weather_type">多云</div>
        <div class="weather_num">28 ℃</div>
      </div>
      <!-- 用户头像区域 -->
      <div class="right_user">
        <img class="user_img" src="@/assets/images/user.png" />
        <div class="user_name">王大伟</div>
      </div>
      <!-- 下拉区域 -->
      <el-dropdown trigger="click">
        <el-icon color="#C0EAFF"><CaretBottom /></el-icon>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { getCurrentTime } from '@/utils/getTime.js'

// 当前日期星期
const currentDate = ref('')
// 当前时分秒
const currentTime = ref('')

onMounted(() => {
  getTimeData()
})

const getTimeData = () => {
  currentDate.value = getCurrentTime().currentDate
  currentTime.value = getCurrentTime().currentTime
  setInterval(() => {
    currentDate.value = getCurrentTime().currentDate
    currentTime.value = getCurrentTime().currentTime
  }, 1000)
}
</script>
<style lang="scss" scoped>
.box {
  position: relative;
  z-index: 999;
  display: flex;
  padding: 0 30px;
  height: 100px;
  color: #c0eaff;
  background-image: url(@/assets/images/header_bg.png);
  background-size: 100% 100%;
  overflow: hidden;

  .box_left {
    display: flex;
    align-items: center;
    margin-top: 8px;
    height: 42px;
    .left_time {
      font-size: 32px;
    }

    .left_date {
      margin-left: 20px;
      font-size: 16px;
    }
  }

  .box_center {
    margin-left: 418px;
    font-size: 40px;
    font-weight: bold;
    color: #fff;
  }

  .box_right {
    display: flex;
    align-items: center;
    margin-left: 438px;
    margin-top: 8px;
    height: 30px;

    .right_weather {
      display: flex;
      align-items: center;

      .weather_img {
        margin-top: 5px;
        width: 40px;
        height: 40px;
        object-fit: cover;
      }

      .weather_type {
        margin-left: 8px;
        font-size: 20px;
      }

      .weather_num {
        margin-left: 10px;
        font-size: 16px;
      }
    }

    .right_user {
      display: flex;
      align-items: center;
      margin-left: 44px;

      .user_img {
        margin-top: 5px;
        width: 30px;
        height: 30px;
        object-fit: cover;
      }

      .user_name {
        margin: 0 8px 0 13px;
        font-size: 16px;
      }
    }
  }
}
</style>
