<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)">
        <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" :class="[os == 'mobile' ? 'androidClass' : 'iosClass']" closeable>
        <!-- <videoPlayer v-if="videoPopup" class="ql-video" :fullscreen="isAndroid && os == 'mobile' ? false : true" :height="os == 'mobile' ? '100%' : '1.915rem'" :src="videoSrc"></videoPlayer> -->
        <videoTcplayer v-if="videoPopup" class="ql-video" :src="videoSrc"></videoTcplayer>
      </van-popup>
    </div>
  </div>
</template>

<script>
import { browser } from "@/common/common";
import MEmpty from "@/components/MEmpty";
// import videoPlayer from "@/components/video";
import videoTcplayer from "@/components/video-tcplayer";
import { queryRoomDetail } from "../api";
export default {
  components: {
    videoTcplayer,
    MEmpty,
  },
  data() {
    const query = this.$route.query;
    return {
      roomUid: query.roomUid,
      videoStatus: true,
      videoList: [],
      videoPopup: false,
      videoSrc: "",
      os: "",
    };
  },
  // props: ["videoList"],
  computed: {
    isAndroid() {
      return browser().android;
    },
  },
  mounted() {
    document.title = "视频列表";
    this.getVideoList();
  },
  methods: {
    onDetail(item) {
      this.videoPopup = true;
      this.videoSrc = item.url;
      this.os = item.os;
    },
    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%;
}

.iosClass {
  width: 90%;
}

.androidClass {
  width: 100%;
  height: 100%;
  display: flex;
  .ql-video {
    width: 100%;
  }
}
</style>
