<template>
  <div class="nav-header">
    <div class="nav-bg"></div>
    <div class="left-nav">
      <span>{{ date }} {{ weekDay }} {{ time }}</span>
    </div>
    <div class="mid-title">
      <span>水利工程质量动态评估系统</span>
    </div>
    <div class="right-nav">
      <span @click="returnManage">
        <img src="@/assets/images/return_icon.jpg" alt="" />
        功能入口
      </span>
      <!-- <img :src="userInfo.op_avatar" alt="" />
      {{ userInfo.op_name }} -->
    </div>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      date: "",
      weekDay: "",
      time: "",
    };
  },
  methods: {
    returnManage() {
      window.location.href = window.location.origin;
    },
    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: 80px;
  padding: 0 30px;
  height: 130px;
  margin: 0px;
  background: url("@/assets/images/index/img_bjh@2x.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: relative;
  .nav-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 80px;
    background: url("@/assets/images/index/img_dingbu@2x.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
  }
  .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: 60px;
    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;
    span {
      padding: 4px;
      z-index: 90;
      cursor: pointer;
      position: absolute;
      right: 20px;
      top: 20px;
      border: 1px solid #3f78bc;
      background: #173c68;
      line-height: 26px;
      font-size: 14px;
      &:hover {
        background: #2862a6;
      }
    }
    img {
      width: 26px;
      height: 26px;
      vertical-align: top;
      border-radius: 50%;
      margin-right: 4px;
      object-fit: cover;
    }
  }
}
</style>