<template>
  <div class="nav-header">
    <div class="left-nav">
      <span>{{ date }} {{ weekDay }} </span>
    </div>
    <div class="mid-title">
      <span>长兴县建设工程质量安全管理站</span>
    </div>
    <div class="right-nav">
      {{ time }}
    </div>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      date: "",
      weekDay: "",
      time: "",
    };
  },
  methods: {
    getTime() {
      let date = new Date();
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      month = month > 9 ? month : "0" + month;
      day = day < 10 ? "0" + day : day;
      let today = year + "年" + month + "月" + day + "日";
      this.date = today;
      let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      let min =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      let sec =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      this.time = `${hour}:${min}:${sec}`;

      let str = "星期";
      let weekDay = new Date().getDay();
      switch (weekDay) {
        case 0:
          str += "日";
          break;
        case 1:
          str += "一";
          break;
        case 2:
          str += "二";
          break;
        case 3:
          str += "三";
          break;
        case 4:
          str += "四";
          break;
        case 5:
          str += "五";
          break;
        case 6:
          str += "六";
          break;
      }
      this.weekDay = str;
    },
  },
  mounted() {
    setInterval(() => {
      this.getTime();
    }, 1000);
  },
  computed: {
    ...mapState(["userInfo"]),
  },
};
</script>
<style lang="less" scoped>
.nav-header {
  display: flex;
  align-content: center;
  line-height: 40px;
  padding: 0 30px;
  height: 94px;
  margin: 0px;
  background: url("@/assets/images/index/inmg_toubu_yi@2x.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: relative;

  .left-nav {
    width: calc(100% / 3);
    display: flex;
    justify-content: flex-start;
    span {
      color: #fff;
      font-size: 18px;
    }
    .weather-img {
      vertical-align: top;
      width: 30px;
      height: 30px;
      margin: 24px 0;
      margin-right: 30px;
    }
  }
  .mid-title {
    width: calc(100% / 3);
    font-size: 32px;
    color: #fefeff;
    text-align: center;
    letter-spacing: 3px;
    line-height: 70px;
    position: relative;
    span {
      position: absolute;
      left: 0;
      width: 100%;
      height: 100%;
      font-weight: bold;
      white-space: nowrap;
      background-clip: text;
      -webkit-text-fill-color: transparent;
      background-image: linear-gradient(to bottom, #ffffff, #a4c7e8);
      z-index: 999;
    }
  }
  .right-nav {
    width: calc(100% / 3);
    text-align: right;
    font-size: 16px;
    color: #fff;

    img {
      width: 26px;
      height: 26px;
      vertical-align: top;
      border-radius: 50%;
      margin-right: 10px;
      margin-top: 26px;
      object-fit: cover;
    }
  }
}
</style>