freeVideo.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="page">
  3. <van-nav-bar
  4. :title="title"
  5. left-text="返回"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. ></van-nav-bar>
  9. <div class="courseContent">
  10. <div class="previewImg">
  11. <video ref="vueMiniPlayer" :src="videoSrc" controls autoplay v-if="showVideo" controlsList="nodownload"></video>
  12. </div>
  13. <div class="title">
  14. <p>{{ video_info.name }}</p>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import {learnerCourseDetail,getFreeVideoSrc} from '../api'
  21. export default {
  22. name: "video",
  23. data() {
  24. return {
  25. video_info:{
  26. name:'免费课程'
  27. },
  28. showVideo:true,
  29. title: "免费课程",
  30. videoSrc:"",
  31. courseDetail: {
  32. thumb: "",
  33. name: "",
  34. images: [],
  35. sections: []
  36. }
  37. };
  38. },
  39. watch:{
  40. videoSrc(){
  41. this.showVideo = false;
  42. this.$nextTick(()=>{
  43. this.showVideo = true;
  44. this.$nextTick(()=>{
  45. this.$refs.vueMiniPlayer.play();//播放
  46. })
  47. })
  48. }
  49. },
  50. created() {
  51. this.init();
  52. },
  53. methods: {
  54. // 章节切换获取视频地址
  55. toSectionVidio(item,i) {
  56. this.courseDetail.sections.forEach((item,index)=>{
  57. item.active = false;
  58. if(index == i){
  59. item.active = true;
  60. }
  61. })
  62. let data = {
  63. index: i,
  64. link: item.link
  65. };
  66. sessionStorage.setItem('vd_info',JSON.stringify(data))
  67. this.getVideoLink(item.link)
  68. // this.videoSrc = this.courseDetail.sections[index].link
  69. },
  70. // 获取视频地址
  71. getVideoLink(link){
  72. let data = {
  73. subjectId:this.$route.params.id,
  74. link:link
  75. }
  76. getFreeVideoSrc(data).then(res=>{
  77. this.videoSrc = res
  78. }).catch(err=>{
  79. this.$router.push('/courseError')
  80. })
  81. },
  82. // 返回
  83. onClickLeft() {
  84. this.$router.go(-1);
  85. },
  86. // 初始化
  87. init() {
  88. if(this.$route.query){
  89. this.video_info = this.$route.query;
  90. this.getVideoLink(this.video_info.link)
  91. }else{
  92. this.$toast.fail('视频似乎有点问题')
  93. setTimeout(() => {
  94. this.$router.go(-1)
  95. }, 2000);
  96. }
  97. },
  98. },
  99. };
  100. </script>
  101. <style scoped lang="scss">
  102. @import url('../utils/navBar.scss');
  103. * {
  104. margin: 0;
  105. padding: 0;
  106. }
  107. img {
  108. display: block;
  109. }
  110. .page {
  111. background-color: #fff;
  112. box-sizing: border-box;
  113. .courseContent {
  114. padding: 0 0.2rem;
  115. margin-top: 0.3rem;
  116. .previewImg {
  117. border-radius: 0.1rem;
  118. overflow: hidden;
  119. width: 100%;
  120. height: 4rem;
  121. video {
  122. width: 100%;
  123. height: 4rem;
  124. }
  125. }
  126. .title {
  127. p {
  128. font-size: 0.32rem;
  129. font-weight: 600;
  130. color: #000;
  131. line-height: 1rem;
  132. overflow: hidden;
  133. text-overflow: ellipsis;
  134. white-space: nowrap;
  135. word-break: break-all;
  136. }
  137. }
  138. .tabs {
  139. height: calc(100vh - 6.25rem);
  140. position: relative;
  141. .images {
  142. margin-top: 0.1rem;
  143. img {
  144. width: 100%;
  145. }
  146. }
  147. .catelog {
  148. margin-top: 1px;
  149. border-top: 1px solid #efefef;
  150. .sup {
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: center;
  154. span {
  155. font-size: 0.24rem;
  156. color: #666;
  157. line-height: 3;
  158. }
  159. }
  160. .logConetent {
  161. .logLi {
  162. border: 1px solid #efefef;
  163. border-radius: 0.1rem;
  164. padding: 0 0.2rem;
  165. margin-bottom: 0.15rem;
  166. p {
  167. padding: .2rem 0;
  168. font-size: 0.3rem;
  169. color: #000;
  170. line-height: 1.3;
  171. // overflow: hidden;
  172. // text-overflow: ellipsis;
  173. // white-space: nowrap;
  174. // word-break: break-all;
  175. }
  176. &.active{
  177. box-shadow: 1px 4px #ddd;
  178. p{
  179. color: #26A2FF;
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. .getCourse {
  188. position: absolute;
  189. bottom: 0.1rem;
  190. left: 0.1rem;
  191. width: calc(100% - 0.2rem);
  192. .getBtn {
  193. width: 100%;
  194. background-color: #26A2FF;
  195. color: #fff;
  196. // animation: getFire 3s infinite linear;
  197. border-radius: .1rem;
  198. }
  199. }
  200. }
  201. @keyframes getFire {
  202. 0% {
  203. transform: scale(0.95);
  204. }
  205. 100% {
  206. transform: scale(1.05);
  207. }
  208. }
  209. </style>