<!--  -->
<template>
  <div class="layout">
    <!-- 上侧固定导航栏 -->
    <div class="lay_top">
      <div class="login">
        <img src="@/assets/img/logo.png" alt="" />
        <p>&nbsp;中国人民解放军 陆 军 勤 务 学 院</p>
      </div>
      <!-- 右边的盒子 -->
      <div class="conten">
        <!-- 当前时间 -->
        <div class="bot_time">
          {{ moment().format("LL") }} {{ moment().format("dddd") }}
        </div>
        <!-- tab栏 -->
        <div class="tab">
          <div
            class="tab_row"
            v-for="item in tabArr"
            :key="item.id"
            @click="jump(item.url)"
          >
            <div :class="{ active: $route.meta.myInd === item.id }">
              {{ item.name }}
            </div>
            <img
              v-show="$route.meta.myInd === item.id"
              src="@/assets/img/active.png"
              alt=""
            />
          </div>
        </div>
      </div>
    </div>
    <!-- 下侧内容 -->
    <div class="right_con">
      <Router-view />
    </div>
  </div>
</template>

<script>
export default {
  name: "layout",
  components: {},
  data() {
    // 这里存放数据
    return {
      tabArr: [
        { url: "tab1", id: 1, name: "数字史馆" },
        { url: "tab2", id: 2, name: "校园全景" },
        { url: "tab3", id: 3, name: "文物典藏" },
        { url: "tab4", id: 4, name: "信息检索" }
      ],
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    // 点击tab栏
    jump(url) {
      if (url === "tab1") url = "/index?m=TEST";
      this.$router.replace(url).catch(() => {});
      if (url === "/index?m=TEST") {
        this.$nextTick(() => {
          setTimeout(() => {
            location.reload(true);
          }, 300);
        });
      }
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less' scoped>
.layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 1900px;
  min-height: 900px;
  color: #fff;
  .lay_top {
    display: flex;
    z-index: 999;
    position: relative;
    width: 100%;
    height: 120px;
    background-color: #b0111e;
    .login {
      display: flex;
      align-items: center;
      margin-left: 100px;
      width: 320px;
      height: 120px;
      background-size: 100% 100%;
      & > img {
        width: 90px;
        height: 86px;
      }
      & > p {
        font-size: 24px;
        color: #f2cd83;
        font-weight: 700;
        padding: 21px;
      }
    }
    .conten {
      color: #f2cd83;
      flex: 1;
      .bot_time {
        text-align: right;
        padding-right: 260px;
        height: 40px;
        line-height: 40px;
        border-bottom: 1px solid #f2cd83;
      }
      .tab {
        padding-top: 13px;
        height: 79px;
        background: url('../../assets/img/layTopBac.png') no-repeat right;
        display: flex;
        justify-content: space-around;
        padding-right: 120px;
        .tab_row {
          cursor: pointer;
          text-align: center;
          font-size: 18px;
          height: 60px;
          & > div {
            color: #fff;
          }
          .active {
            color: #f2cd83;
            font-weight: 700;
          }
          & > img {
            width: 53px;
            height: 19px;
          }
          &:hover div{
            color: #f2cd83;
          }
        }
      }
    }
  }
  .right_con {
    background: url('../../assets/img/layoutBac.png');
    background-size: 100% 100%;
    position: relative;
    flex: 1;
  }
}
</style>
