<template>
  <div class="three">
    <div class="comTit">
      <img src="../assets/img/comBs1.png" alt="" />
      <span>{{ tit }}</span>
      <img src="../assets/img/comBs2.png" alt="" />
    </div>
    <div class="swBox" :class="{ opcBase: conShowLoad }">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div
            class="swiper-slide swiperVideo"
            v-for="item in data.videos"
            :key="item.id"
            @click="$emit('openLook', baseURL + item.filePath, 'video')"
          >
            <!-- 视频 -->
            <div class="videoName">
              <p>{{ item.name }}</p>
              <div class="videoPlay">
                <img src="../assets/img/videoPlay.png" alt="" />
              </div>
            </div>
            <video :src="baseURL + item.filePath"></video>
          </div>

          <!-- 图片 -->
          <div
            class="swiper-slide"
            @click="$emit('openLook', baseURL + item.filePath, 'img')"
            v-for="item in data.images"
            :key="item.id"
          >
            <img :src="baseURL + item.filePath" alt="" />
          </div>
        </div>
      </div>
    </div>
    <div
      class="main"
      v-html="data.content"
      :class="{ opcBase: conShowLoad }"
    ></div>
    <!-- 数据加载中 -->
    <div class="conShowLoad" v-show="conShowLoad">
      <img src="../assets/img/loading.gif" alt="" />
    </div>
  </div>
</template>

<script>
import Swiper from "@/assets/swiper/swiper.js";
import axios from "@/utils/request";
export default {
  name: "three",
  props: {
    tit: {
      type: String,
    },
    data: {
      type: Object,
      default: () => {},
    },
  },
  components: {},
  data() {
    //这里存放数据
    return {
      conShowLoad: true,
      baseURL: "",
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    // 获取服务器前缀地址
    this.baseURL = axios.defaults.baseURL;
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        new Swiper(".three .swiper-container", {
          slidesPerView: 1.4,
          spaceBetween: 10,
        });
        this.conShowLoad = false;
      }, 1000);
    });
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less' scoped>
@import "../assets/swiper/swiper.css";
.three {
  position: relative;
  width: 100%;
  height: 100%;
  .main {
    letter-spacing: 1px;
    color: #8a7351;
    line-height: 24px;
    font-size: 14px;
    padding: 0 12px 0 20px;
    width: 100%;
    height: calc(100% - 320px);
    overflow-y: auto;
    margin-top: 20px;
  }
  .swBox {
    width: 100%;
    height: 170px;
    .swiper-container {
      width: calc(100% - 40px);
      margin: 0 auto;
      height: 170px;
    }
    .swiper-slide {
      width: 100%;
      height: 100%;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      video {
        z-index: -1;
        // width: 100%;
        height: 100%;
      }
    }
    .swiperVideo {
      overflow: hidden;
      position: relative;
      width: 100%;
      height: 100%;
      .videoName {
        position: absolute;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.3);
        top: 0px;
        left: 0px;
        color: #fff;
        font-size: 14px;
      }
    }
  }
}
</style>