courseDetail.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="courseDetail">
  3. <video class="video" show-mute-btn enable-play-gesture page-gesture show-progress show-fullscreen-btn show-play-btn enable-progress-gesture :src="info.chapters[current].chapterUrl" :autoplay="autoplay" controls @ended="onEnd"></video>
  4. <view class="content">
  5. <view class="tab-box">
  6. <view class="tab" :class="[tab == 0?'active':'']" @click="handleTab(0)">
  7. 简介
  8. </view>
  9. <view class="tab" :class="[tab == 1?'active':'']" @click="handleTab(1)">
  10. 章节
  11. </view>
  12. </view>
  13. <view class="video-title">
  14. {{info.courseName}}
  15. </view>
  16. <view class="type-box">
  17. <view class="type">
  18. 天文课程-天眼
  19. </view>
  20. <view class="times">
  21. 10465次播放
  22. </view>
  23. </view>
  24. <view class="intro" v-show="tab == 0">
  25. <view class="intro-title">
  26. 课程简介
  27. </view>
  28. <view class="desc">
  29. {{info.courseMsg}}
  30. </view>
  31. </view>
  32. <!-- 章节 -->
  33. <view class="catalogue" v-show="tab == 1">
  34. <view class="item" v-for="(item,index) in info.chapters" :key="index" @click="handleItem(item,index)">
  35. <view class="num" :class="[current == index?'active':'']">
  36. {{index+1<10?'0'+(index+1):index+1}}
  37. </view>
  38. <view class="video-info">
  39. <view class="title" :class="[current == index?'active':'']">
  40. {{item.chapterName}}
  41. </view>
  42. <view class="info">
  43. <view class="icon-box">
  44. <image class="icon" src="../static/study/time.png" mode=""></image>
  45. <view class="text">
  46. 09:05
  47. </view>
  48. </view>
  49. <view class="icon-box">
  50. <image class="icon" src="../static/study/play-icon.png" mode=""></image>
  51. <view class="text">
  52. 09:05
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <image class="btn" :src="current == index?playIng:playBtn" mode=""></image>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {videoDetail} from '@/api/study.js'
  65. export default {
  66. data() {
  67. return {
  68. tab:0,
  69. current:0,
  70. autoplay:true,
  71. info:{
  72. chapters:[],
  73. columnId:0,
  74. courseImg:'',
  75. id:0,
  76. courseMsg:'',
  77. courseName:''
  78. },
  79. // list:[
  80. // {
  81. // title:'火箭发射',
  82. // times:'09:05',
  83. // playTimes:'1.9万',
  84. // video:'https://sns-video-bd.xhscdn.com/spectrum/01e2e095923d542a01837003823d55acab_259.mp4',
  85. // poster: 'https://gimg4.baidu.com/poster/src=http%3A%2F%2Ft15.baidu.com%2Fit%2Fu%3D4149304328%2C1810644736%26fm%3D225%26app%3D113%26f%3DJPEG%3Fw%3D1499%26h%3D843%26s%3D3352508488112DED7E265C1B03007098&refer=http%3A%2F%2Fwww.baidu.com&app=2004&size=f352,234&n=0&g=0n&q=100?sec=1703215065&t=01d1ccc946fc2cc3600627e2e1aac47f',
  86. // },
  87. // {
  88. // title:'星舰发射',
  89. // times:'09:05',
  90. // playTimes:'1.9万',
  91. // video:'http://flv0.bn.netease.com/00756cf0f624a4622e55ac120cfede7958e925f6eb2ac9a492d01cb163db2ba56e195feabfe3f2c361b91f26fbd86a4969bc4a9669f3e30eeb29cf18d8b8a4fe7727b72ddf34ad1a01d1502ca790f0f7fa40c55400983658284e046bafa6f501687a85211cd279686a278559e76f2a2b36321394c90916b4.mp4',
  92. // poster:'https://nimg.ws.126.net/?url=http%3A%2F%2Fvideoimg.ws.126.net%2Fcover%2F20231221%2FVBtFr5Y9x_cover.jpg&thumbnail=750x2147483647&quality=75&type=jpg',
  93. // }
  94. // ],
  95. playBtn:require('@/static/study/play-btn.png'),
  96. playIng:require('@/static/study/playing.png'),
  97. }
  98. },
  99. methods: {
  100. // 视频播放结束
  101. onEnd(){
  102. if(this.current != this.info.chapters.length-1){
  103. this.current ++
  104. }
  105. },
  106. handleTab(tab){
  107. this.tab = tab
  108. },
  109. handleItem(item,index){
  110. this.current = index
  111. },
  112. videoDetail(id){
  113. videoDetail({id}).then(res=>{
  114. if(res.state == 'Success'){
  115. this.info = res.content
  116. }
  117. })
  118. }
  119. },
  120. onLoad(options) {
  121. this.videoDetail(options.id)
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .courseDetail{
  127. .video{
  128. width: 100%;
  129. height: 420rpx;
  130. }
  131. .content{
  132. padding: 0 30rpx;
  133. .tab-box{
  134. display: flex;
  135. color: #222222;
  136. font-size: 28rpx;
  137. border-bottom: 1rpx solid #F0F0F0;
  138. .tab{
  139. flex: 1;
  140. padding: 20rpx 0;
  141. text-align: center;
  142. }
  143. .tab.active{
  144. font-weight: bold;
  145. position: relative;
  146. &::after{
  147. content: '';
  148. width: 40rpx;
  149. height: 8rpx;
  150. border-radius: 4rpx;
  151. background: #3879F9;
  152. position: absolute;
  153. bottom: 0%;
  154. left: 50%;
  155. transform: translateX(-50%);
  156. }
  157. }
  158. }
  159. .video-title{
  160. width: 100%;
  161. font-size: 32rpx;
  162. font-weight: bold;
  163. color: #222222;
  164. margin-top: 24rpx;
  165. display: -webkit-box;
  166. -webkit-box-orient: vertical;
  167. -webkit-line-clamp: 2; /* 显示的最大行数 */
  168. overflow: hidden;
  169. }
  170. .type-box{
  171. display: flex;
  172. justify-content: space-between;
  173. align-items: center;
  174. color: #AAAAAA;
  175. font-size: 24rpx;
  176. padding: 28rpx 0;
  177. border-bottom: 1rpx solid #F0F0F0;
  178. }
  179. .intro{
  180. .intro-title{
  181. margin: 24rpx 0;
  182. font-weight: bold;
  183. color: #222222;
  184. font-size: 28rpx;
  185. }
  186. .desc{
  187. font-size: 24rpx;
  188. font-weight: 400;
  189. color: #222222;
  190. line-height: 40rpx;
  191. }
  192. }
  193. .catalogue{
  194. .item{
  195. display: flex;
  196. align-items: center;
  197. padding: 20rpx 0;
  198. border-bottom: 1rpx solid #F0F0F0;
  199. .num.active{
  200. color: #3879F9;
  201. }
  202. .num{
  203. font-size: 28rpx;
  204. font-weight: bold;
  205. color: #AAAAAA;
  206. }
  207. .video-info{
  208. flex: 1;
  209. margin-left: 18rpx;
  210. .title.active{
  211. color: #3879F9;
  212. }
  213. .title{
  214. font-weight: bold;
  215. color: #333333;
  216. font-size: 28rpx;
  217. }
  218. .info{
  219. display: flex;
  220. align-items: center;
  221. margin-top: 12rpx;
  222. .icon-box{
  223. display: flex;
  224. align-items: flex-end;
  225. font-size: 24rpx;
  226. color: #AAAAAA;
  227. margin-right: 36rpx;
  228. .icon{
  229. width: 28rpx;
  230. height: 28rpx;
  231. }
  232. .text{
  233. margin-left: 6rpx;
  234. }
  235. }
  236. }
  237. }
  238. .btn{
  239. width: 40rpx;
  240. height: 40rpx;
  241. }
  242. }
  243. }
  244. }
  245. }
  246. </style>