coursePreview.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <!--课程预览-->
  2. <template>
  3. <div class="coursePreview">
  4. <p class="reset-button-one" style="margin:20px 0 0 20px;font-weight:700;" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
  5. <div class="course-info">
  6. <div class="name-p">{{exerciseData.title}}</div>
  7. <!--<div class="item-p">{{exerciseData.title}}</div>-->
  8. <div class="title-p">时长:{{exerciseData.durationStr}}</div>
  9. <p class="num-p"></p>
  10. </div>
  11. <div class="center-info-components-max-box scrollbar-box" v-if="loading">
  12. <!--图片-->
  13. <img
  14. style="display: block;margin:0 auto;max-width:900px;"
  15. v-if="exerciseData.postfix == 'png' || exerciseData.postfix == 'jpeg' || exerciseData.postfix == 'gif'"
  16. :src="exerciseData.chapterData">
  17. <!--视频-->
  18. <!--<video-player-->
  19. <!--class="video-player vjs-custom-skin"-->
  20. <!--v-if="exerciseData.postfix == 'mp4' || exerciseData.postfix == 'webm'"-->
  21. <!--@pause="demo($event)"-->
  22. <!--:playsinline="true"-->
  23. <!--:options="playerOptions">-->
  24. <!--</video-player>-->
  25. <!--poster="@/assets/ZDimages/video_logo.jpg"-->
  26. <video class="video-player vjs-custom-skin"
  27. style="width:910px;height:512px;"
  28. autoplay="autoplay"
  29. :poster="videoCover"
  30. v-if="exerciseData.chapterData && exerciseData.postfix == 'mp4'">
  31. <source :src="exerciseData.chapterData" type="video/mp4">
  32. </video>
  33. <!--word-->
  34. <iframe
  35. class="iframe"
  36. v-if="exerciseData.postfix == 'pdf' || exerciseData.postfix == 'doc' || exerciseData.postfix == 'docx' || exerciseData.postfix == 'ppt' || exerciseData.postfix == 'pptx'"
  37. :src="exerciseData.iframeSrc" scrolling="auto" frameborder="0">
  38. </iframe>
  39. <!--富文本-->
  40. <div v-if="exerciseData.type == 5" v-html="exerciseData.chapterData"></div>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import { videoPlayer } from 'vue-video-player'
  46. export default {
  47. name: 'coursePreview',
  48. props:{
  49. exerciseData:{},
  50. },
  51. components:{
  52. videoPlayer
  53. },
  54. data() {
  55. return {
  56. videoCover:window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + localStorage.getItem('videoCover'),
  57. loading:false,
  58. playerOptions: {
  59. playbackRates: [0.5, 1.0, 1.5, 2.0], // 可选的播放速度
  60. autoplay: false, // 如果为true,浏览器准备好时开始回放。
  61. muted: false, // 默认情况下将会消除任何音频。
  62. loop: false, // 是否视频一结束就重新开始。
  63. preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  64. language: 'zh-CN',
  65. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  66. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  67. sources: [],
  68. poster: '', // 封面地址
  69. notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  70. controlBar: {
  71. timeDivider: true, // 当前时间和持续时间的分隔符
  72. durationDisplay: true, // 显示持续时间
  73. remainingTimeDisplay: false, // 是否显示剩余时间功能
  74. fullscreenToggle: true // 是否显示全屏按钮
  75. }
  76. },
  77. }
  78. },
  79. created() {
  80. },
  81. mounted() {
  82. let self = this;
  83. setTimeout(function(){
  84. self.judgeFunction();
  85. },500);
  86. },
  87. methods: {
  88. //返回
  89. backPage(){
  90. this.$parent.goPage(1);
  91. },
  92. judgeFunction(){
  93. if(this.exerciseData.postfix == "mp4"){
  94. console.log("视频")
  95. // this.getVideo();
  96. this.loading = true;
  97. }else if(this.exerciseData.postfix == "pdf" || this.exerciseData.postfix == "doc" || this.exerciseData.postfix == "docx"||this.exerciseData.postfix == "ppt" || this.exerciseData.postfix == "pptx"){
  98. console.log("文档")
  99. this.getWord();
  100. }else if(this.exerciseData.type == 5){
  101. console.log("富文本")
  102. this.getRichText();
  103. }
  104. },
  105. //富文本处理
  106. getRichText(){
  107. this.exerciseData.chapterData = unescape(this.exerciseData.chapterData)
  108. this.loading = true;
  109. },
  110. //视频处理
  111. getVideo(){
  112. let list = [];
  113. let obj = {
  114. type:'video/'+this.exerciseData.postfix,
  115. src:this.exerciseData.chapterData,
  116. };
  117. list.push(obj);
  118. this.playerOptions.sources = list;
  119. this.loading = true;
  120. },
  121. //word处理
  122. async getWord(){
  123. this.exerciseData.iframeSrc = this.urlJudge(this.exerciseData.chapterData)
  124. this.loading = true;
  125. },
  126. }
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. .coursePreview{
  131. flex:1;
  132. display: flex;
  133. flex-direction: column;
  134. overflow-y: scroll;
  135. *{
  136. margin:0;
  137. padding:0;
  138. font-weight:500;
  139. color:#333;
  140. }
  141. .course-info{
  142. .name-p{
  143. color:#333;
  144. font-size:18px;
  145. line-height:30px;
  146. font-weight:700;
  147. margin:10px 40px 0;
  148. }
  149. .item-p{
  150. color:#333;
  151. font-size:18px;
  152. line-height:30px;
  153. margin:0 40px;
  154. }
  155. .title-p{
  156. color:#333;
  157. font-size:18px;
  158. line-height:30px;
  159. margin:0 40px 10px;
  160. }
  161. .num-p{
  162. border-bottom:3px dashed #dedede;
  163. }
  164. }
  165. .center-info-components-max-box{
  166. margin:20px;
  167. overflow-y: scroll;
  168. flex:1;
  169. display: flex;
  170. flex-direction: column;
  171. position: relative;
  172. .video-player{
  173. position: absolute;
  174. top:50%;
  175. left:50%;
  176. margin-top:-315px;
  177. margin-left:-560px;
  178. height:630px;
  179. width: 1120px;
  180. }
  181. iframe{
  182. flex:1;
  183. }
  184. }
  185. }
  186. </style>