courseVideo.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="column">
  3. <view class="video-box" >
  4. <video id="myVideo" :src='listdetail.videoUrl' show-mute-btn='false'
  5. vslide-gesture-in-fullscreen='true' loop='true' enable-progress-gesture='true'
  6. enable-danmu controls='true' autoplay="true" object-fit='contain' show-center-play-btn='true'
  7. class="videotop" ></video>
  8. </view>
  9. <view class="title-content" id="title-content">
  10. <!-- 课程标题 -->
  11. <view >
  12. {{listdetail.title}}
  13. </view>
  14. <view class="fs24" style="color: #666;font-weight: normal;">
  15. {{listdetail.description}}
  16. </view>
  17. <view class="fs24" style="color: #999;font-weight: normal;">课程视频时长:{{formatSeconds(listdetail.duration)}}</view>
  18. </view>
  19. <!-- 问题 -->
  20. <view class="ques-content ">
  21. <view class="ques-content-tit">问答题</view>
  22. <view class="center fs32" v-if="listdetail.questionBankList!=null&&listdetail.questionBankList.length<1" style="color: #666;">暂无问答题</view>
  23. <view v-for="(item,index) in listdetail.questionBankList" :key="index">
  24. <view class="ques-title">
  25. <text>{{index + 1}}.</text>
  26. <view class="ques-type" v-show="item.type == 1 || item.type == 2">
  27. {{item.type == 1 ? '单选' : item.type == 2 ? '多选' : ''}}
  28. </view>
  29. <text >{{item.title}}</text>
  30. </view>
  31. <view :class="option.isAnswer== 1 ?'ques-option ques-option-active':'ques-option'"
  32. v-for="(option,idx) in item.question" :key="idx">
  33. <view>
  34. {{numberToLetter(idx)}}.
  35. </view>
  36. <view>{{option.name}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- <view class="footer">
  41. <view class="justify-between" >
  42. <view class="copybtn flex-1" @click="copyshareLink()">复制分享链接</view>
  43. </view>
  44. </view> -->
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. getcourseDetail
  50. } from '@/api/courseManage'
  51. import {
  52. numberToLetter
  53. } from "@/utils/tools.js"
  54. export default {
  55. data() {
  56. return {
  57. videoId:'',
  58. listdetail:[]
  59. }
  60. },
  61. onLoad(option) {
  62. this.videoId=option.videoId
  63. },
  64. onShow() {
  65. this.getdetail()
  66. },
  67. methods: {
  68. numberToLetter(num) {
  69. // 将数字转换为字母的 ASCII 码
  70. let letterCode = num + 65;
  71. // 将 ASCII 码转换为大写字母
  72. let letter = String.fromCharCode(letterCode);
  73. return letter;
  74. },
  75. //转化时间格式
  76. formatSeconds(seconds) {
  77. const hours = Math.floor(seconds / 3600);
  78. const minutes = Math.floor((seconds % 3600) / 60);
  79. const remainingSeconds = seconds % 60;
  80. // 补零函数:确保两位数显示
  81. const pad = (num) => num.toString().padStart(2, '0');
  82. return `${pad(hours)}:${pad(minutes)}:${pad(remainingSeconds)}`;
  83. },
  84. // 获取视频详情
  85. getdetail() {
  86. const param = {
  87. videoId:this.videoId
  88. }
  89. getcourseDetail(param).then(res => {
  90. if(res.code==200){
  91. this.listdetail=res.data.data
  92. this.listdetail.questionBankList= this.listdetail.questionBankList.map(item => ({
  93. ...item,
  94. question: JSON.parse(item.question),
  95. answer: '',
  96. }))
  97. }else{
  98. uni.showToast({
  99. title: res.msg,
  100. icon: 'none',
  101. });
  102. }
  103. })
  104. },
  105. copyshareLink(){
  106. console.log(123)
  107. }
  108. }
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. .video-box {
  113. width: 100%;
  114. height: 420rpx;
  115. overflow: hidden;
  116. position: relative;
  117. #myVideo {
  118. width: 100%;
  119. height: 100%;
  120. }
  121. }
  122. .title-content {
  123. padding: 20rpx 32rpx;
  124. background-color: #fff;
  125. font-size: 28rpx;
  126. font-weight: bold;
  127. line-height: 1.6;
  128. }
  129. .ques-content-tit {
  130. font-family: PingFang SC, PingFang SC;
  131. font-weight: 600;
  132. font-size: 36rpx;
  133. color: #222222;
  134. }
  135. .ques-content {
  136. background-color: #fff;
  137. margin-top: 20rpx;
  138. padding: 32rpx 32rpx;
  139. padding-bottom: 140rpx;
  140. box-sizing: border-box;
  141. ont-family: PingFang SC, PingFang SC;
  142. font-weight: 400;
  143. font-size: 28rpx;
  144. color: #222222;
  145. }
  146. .ques-title {
  147. margin: 32rpx 0 34rpx 0;
  148. font-weight: 500;
  149. font-size: 32rpx;
  150. white-space: normal;
  151. }
  152. .ques-type {
  153. flex-shrink: 0;
  154. min-width: 72rpx;
  155. height: 40rpx;
  156. padding: 0 12rpx;
  157. margin: 0 12rpx;
  158. box-sizing: border-box;
  159. background: #ff8901;
  160. border-radius: 8rpx 8rpx 8rpx 8rpx;
  161. line-height: 40rpx;
  162. text-align: center;
  163. font-family: PingFang SC, PingFang SC;
  164. font-weight: 400;
  165. font-size: 24rpx;
  166. color: #FFFFFF;
  167. display: inline-block;
  168. }
  169. .ques-option {
  170. min-height: 88rpx;
  171. padding: 24rpx 32rpx;
  172. box-sizing: border-box;
  173. margin-bottom: 24rpx;
  174. background: #F5F7FA;
  175. border-radius: 16rpx 16rpx 16rpx 16rpx;
  176. display: flex;
  177. align-items: center;
  178. &-active {
  179. color: #1db131 !important;
  180. background: #e8fcee !important;
  181. }
  182. }
  183. .footer {
  184. border-top: 1rpx solid #ededef;
  185. background: #fff;
  186. width: 100%;
  187. position: fixed;
  188. bottom: 0;
  189. padding: 24rpx 32rpx;
  190. box-sizing: border-box;
  191. z-index: 9;
  192. .copybtn {
  193. background: #FF5C03;
  194. color: #fff;
  195. text-align: center;
  196. font-size: 28rpx;
  197. border-radius: 80rpx;
  198. padding: 20rpx 0;
  199. }
  200. }
  201. </style>