<template>
  <div class="Bottom">
    <div class="box1">
      <!-- 航拍 -->
      <div :class="{ acShow: towAc === 1 }">
        <div class="swiper-container swiper-container1">
          <div class="swiper-wrapper">
            <div class="swiper-slide">
              <div
                v-for="(item, index) in data1_1"
                :key="index"
                :class="{ active: oneAc === item.code, sm: item.sm }"
                @click="cutVr(item)"
              >
                <img src="../assets/img/demo.png" alt="" />
                <p>{{ item.name + index }}</p>
              </div>
            </div>
            <div class="swiper-slide">
              <div
                v-for="(item, index) in data1_2"
                :key="index"
                :class="{ active: oneAc === item.code, sm: item.sm }"
                @click="cutVr(item)"
              >
                <img src="../assets/img/demo2.png" alt="" />
                <p>{{ item.name + index }}</p>
              </div>
            </div>
          </div>
        </div>
        <div class="swiper-button-next swiper-button-next1"></div>
        <div class="swiper-button-prev swiper-button-prev1"></div>
      </div>

      <!-- 地面全景 -->
      <div :class="{ acShow: towAc === 2 }">
        <div class="swiper-container swiper-container2">
          <div class="swiper-wrapper">
            <div class="swiper-slide">
              <div
                v-for="(item, index) in data2_1"
                :key="index"
                :class="{ active: oneAc === item.code, sm: item.sm }"
                @click="cutVr(item)"
              >
                <img src="../assets/img/demo.png" alt="" />
                <p>{{ item.name + index }}</p>
              </div>
            </div>
            <div class="swiper-slide">
              <div
                v-for="(item, index) in data2_2"
                :key="index"
                :class="{ active: oneAc === item.code, sm: item.sm }"
                @click="cutVr(item)"
              >
                <img src="../assets/img/demo2.png" alt="" />
                <p>{{ item.name + index }}</p>
              </div>
            </div>
          </div>
        </div>
        <div class="swiper-button-next swiper-button-next2"></div>
        <div class="swiper-button-prev swiper-button-prev2"></div>
      </div>

      <!-- 室内导览 -->
      <div :class="{ acShow: towAc === 3 }">
        <div class="swiper-container swiper-container3">
          <div class="swiper-wrapper">
            <div class="swiper-slide">
              <div
                v-for="(item, index) in data3_1"
                :key="index"
                :class="{ active: oneAc2 === item.code, sm: item.sm }"
                @click="cutVr2(item)"
              >
                <img src="../assets/img/demo.png" alt="" />
                <p>{{ item.name }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="box2">
      <div :class="{ active: towAc === 1 }" @click="towAc = 1">航拍</div>
      <img src="../assets/img/fenge.png" alt="" />
      <div :class="{ active: towAc === 2 }" @click="towAc = 2">地面全景</div>
      <img src="../assets/img/fenge.png" alt="" />
      <div :class="{ active: towAc === 3 }" @click="towAc = 3">室内导览</div>
    </div>
  </div>
</template>

<script>
import Swiper from "@/assets/swiper/swiper.js";
export default {
  name: "Bottom",
  components: {},
  data() {
    return {
      oneAc: "aa",
      oneAc2: "",
      towAc: 1,
      data1_1: [
        { sm: true, name: "航拍全景1_", code: "aa", ind: 0 },
        { name: "航拍全景1_", code: "bb", ind: 0 },
        { name: "航拍全景1_", code: "cc", ind: 0 },
        { name: "航拍全景1_", code: "", ind: 0 },
        { name: "航拍全景1_", code: "", ind: 0 },
        { sm: true, name: "航拍全景1_", code: "", ind: 0 },
      ],
      data1_2: [
        { sm: true, name: "航拍全景2_", code: "", ind: 0 },
        { name: "航拍全景2_", code: "", ind: 0 },
        { name: "航拍全景2_", code: "", ind: 0 },
        { name: "航拍全景2_", code: "", ind: 0 },
        { name: "航拍全景2_", code: "", ind: 0 },
        { sm: true, name: "航拍全景2_", code: "", ind: 0 },
      ],
      data2_1: [
        { sm: true, name: "地面全景1_", code: "aaa", ind: 0 },
        { name: "地面全景1_", code: "bb", ind: 0 },
        { name: "地面全景1_", code: "cc", ind: 0 },
        { name: "地面全景1_", code: "", ind: 0 },
        { name: "地面全景1_", code: "", ind: 0 },
        { sm: true, name: "地面全景1_", code: "", ind: 0 },
      ],
      data2_2: [
        { sm: true, name: "地面全景2_", code: "aaaa", ind: 0 },
        { name: "地面全景2_", code: "bb", ind: 0 },
        { name: "地面全景2_", code: "cc", ind: 0 },
        { name: "地面全景2_", code: "", ind: 0 },
        { name: "地面全景2_", code: "", ind: 0 },
        { sm: true, name: "地面全景2_", code: "", ind: 0 },
      ],
      data3_1: [
        { name: "第一展厅", code: "111", ind: 0 },
        { name: "第二展厅", code: "222", ind: 0 },
      ],
    };
  },
  computed: {},
  methods: {
    // 切换VR
    cutVr(item) {
      this.oneAc = item.code;
      this.oneAc2 = null;
      this.$emit("zhanChange", item.code);
    },
    cutVr2(item) {
      this.oneAc2 = item.code;
      this.$emit("zhanChange", item.code);
    },
  },
  watch: {
    towAc(val) {
      // 控制底部容器大小
      this.$emit("botWidth", val);
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.$nextTick(() => {
      new Swiper(".box1 .swiper-container1", {
        navigation: {
          nextEl: ".swiper-button-next1",
          prevEl: ".swiper-button-prev1",
        },
        slidesPerView: 1,
        spaceBetween: 0,
      });
      new Swiper(".box1 .swiper-container2", {
        navigation: {
          nextEl: ".swiper-button-next2",
          prevEl: ".swiper-button-prev2",
        },
        slidesPerView: 1,
        spaceBetween: 0,
      });
      new Swiper(".box1 .swiper-container3", {
        slidesPerView: 1,
        spaceBetween: 0,
      });
    });
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less' scoped>
@import "../assets/swiper/swiper.css";
.Bottom {
  width: 100%;
  height: 100%;
  .box1 {
    position: relative;
    width: 100%;
    height: 152px;
    margin-bottom: 4px;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 60px 60px 0 0;
    & > div {
      padding: 8px 50px 5px 50px;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      pointer-events: none;
      width: 100%;
      height: 100%;
    }
    .acShow {
      opacity: 1;
      pointer-events: auto;
    }
    .swiper-container {
      width: 100%;
      height: 100%;
      .swiper-slide {
        display: flex;
        & > div {
          border-radius: 20px;
          overflow: hidden;
          position: relative;
          cursor: pointer;
          margin-right: 12px;
          width: 209px;
          height: 100%;
          &:nth-of-type(6) {
            margin-right: 0;
          }
          & > p {
            transition: all 0.3s;
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30px;
            line-height: 30px;
            text-align: center;
            background-color: rgba(0, 0, 0, 0.6);
            font-size: 14px;
            color: #fff;
          }
          & > img {
            width: 100%;
            height: 100%;
            object-fit: cover;
          }
          &:hover {
            & > p {
              background-color: rgba(181, 147, 134, 0.8);
            }
          }
        }
        .active {
          pointer-events: none;
          & > p {
            background-color: rgba(181, 147, 134, 0.8);
          }
        }
        .sm {
          width: 170px;
        }
      }
    }
    .swiper-button-next {
      color: #b59386;
    }
    .swiper-button-prev {
      color: #b59386;
    }
  }
  .box2 {
    background-color: rgba(0, 0, 0, 0.8);
    width: 100%;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    & > img {
      margin: 0 32px;
      width: 2px;
      height: 40px;
    }
    & > div {
      cursor: pointer;
      font-size: 22px;
      color: #fff;
      padding-bottom: 5px;
      &:hover {
        padding-top: 2px;
        color: #b59386;
        border-bottom: 2px solid #b59386;
      }
    }
    .active {
      padding-top: 2px;
      pointer-events: none;
      color: #b59386;
      border-bottom: 2px solid #b59386;
    }
  }
}
</style>