<style scoped>
#player-con {
  width: 100%;
  height: 500px;
  background-color: #eee;
}
.no-video {
  width: 800px;
  height: 450px;
  margin: 0 auto;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 30px;
}
.title {
  color: #000000;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 20px;
}
.scheduInfo {
  height: 100%;
  width: 100%;
  padding: 15px;
  background-color: #f2f4f7;
  overflow: hidden;
}

.scheduInfo .schedu_left {
  width: 248px;
  flex: 0 0 auto;
  position: relative;
  background-image: url(../../assets/images/sched_bg.png);
  background-repeat: no-repeat;
  background-size: 100% auto;
  height: 100%;
}

.scheduInfo .okr-menu-active {
  color: var(--q-color-primary);
  font-weight: bold;
  background: #ecf1ff;
}

.mySched {
  border-radius: 8px;
  overflow: hidden;
  height: 100%;
  background-color: #fff;
}

.schedu_ImgDiv {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  overflow: hidden;
  margin: 75px auto 0;
}

.schedu_ImgDiv img {
  width: 100%;
  height: 100%;
}

.schedu_Name {
  color: #fff;
  font-size: 16px;
  margin-top: 26px;
  text-align: center;
}

.schedu_Status {
  font-size: 12px;
  color: #fff;
  text-align: center;
  margin-top: 15px;
}

.schedu_st {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  position: relative;
  top: 1px;
}

.zbz {
  background-color: #00db4e;
}

.xxz {
  background-color: #dbdbdb;
}

.wdk {
  background-color: #fe4475;
}

.clockon_Duty {
  width: 120px;
  height: 34px;
  background: linear-gradient(90deg, #00bdd3, #00d761);
  border-radius: 10px;
  margin: 100px auto 24px;
  text-align: center;
  line-height: 31px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.sche_daka {
  font-size: 18px;
  position: relative;
  left: 5px;
  top: 2px;
}

.schedu_jiaojie {
  width: 120px;
  height: 34px;
  line-height: 34px;
  text-align: center;
  border-radius: 10px;
  border: 1px solid #91aeff;
  color: #c4d4ff;
  font-size: 14px;
  margin: auto;
  cursor: pointer;
}

.scheInfo_rightTop {
  width: 100%;
  /* height: 80px; */
  padding: 20px 0;
  background-color: #fff;
}

.schScroll {
  background-color: #f6f8fa;
}

.scheInfo_Topflex {
  display: flex;
  /* width: 90%; */
  /* height: 80px; */
  align-items: center;
}

.Sctop_Color {
  font-size: 18px;
  color: #000000;
  width: 246px;
  text-align: center;
}

.Scotop_little {
  color: #aaaaaa;
  font-size: 14px;
  margin-right: 15px;
  display: inline-block;
  text-align: right;
  width: 60px;
}

.Scdu_benci::after {
  content: "";
  position: absolute;
  height: 29px;
  width: 2px;
  background: #ebebeb;
  right: 0;
}

.sche_mid {
  display: flex;
  width: 100%;
  justify-content: space-between;
}

.sche_midList {
  width: 31.6%;
  height: 300px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #ebebeb;
  box-shadow: 0px 1px 1px 0px #e4e7fb;
  overflow: hidden;
  font-family: "MicrosoftYaHei";
  position: relative;
}

.Sche_Bottom {
  margin: 26px 40px 0 40px;
}

.scheList_TOP {
  width: 100%;
  height: 107px;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

.scheList_TOP img {
  width: 100%;
  height: 100%;
}

.word_sche {
  color: #fff;
  font-size: 20px;
  position: absolute;
  top: 25px;
  left: 32px;
}

.word_scheNumber {
  display: inline-block;
  width: 36px;
  height: 36px;
  color: #fff;
  background-color: #fe4475;
  position: absolute;
  top: 30px;
  left: 130px;
  text-align: center;
  line-height: 36px;
  border-radius: 8px;
  font-size: 25px;
}

.scheList_Bottom {
  font-size: 14px;
  color: #000000;
  height: 46px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f3f3f3;
}

.sche_Dian {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #6d97ff;
  border-radius: 50%;
  margin-right: 10px;
}

.schScroll::-webkit-scrollbar {
  display: none;
}

.Sch_MainColor {
  font-size: 18px;
  color: #000000;
}
</style>

<template>
  <div class="scheduInfo">
    <div class="flex row mySched">
      <div class="col scroll schScroll">
        <schedulHead :dataList="dataList"></schedulHead>
        <div class="Sche_Bottom">
          <div class="title">课程录像</div>
          <div class="no-video" v-if="!dataList.VideoUrl">暂无视频</div>
          <div id="player-con" v-if="dataList.VideoUrl"></div>
          <schedulVisit :tabledata="dataList.GuestList"></schedulVisit>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getTimeDetail } from "../../api/classroom/index";
import { getVideoPlayAuth, getVideoPlayUrl } from "../../api/classroom/video";
import schedulVisit from "./components/schedul-visit";
import schedulHead from "./components/schedul-head";

export default {
  props: {},
  components: {
    schedulVisit,
    schedulHead
  },
  data() {
    return {
      dataList: {},
      player: null
    };
  },
  created() {
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
    }
  },
  mounted() {
    this.getdata();
  },
  methods: {
    getdata() {
      getTimeDetail({ ID: this.id }).then(res => {
        if (res.Code === 1) {
          this.dataList = res.Data;
          if (res.Data.VideoUrl) {
            this.getAuth(res.Data.VideoUrl);
            // this.$nextTick(() => {
            //   this.initPlayer(res.Data.VideoUrl);
            // });
          }
        }
      });
    },
    //初始化视频播放器
    initPlayer(url, cover, auth) {
      this.player = new Aliplayer(
        {
          id: "player-con",
          source: url,
          width: "100%",
          height: "500px",
          autoplay: false,
          isLive: false,
          rePlay: false,
          playsinline: true,
          preload: true,
          controlBarVisibility: "hover",
          useH5Prism: true,
          cover: cover,
          playauth: auth
        },
        function(player) {}
      );
    },
    getAuth(url) {
      getVideoPlayAuth({ strVid: url }).then(res => {
        if (res.Code === 1 && res.Data.PlayAuth) {
          this.getUrl(url, res.Data.PlayAuth);
        }
      });
    },
    getUrl(url, auth) {
      getVideoPlayUrl({ strVid: url }).then(res => {
        if (res.Code === 1) {
          this.initPlayer(res.Data.URL, res.Data.VideoImg, auth);
        }
      });
    }
  }
};
</script>
