<template>
  <div class="Three">
    <div class="leftTitle">三级页面</div>

    <Main
      :data="data"
      :isThree="true"
      @lookInfoFu="lookInfoFu"
      :styleInfo="{
        bac: '#bbbbbb',
        borC: '#fff',
        qBac: '#fff',
        qColor: 'black',
      }"
    />

    <div class="floorIght">
      <div class="btn" @click="$router.push('/')">去首页</div>
      <div class="btn" @click="$router.go(-1)">返回上一页</div>
    </div>

    <!-- 右边的简介 -->
    <div class="info" :class="{ infoShow: info.title }">
      <div class="infoMain">
        <div class="intoTitle"><span>关于</span> {{ info.title }}</div>
        <div class="infoTxt" v-html="info.txt"></div>
      </div>
      <!-- 收起 -->
      <div class="hideInfo" @click="info = {}">
        <img src="../assets/img/right.svg" alt="" />
      </div>
    </div>
    <Search />
  </div>
</template>

<script>
import Search from "../components/Search.vue";
import Main from "../components/Main.vue";

export default {
  components: { Search, Main },
  data() {
    return {
      data: [],
      info: {},
    };
  },
  computed: {},
  watch: {
    info(val) {
      if (val.title) {
        const dom = document.querySelector(".infoMain");
        if (dom) {
          dom.scrollTop = 0;
        }
      }
    },
  },
  methods: {
    lookInfoFu(item) {
      if (item.link) window.open(item.link);
      else if (this.info.title && this.info.title === item.name) this.info = {};
      else this.info = { title: item.name, txt: item.txt };
    },
  },
  created() {},
  mounted() {
    fetch("data3.json")
      .then((res) => {
        return res.json();
      })
      .then((data) => {
        this.data = data.filter((v) => v.uid == this.$route.params.id);
      });
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less' scoped>
.Three {
  background-color: #dbdbdb;
  position: relative;
  overflow: hidden;
  .leftTitle {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 20px;
  }

  .floorIght {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 50px;
    display: flex;
    & > div {
      cursor: pointer;
      margin-right: 15px;
      border-radius: 20px;
      height: 40px;
      background-color: #e3e3e3;
      padding: 0 30px;
      line-height: 40px;
    }
  }
  .info {
    transition: all 0.3s;
    position: absolute;
    right: -400px;
    top: 0;
    z-index: 20;
    background-color: rgba(0, 0, 0, 0.8);
    width: 400px;
    height: 100%;
    border-radius: 10px 0 0 10px;
    color: #fff;
    padding: 80px 10px 80px 20px;
    .infoMain {
      height: 100%;
      padding-right: 10px;
      overflow-y: auto;
      &::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 5px; /*高宽分别对应横竖滚动条的尺寸*/
        height: 1px;
      }
      &::-webkit-scrollbar-thumb {
        /*滚动条里面小方块*/
        border-radius: 10px;
        -webkit-box-shadow: inset 0 0 5px transparent;
        background: #fff;
      }
      &::-webkit-scrollbar-track {
        /*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 5px transparent;
        border-radius: 10px;
        background: transparent;
      }
      .intoTitle {
        font-weight: 700;
        font-size: 30px;
        margin-bottom: 20px;
        & > span {
          font-weight: 400;
          font-size: 16px;
        }
      }
      .infoTxt {
        line-height: 24px;
        letter-spacing: 4px;
      }
    }
    .hideInfo {
      cursor: pointer;
      position: absolute;
      z-index: 10;
      bottom: 10px;
      left: 20px;
      & > img {
        width: 30px;
      }
    }
  }
  .infoShow {
    right: 0;
  }
}
</style>