detail.uvue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <script setup lang='ts'>
  2. import Back from '@/components/back.uvue'
  3. import Loading from '@/components/loading.uvue'
  4. import { ref, onMounted, watchEffect, nextTick, onUnmounted } from 'vue'
  5. import { type SubjectCourseResult, fetchSubjectCourseApp, updateSubjectProgress } from '@/services/subject/course'
  6. import { router } from '@/.cool'
  7. const isLoading = ref(true)
  8. const showProgress = ref(true)
  9. const showControls = ref(true)
  10. const showVideo = ref(true)
  11. const data = ref({
  12. videoSrc: '',
  13. })
  14. //当前进度
  15. const course = ref<SubjectCourseResult>()
  16. //通过路由参数获取课程id
  17. async function fetchCatalog() {
  18. course.value = await fetchSubjectCourseApp({ id: router.query().id })
  19. if (!course.value?.videoPath) {
  20. return
  21. }
  22. data.value.videoSrc = course.value?.videoPath.includes('http') ? encodeURI(course.value?.videoPath) : ('https://oss.xiaoxiongcode.com' + encodeURI(course.value?.videoPath))
  23. }
  24. onMounted(async () => {
  25. await fetchCatalog()
  26. isLoading.value = false
  27. setTimeout(() => {
  28. isLoading.value = false
  29. }, 1000)
  30. })
  31. async function handleEnded() {
  32. router.back()
  33. }
  34. function handleControlsToggle(e) {
  35. showControls.value = e.detail.show
  36. }
  37. </script>
  38. <template>
  39. <Loading v-show="isLoading" />
  40. <cl-page v-show="!isLoading">
  41. <view class="w-full h-full">
  42. <video id="video1" class="w-full h-full " :src="data.videoSrc" :show-center-play-btn="false"
  43. :show-background-playback-button="false" :show-fullscreen-btn="false" :show-casting-button="false" autoplay
  44. @controlstoggle="handleControlsToggle" @ended="handleEnded">
  45. </video>
  46. <view class="video-fullscreen_title" v-show="showControls">
  47. <Back />
  48. <view class="text-[20px] font-bold text-white">
  49. {{ course?.mainTitle }}
  50. </view>
  51. </view>
  52. </view>
  53. </cl-page>
  54. </template>
  55. <style lang="scss" scoped>
  56. .translate50 {
  57. transform: translateY(-50%);
  58. }
  59. .course-detail-page {
  60. @apply flex flex-row items-center;
  61. background-color: #3498DB;
  62. height: 100vh;
  63. color: black;
  64. transition: all 1s ease-in-out;
  65. }
  66. .video-container {
  67. width: 100vw;
  68. height: 100vh;
  69. top: 0;
  70. left: 0;
  71. transform: translate(0, 0);
  72. animation: spin 2s linear 1;
  73. transition: all 2s ease-in-out;
  74. }
  75. @keyframes spin {
  76. 0% {
  77. opacity: 50%;
  78. }
  79. 100% {
  80. opacity: 1;
  81. }
  82. }
  83. .hidden {
  84. opacity: 0;
  85. transition: all 3s ease-in-out;
  86. }
  87. .video-fullscreen_title {
  88. @apply absolute top-3 left-0 pl-[80px] w-[100vw] z-10 flex items-center justify-between flex-row;
  89. color: #fff;
  90. .control-progress {
  91. @apply flex flex-row gap-[3px] relative justify-end;
  92. flex: 1;
  93. .before {
  94. @apply absolute top-1/2 right-0 w-[340px] h-[40px] bg-[#2BA0F3] rounded-l-full;
  95. transform: translateY(-30%);
  96. }
  97. }
  98. }
  99. video::-webkit-media-controls-fullscreen-button,
  100. video::-webkit-media-controls-enter-fullscreen-button,
  101. video::-webkit-media-controls-rotate-button,
  102. video::-webkit-media-controls-seek-back-button,
  103. video::-webkit-media-controls-seek-forward-button {
  104. display: none !important;
  105. }
  106. .mic {
  107. @apply absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2;
  108. }
  109. </style>