courseVideo.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.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 mr40" @click="buildimg">生成海报</view> -->
  43. <view class="copybtn flex-1" @click="copyshareLink()">复制分享链接</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. getcourseDetail,
  51. sharecourselink
  52. } from '@/api/courseManage'
  53. import {
  54. numberToLetter
  55. } from "@/utils/tools.js"
  56. export default {
  57. data() {
  58. return {
  59. videoId:'',
  60. listdetail:[],
  61. user:{},
  62. copylink:''
  63. }
  64. },
  65. onLoad(option) {
  66. this.videoId=option.videoId
  67. },
  68. onShow() {
  69. this.getdetail()
  70. this.user = uni.getStorageSync("companyUserInfo") ? JSON.parse(uni.getStorageSync("companyUserInfo")) : {}
  71. },
  72. methods: {
  73. numberToLetter(num) {
  74. // 将数字转换为字母的 ASCII 码
  75. let letterCode = num + 65;
  76. // 将 ASCII 码转换为大写字母
  77. let letter = String.fromCharCode(letterCode);
  78. return letter;
  79. },
  80. //转化时间格式
  81. formatSeconds(seconds) {
  82. const hours = Math.floor(seconds / 3600);
  83. const minutes = Math.floor((seconds % 3600) / 60);
  84. const remainingSeconds = seconds % 60;
  85. // 补零函数:确保两位数显示
  86. const pad = (num) => num.toString().padStart(2, '0');
  87. return `${pad(hours)}:${pad(minutes)}:${pad(remainingSeconds)}`;
  88. },
  89. // 获取视频详情
  90. getdetail() {
  91. const param = {
  92. videoId:this.videoId
  93. }
  94. getcourseDetail(param).then(res => {
  95. if(res.code==200){
  96. this.listdetail=res.data
  97. this.listdetail.questionBankList= this.listdetail.questionBankList.map(item => ({
  98. ...item,
  99. question: JSON.parse(item.question),
  100. answer: '',
  101. }))
  102. }else{
  103. uni.showToast({
  104. title: res.msg,
  105. icon: 'none',
  106. });
  107. }
  108. })
  109. },
  110. copyshareLink(){
  111. const params = {
  112. companyId: this.user.companyId,
  113. companyUserId: this.user.userId,
  114. courseId: this.listdetail.courseId,
  115. time: this.time,
  116. videoId: this.listdetail.videoId,
  117. }
  118. sharecourselink(params).then(res => {
  119. if (res.code == 200) {
  120. this.copylink = res.url
  121. // if (this.copylink.startsWith('http://')) {
  122. // this.copylink = this.copylink.replace('http://', 'https://');
  123. // }
  124. // console.log(this.copylink)
  125. setTimeout(() => {
  126. uni.setClipboardData({
  127. data: this.copylink,
  128. success: () => {
  129. uni.showToast({
  130. title: '链接已复制',
  131. icon: 'none',
  132. duration: 2000
  133. });
  134. },
  135. fail: () => {
  136. uni.showToast({
  137. title: '复制失败',
  138. icon: 'none'
  139. });
  140. }
  141. });
  142. }, 100)
  143. console.log(this.copylink)
  144. } else {
  145. uni.showToast({
  146. icon: 'none',
  147. title: res.msg
  148. })
  149. }
  150. })
  151. console.log(123)
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .video-box {
  158. width: 100%;
  159. height: 420rpx;
  160. overflow: hidden;
  161. position: relative;
  162. #myVideo {
  163. width: 100%;
  164. height: 100%;
  165. }
  166. }
  167. .title-content {
  168. padding: 20rpx 32rpx;
  169. background-color: #fff;
  170. font-size: 28rpx;
  171. font-weight: bold;
  172. line-height: 1.6;
  173. }
  174. .ques-content-tit {
  175. font-family: PingFang SC, PingFang SC;
  176. font-weight: 600;
  177. font-size: 36rpx;
  178. color: #222222;
  179. }
  180. .ques-content {
  181. background-color: #fff;
  182. margin-top: 20rpx;
  183. padding: 32rpx 32rpx;
  184. padding-bottom: 140rpx;
  185. box-sizing: border-box;
  186. ont-family: PingFang SC, PingFang SC;
  187. font-weight: 400;
  188. font-size: 28rpx;
  189. color: #222222;
  190. }
  191. .ques-title {
  192. margin: 32rpx 0 34rpx 0;
  193. font-weight: 500;
  194. font-size: 32rpx;
  195. white-space: normal;
  196. }
  197. .ques-type {
  198. flex-shrink: 0;
  199. min-width: 72rpx;
  200. height: 40rpx;
  201. padding: 0 12rpx;
  202. margin: 0 12rpx;
  203. box-sizing: border-box;
  204. background: #ff8901;
  205. border-radius: 8rpx 8rpx 8rpx 8rpx;
  206. line-height: 40rpx;
  207. text-align: center;
  208. font-family: PingFang SC, PingFang SC;
  209. font-weight: 400;
  210. font-size: 24rpx;
  211. color: #FFFFFF;
  212. display: inline-block;
  213. }
  214. .ques-option {
  215. min-height: 88rpx;
  216. padding: 24rpx 32rpx;
  217. box-sizing: border-box;
  218. margin-bottom: 24rpx;
  219. background: #F5F7FA;
  220. border-radius: 16rpx 16rpx 16rpx 16rpx;
  221. display: flex;
  222. align-items: center;
  223. &-active {
  224. color: #1db131 !important;
  225. background: #e8fcee !important;
  226. }
  227. }
  228. .footer {
  229. border-top: 1rpx solid #ededef;
  230. background: #fff;
  231. width: 100%;
  232. position: fixed;
  233. bottom: 0;
  234. padding: 24rpx 32rpx;
  235. box-sizing: border-box;
  236. z-index: 9;
  237. .copybtn {
  238. background: #FF5C03;
  239. color: #fff;
  240. text-align: center;
  241. font-size: 28rpx;
  242. border-radius: 80rpx;
  243. padding: 20rpx 0;
  244. }
  245. }
  246. </style>