123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <!--课程预览-->
- <template>
- <div class="coursePreview">
- <p class="reset-button-one" style="margin:20px 0 0 20px;font-weight:700;" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
- <div class="course-info">
- <div class="name-p">{{exerciseData.title}}</div>
- <!--<div class="item-p">{{exerciseData.title}}</div>-->
- <div class="title-p">时长:{{exerciseData.durationStr}}</div>
- <p class="num-p"></p>
- </div>
- <div class="center-info-components-max-box scrollbar-box" v-if="loading">
- <!--图片-->
- <img
- style="display: block;margin:0 auto;max-width:900px;"
- v-if="exerciseData.postfix == 'png' || exerciseData.postfix == 'jpeg' || exerciseData.postfix == 'gif'"
- :src="exerciseData.chapterData">
- <!--视频-->
- <!--<video-player-->
- <!--class="video-player vjs-custom-skin"-->
- <!--v-if="exerciseData.postfix == 'mp4' || exerciseData.postfix == 'webm'"-->
- <!--@pause="demo($event)"-->
- <!--:playsinline="true"-->
- <!--:options="playerOptions">-->
- <!--</video-player>-->
- <!--poster="@/assets/ZDimages/video_logo.jpg"-->
- <video class="video-player vjs-custom-skin"
- style="width:910px;height:512px;"
- autoplay="autoplay"
- :poster="videoCover"
- v-if="exerciseData.chapterData && exerciseData.postfix == 'mp4'">
- <source :src="exerciseData.chapterData" type="video/mp4">
- </video>
- <!--word-->
- <iframe
- class="iframe"
- v-if="exerciseData.postfix == 'pdf' || exerciseData.postfix == 'doc' || exerciseData.postfix == 'docx' || exerciseData.postfix == 'ppt' || exerciseData.postfix == 'pptx'"
- :src="exerciseData.iframeSrc" scrolling="auto" frameborder="0">
- </iframe>
- <!--富文本-->
- <div v-if="exerciseData.type == 5" v-html="exerciseData.chapterData"></div>
- </div>
- </div>
- </template>
- <script>
- import { videoPlayer } from 'vue-video-player'
- export default {
- name: 'coursePreview',
- props:{
- exerciseData:{},
- },
- components:{
- videoPlayer
- },
- data() {
- return {
- videoCover:window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + localStorage.getItem('videoCover'),
- loading:false,
- playerOptions: {
- playbackRates: [0.5, 1.0, 1.5, 2.0], // 可选的播放速度
- autoplay: false, // 如果为true,浏览器准备好时开始回放。
- muted: false, // 默认情况下将会消除任何音频。
- loop: false, // 是否视频一结束就重新开始。
- preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
- language: 'zh-CN',
- aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
- fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
- sources: [],
- poster: '', // 封面地址
- notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
- controlBar: {
- timeDivider: true, // 当前时间和持续时间的分隔符
- durationDisplay: true, // 显示持续时间
- remainingTimeDisplay: false, // 是否显示剩余时间功能
- fullscreenToggle: true // 是否显示全屏按钮
- }
- },
- }
- },
- created() {
- },
- mounted() {
- let self = this;
- setTimeout(function(){
- self.judgeFunction();
- },500);
- },
- methods: {
- //返回
- backPage(){
- this.$parent.goPage(1);
- },
- judgeFunction(){
- if(this.exerciseData.postfix == "mp4"){
- console.log("视频")
- // this.getVideo();
- this.loading = true;
- }else if(this.exerciseData.postfix == "pdf" || this.exerciseData.postfix == "doc" || this.exerciseData.postfix == "docx"||this.exerciseData.postfix == "ppt" || this.exerciseData.postfix == "pptx"){
- console.log("文档")
- this.getWord();
- }else if(this.exerciseData.type == 5){
- console.log("富文本")
- this.getRichText();
- }
- },
- //富文本处理
- getRichText(){
- this.exerciseData.chapterData = unescape(this.exerciseData.chapterData)
- this.loading = true;
- },
- //视频处理
- getVideo(){
- let list = [];
- let obj = {
- type:'video/'+this.exerciseData.postfix,
- src:this.exerciseData.chapterData,
- };
- list.push(obj);
- this.playerOptions.sources = list;
- this.loading = true;
- },
- //word处理
- async getWord(){
- this.exerciseData.iframeSrc = this.urlJudge(this.exerciseData.chapterData)
- this.loading = true;
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .coursePreview{
- flex:1;
- display: flex;
- flex-direction: column;
- overflow-y: scroll;
- *{
- margin:0;
- padding:0;
- font-weight:500;
- color:#333;
- }
- .course-info{
- .name-p{
- color:#333;
- font-size:18px;
- line-height:30px;
- font-weight:700;
- margin:10px 40px 0;
- }
- .item-p{
- color:#333;
- font-size:18px;
- line-height:30px;
- margin:0 40px;
- }
- .title-p{
- color:#333;
- font-size:18px;
- line-height:30px;
- margin:0 40px 10px;
- }
- .num-p{
- border-bottom:3px dashed #dedede;
- }
- }
- .center-info-components-max-box{
- margin:20px;
- overflow-y: scroll;
- flex:1;
- display: flex;
- flex-direction: column;
- position: relative;
- .video-player{
- position: absolute;
- top:50%;
- left:50%;
- margin-top:-315px;
- margin-left:-560px;
- height:630px;
- width: 1120px;
- }
- iframe{
- flex:1;
- }
- }
- }
- </style>
|