<!--  -->
<template>
  <div class="tab3">
    <div class="left">
      <ul>
        <li
          :class="{ active: listInd === item.id }"
          v-for="item in listData"
          :key="item.id"
          @click="cutTab(item.id)"
        >
          <span>·</span> {{ item.name }}
        </li>
      </ul>
      <div class="search">
        <el-input
          placeholder="搜索"
          suffix-icon="el-icon-search"
          v-model="search"
        >
        </el-input>
        <span class="btn" @click="mySearch"></span>
      </div>
    </div>
    <!-- 右侧内容 -->
    <div class="right">
      <div class="row" v-for="i in 9" :key="i" @click="modelFu">
        <img src="../../assets/img/swiper.png" alt="" />
        <p>123</p>
      </div>
      <!-- 分页 -->
      <!-- :page-sizes="[15, 30, 45, 60]"
        :current-page="from2.pageNum"
        @current-change="currentChange"
        @size-change="sizeChange"
      -->
      <div class="paging">
        <el-pagination layout="prev,pager,next,jumper" :total="100">
        </el-pagination>
      </div>
    </div>
    <!-- 点击文物出现的弹窗 -->
    <div class="model" v-if="modelShow">
      <div class="ifrCon" ref="ifrCon">
        <iframe
          src="https://4dscene.4dage.com/culturalrelics/ZSBWG/Model.html?m=zsbb12&v=1"
          frameborder="0"
        ></iframe>
        <!-- 关闭按钮 -->
        <div class="btnX el-icon-close" @click="modelShow = false"></div>
        <!-- 全屏按钮 -->
        <div class="full" @click="screen"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'tab3',
  components: {},
  data () {
    // 这里存放数据
    return {
      fullscreen: false,
      modelShow: false,
      listData: [
        { id: 1, name: '实物模型', type: '' },
        { id: 2, name: '专题图库', type: '' },
        { id: 3, name: '视频档案', type: '' }
      ],
      listInd: 1,
      search: ''
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    // 点击模型全屏
    screen () {
      const element = this.$refs.ifrCon // 获取容器
      if (this.fullscreen) {
        // 如果已经全屏了就退出全屏

        if (document.exitFullscreen) {
          document.exitFullscreen()
        } else if (document.webkitCancelFullScreen) {
          document.webkitCancelFullScreen()
        } else if (document.mozCancelFullScreen) {
          document.mozCancelFullScreen()
        } else if (document.msExitFullscreen) {
          document.msExitFullscreen()
        }
      } else {
        // 如果不是全屏就变成全屏
        if (element.requestFullscreen) {
          element.requestFullscreen()
        } else if (element.webkitRequestFullScreen) {
          element.webkitRequestFullScreen()
        } else if (element.mozRequestFullScreen) {
          element.mozRequestFullScreen()
        } else if (element.msRequestFullscreen) {
          // IE11
          element.msRequestFullscreen()
        }
      }

      this.fullscreen = !this.fullscreen
    },
    // 点击模型
    modelFu () {
      this.modelShow = true
    },
    cutTab (id) {
      this.listInd = id
    },
    mySearch () {
      console.log('点击了搜索')
    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {
    // 监听esc事件
    document.addEventListener('webkitfullscreenchange', (e) => {
      if (!(e.currentTarget.webkitIsFullScreen)) {
        // console.log('退出啊webkitIsFullScreen11111111111')
        setTimeout(() => {
          this.fullscreen = false
        }, 100)
      } else {
        // console.log('进入webkitIsFullScreen')
      }
    })

    document.addEventListener('fullscreenchange', (e) => {
      if (!document.fullscreenElement) {
        // console.log('退出啊fullscreenchange1111111111')
        setTimeout(() => {
          this.fullscreen = false
        }, 100)
      } else {
        // console.log('进入fullscreenchange')
      }
    })

    document.addEventListener('MSFullscreenChange', (e) => {
      if (!document.msFullscreenElement) {
        // console.log('IE退出111111')
        setTimeout(() => {
          this.fullscreen = false
        }, 100)
      } else {
        // console.log('IE进')
      }
    })
    document.addEventListener('mozfullscreenchange', (e) => {
      if (!document.mozFullScreenElement) {
        // console.log('火狐退出1111111111111')
        this.$nextTick(() => {
          setTimeout(() => {
            this.fullscreen = false
          }, 100)
        })
      } else {
        // console.log('火狐进')
      }
    })
  },
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {} // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style lang='less' scoped>
.tab3 {
  display: flex;
  padding: 50px 30px 0;
  color: #3e3e3e;
  .left {
    width: 300px;
    height: 800px;
    ul {
      margin-bottom: 20px;
      border: 1px solid #c7c7c7;
      height: 120px;
      li {
        margin-left: -1px;
        width: 300px;
        cursor: pointer;
        display: flex;
        align-items: center;
        padding-left: 20px;
        height: 40px;
        & > span {
          font-size: 40px;
          margin-right: 10px;
        }
        &:hover {
          background-color: #b9412e;
          color: #fff;
        }
      }
      .active {
        background-color: #b9412e;
        color: #fff;
      }
    }
    .search {
      position: relative;
      .btn {
        cursor: pointer;
        position: absolute;
        right: 0;
        top: 0;
        height: 40px;
        width: 40px;
        background-color: transparent;
      }
    }
  }
  .right {
    position: relative;
    justify-content: space-between;
    align-content: flex-start;
    display: flex;
    flex-wrap: wrap;
    min-width: 1200px;
    margin-left: 40px;
    flex: 1;
    height: 825px;
    .row {
      margin-bottom: 20px;
      cursor: pointer;
      width: 30%;
      text-align: center;
      & > img {
        width: 100%;
        height: 200px;
        object-fit: cover;
        border: 2px solid #b9412e;
      }
      & > p {
        margin-top: 10px;
      }
    }
    .paging {
      position: absolute;
      left: 50%;
      bottom: 0;
      transform: translateX(-50%);
    }
  }
  .model {
    position: fixed;
    top: 0;
    left: 0;
    min-width: 1000px;
    min-height: 600px;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    .ifrCon {
      border: 10px solid #fff;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 1000px;
      height: 600px;
      iframe {
        width: 100%;
        height: 100%;
      }
      .btnX {
        cursor: pointer;
        position: absolute;
        right: 10px;
        top: 10px;
        color: #fff;
        font-size: 40px;
      }
      .full {
        width: 30px;
        height: 30px;
        background: url('../../assets/img/tab3Full.png');
        background-size: 30px 30px;
        cursor: pointer;
        position: absolute;
        right: 10px;
        bottom: 10px;
        color: #fff;
      }
    }
  }
}
</style>
