|
@@ -0,0 +1,212 @@
|
|
|
+<template>
|
|
|
+ <div class="video_area">
|
|
|
+ <div
|
|
|
+ v-show="data.property.sn_position.includes('top')"
|
|
|
+ class="top"
|
|
|
+ :style="getJustifyContentStyle(data.property.sn_position)"
|
|
|
+ >
|
|
|
+ {{ data.property.serial_number }}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-show="data.property.sn_position.includes('left')"
|
|
|
+ class="left"
|
|
|
+ :style="getJustifyContentStyle(data.property.sn_position)"
|
|
|
+ >
|
|
|
+ {{ data.property.serial_number }}
|
|
|
+ </div>
|
|
|
+ <div class="main">
|
|
|
+ <ul v-if="'list' === data.property.view_method" class="view_list">
|
|
|
+ <li v-for="(file, i) in data.file_list" :key="i">
|
|
|
+ <VideoPlay
|
|
|
+ view-size="small"
|
|
|
+ view-method="list"
|
|
|
+ :file-id="file.file_id"
|
|
|
+ :cur-video-index="curVideoIndex"
|
|
|
+ @changeFile="changeFile"
|
|
|
+ />
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ <div v-if="'independent' === data.property.view_method" class="view_independent">
|
|
|
+ <el-carousel
|
|
|
+ ref="video_carousel"
|
|
|
+ indicator-position="none"
|
|
|
+ direction="vertical"
|
|
|
+ :autoplay="false"
|
|
|
+ :interval="0"
|
|
|
+ >
|
|
|
+ <el-carousel-item v-for="(file, i) in data.file_list" :key="i">
|
|
|
+ <VideoPlay
|
|
|
+ view-size="big"
|
|
|
+ :file-id="file.file_id"
|
|
|
+ :cur-video-index="curVideoIndex"
|
|
|
+ @changeFile="changeFile"
|
|
|
+ />
|
|
|
+ </el-carousel-item>
|
|
|
+ </el-carousel>
|
|
|
+ <ul class="view_independent_list">
|
|
|
+ <li v-for="(file, i) in data.file_list" :key="i" @click="handleAudioClick(i)">
|
|
|
+ <VideoPlay view-size="small" :file-id="file.file_id" :audio-index="i" :cur-video-index="curVideoIndex" />
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-show="data.property.sn_position.includes('right')"
|
|
|
+ class="right"
|
|
|
+ :style="getJustifyContentStyle(data.property.sn_position)"
|
|
|
+ >
|
|
|
+ {{ data.property.serial_number }}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-show="data.property.sn_position.includes('bottom')"
|
|
|
+ class="bottom"
|
|
|
+ :style="getJustifyContentStyle(data.property.sn_position)"
|
|
|
+ >
|
|
|
+ {{ data.property.serial_number }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getVideoData } from '@/views/book/courseware/data/video';
|
|
|
+import PreviewMixin from '../common/PreviewMixin';
|
|
|
+import VideoPlay from '../common/VideoPlay.vue';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'VideoPreview',
|
|
|
+ components: { VideoPlay },
|
|
|
+ mixins: [PreviewMixin],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ data: getVideoData(),
|
|
|
+ curVideoIndex: 0,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleAudioClick(index) {
|
|
|
+ // 获取 Carousel 实例
|
|
|
+ const carousel = this.$refs.video_carousel;
|
|
|
+ // 切换到对应索引的文件
|
|
|
+ carousel.setActiveItem(index);
|
|
|
+ this.curVideoIndex = index;
|
|
|
+ },
|
|
|
+ changeFile(type) {
|
|
|
+ // 获取 Carousel 实例
|
|
|
+ const carousel = this.$refs.video_carousel;
|
|
|
+ // 切换到对应索引的文件
|
|
|
+ if (type === 'prev') {
|
|
|
+ carousel.prev();
|
|
|
+ this.curVideoIndex += -1;
|
|
|
+ } else {
|
|
|
+ carousel.next();
|
|
|
+ this.curVideoIndex += 1;
|
|
|
+ }
|
|
|
+ if (this.curVideoIndex >= this.data.file_id_list.length) {
|
|
|
+ this.curVideoIndex = 0;
|
|
|
+ }
|
|
|
+ if (this.curVideoIndex < 0) {
|
|
|
+ this.curVideoIndex = this.data.file_id_list.length - 1;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 得到位置样式
|
|
|
+ * @param {string} position 位置
|
|
|
+ */
|
|
|
+ getJustifyContentStyle(position) {
|
|
|
+ if (position.includes('start')) {
|
|
|
+ return 'justify-content: start';
|
|
|
+ } else if (position.includes('end')) {
|
|
|
+ return 'justify-content: end';
|
|
|
+ }
|
|
|
+ return 'justify-content: center';
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.video_area {
|
|
|
+ display: grid;
|
|
|
+ grid:
|
|
|
+ 'top top top'
|
|
|
+ 'left main right'
|
|
|
+ 'bottom bottom bottom';
|
|
|
+ grid-template-columns: 1fr 28fr 1fr;
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ > div {
|
|
|
+ display: flex;
|
|
|
+ margin: 4px auto;
|
|
|
+
|
|
|
+ > span {
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .top {
|
|
|
+ grid-area: top;
|
|
|
+ width: 92%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .left {
|
|
|
+ flex-direction: column;
|
|
|
+ grid-area: left;
|
|
|
+ }
|
|
|
+
|
|
|
+ .main {
|
|
|
+ grid-area: main;
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ .view_list {
|
|
|
+ display: flex;
|
|
|
+ gap: 20px 32px;
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ > li {
|
|
|
+ width: 25%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .view_independent {
|
|
|
+ display: flex;
|
|
|
+ column-gap: 3%;
|
|
|
+ width: 100%;
|
|
|
+
|
|
|
+ :deep .el-carousel {
|
|
|
+ width: 90%;
|
|
|
+ background-color: #d9d9d9;
|
|
|
+
|
|
|
+ &__container {
|
|
|
+ height: 100%;
|
|
|
+ max-height: 500px;
|
|
|
+ padding: 2px;
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__item {
|
|
|
+ transition: none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .view_independent_list {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ row-gap: 20px;
|
|
|
+ width: 25%;
|
|
|
+ max-height: 500px;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .right {
|
|
|
+ flex-direction: column;
|
|
|
+ grid-area: right;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bottom {
|
|
|
+ grid-area: bottom;
|
|
|
+ width: 92%;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|