<template>
  <div>
    <div class="nav-header">
      <div class="left-nav">
        <span style="font-size: 14px">XXX项目后台管理系统</span>
        <router-link to="/">数字工地</router-link>
        <router-link to="/realname">实名制</router-link>
        <router-link to="/supervisory">视频监控</router-link>
        <router-link to="/earlywarning">AI预警</router-link>
      </div>
      <div class="mid-title">绍兴二院兰亭院区(康复医院)工程</div>
      <div class="right-nav">
        <router-link to="/tower" style="margin-left: 40px"
          >塔吊监测</router-link
        >
        <router-link to="/noise">扬尘噪音</router-link>
        <div class="clock">
          <div class="time">
            {{ time }}
          </div>
          <div class="date">
            <div class="week">{{ weekDay }}</div>
            <div class="day">{{ date }}</div>
          </div>
        </div>
      </div>
    </div>
    <div>
      <router-view></router-view>
    </div>
  </div>
</template>
<script>
export default {
  name: "Index",
  data() {
    return {
      time: "",
      weekDay: "",
      date: "",
    };
  },
  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() {
    this.getTime();
    setInterval(() => {
      this.getTime();
    }, 1000);
  },
};
</script>
<style scoped lang="less">
.nav-header {
  display: flex;
  align-content: center;
  line-height: 70px;
  padding: 0 18px;
  min-height: 78px;
  margin: 0px;
  background: url("@/assets/nav.png") no-repeat;
  background-size: 100% 100%;
  .left-nav {
    width: calc(100% / 3);
    span {
      color: #fff;
      margin-right: 16px;
    }
  }
  .mid-title {
    width: calc(100% / 3);
    font-size: 28px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #fefeff;
    text-align: center;
    letter-spacing: 3px;
  }
  .right-nav {
    width: calc(100% / 3);
    text-align: left;
    .clock {
      float: right;
      width: 124px;
      text-align: center;
      .time {
        text-align: center;
        font-size: 24px;
        color: #22c3ed;
        letter-spacing: 4px;
        line-height: 46px;
      }
      .date {
        font-size: 12px;
        color: #fff;
        display: flex;
        justify-content: space-between;
        line-height: 14px;
      }
    }
  }
}
a {
  min-width: 66px;
  text-align: center;
  display: inline-block;
  text-decoration: none;
  margin-right: 16px;
  color: #80a1c6;
  padding: 9px 12px;
  border: 1px solid #0f5da6;
  border-radius: 4px;
  line-height: 16px;
  font-size: 16px;
  background-image: linear-gradient(#0d3353, #183e75);
  &:hover {
    color: #fff;
    border-color: #27acfb;
    position: relative;
    &::after {
      position: absolute;
      content: "";
      width: 0;
      height: 0;
      bottom: 0px;
      left: 50%;
      transform: translateX(-50%);
      border-right: solid 6px transparent;
      border-left: solid 6px transparent;
      border-bottom: solid 6px #22c3ed;
      filter: drop-shadow(0px -1px 3px rgba(0, 234, 255, 0.8));
    }
  }
}
.router-link-exact-active.router-link-active {
  color: #fff;
  border-color: #27acfb;
  position: relative;
}

.router-link-exact-active.router-link-active::after {
  position: absolute;
  content: "";
  width: 0;
  height: 0;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  border-right: solid 6px transparent;
  border-left: solid 6px transparent;
  border-bottom: solid 6px #22c3ed;
  filter: drop-shadow(0px -1px 3px rgba(0, 234, 255, 0.8));
}
</style>