<template>
  <div class="previewVideo">
    <div class="h2 flex-center">视频列表</div>

    <div class="video-list">
      <div
        class="video-item"
        v-for="(item, index) in videoList"
        :key="index"
        @click="onDetail(item)"
      >
        <!-- <videoPlayer
          class="ql-video video"
          height="100%"
          preload="auto"
          :playLarge="false"
          :src="`${item.url}#t=1`"
          @play="onPlay(index)"
          :ref="`video${index}`"
        ></videoPlayer> -->
        <img src="../images/video_default.png" class="video" />
        <p class="time">{{ item.createdTime }}</p>
      </div>
      <MEmpty
        v-if="!videoStatus"
        msg="暂无视频"
        style="width: 100%; margin-bottom: 0.1rem"
      />

      <van-popup v-model="videoPopup" style="width: 90%" closeable>
        <videoPlayer
          v-if="videoPopup"
          class="ql-video"
          height="1.915rem"
          :src="videoSrc"
        ></videoPlayer>
      </van-popup>
    </div>
  </div>
</template>

<script>
import MEmpty from "@/components/MEmpty";
import videoPlayer from "@/components/video";
import { queryRoomDetail } from "../api";
export default {
  components: {
    videoPlayer,
    MEmpty,
  },
  data() {
    const query = this.$route.query;
    return {
      roomUid: query.roomUid,
      videoStatus: true,
      videoList: [],
      videoPopup: false,
      videoSrc: "",
    };
  },
  // props: ["videoList"],
  mounted() {
    document.title = "视频列表";
    this.getVideoList();
  },
  methods: {
    onDetail(item) {
      this.videoPopup = true;
      this.videoSrc = item.url + "#t=1";
    },
    async getVideoList() {
      try {
        this.videoStatus = true;
        const res = await queryRoomDetail({ roomUid: this.roomUid });
        const result = res.data;
        this.videoList = result || [];
        this.videoStatus = this.videoList.length > 0;
      } catch {
        //
      }
    },
    onPlay(index) {
      // #t=1
      console.log(index, "index");
    },
  },
};
</script>

<style lang="less" scoped>
.flex-center {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
/deep/.icon_nodata {
  margin-top: 0.2rem !important;
}
.previewVideo {
  min-height: calc(100vh - 0.44rem);
  padding: 0.22rem 0.16rem;
}
.h2 {
  margin-bottom: 0.1rem;
  font-size: 0.18rem;
  font-weight: 500;
  color: #333333;
  &::before {
    display: inline-block;
    content: " ";
    width: 4px;
    height: 17px;
    background: #01c1b5;
    border-radius: 3px;
    margin-right: 0.07rem;
  }
}
.video-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}
.video-item {
  width: 48%;
  margin-bottom: 0.1rem;
  .video {
    width: 100%;
    height: 1rem;
    background: #d8d8d8;
    border-radius: 0.1rem;
    overflow: hidden;
    vertical-align: middle;
  }
  .time {
    font-size: 0.12rem;
    color: #666666;
    line-height: 0.28rem;
  }
  /deep/.plyr {
    min-width: 100%;
  }
}
</style>
