detail.uvue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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') ? course.value?.videoPath : ('https://oss.xiaoxiongcode.com' + 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. }
  33. function handleControlsToggle(e) {
  34. showControls.value = e.detail.show
  35. }
  36. </script>
  37. <template>
  38. <Loading v-show="isLoading" />
  39. <cl-page v-show="!isLoading">
  40. <view class="w-full h-full">
  41. <video id="video1" class="w-full h-full " :src="data.videoSrc" :show-center-play-btn="false"
  42. :show-background-playback-button="false" :show-fullscreen-btn="false" :show-casting-button="false" autoplay
  43. @controlstoggle="handleControlsToggle" @ended="handleEnded">
  44. </video>
  45. <view class="video-fullscreen_title" v-show="showControls">
  46. <Back />
  47. <view class="text-[20px] font-bold text-white">
  48. {{ course?.mainTitle }}
  49. </view>
  50. </view>
  51. </view>
  52. </cl-page>
  53. </template>
  54. <style lang="scss" scoped>
  55. .translate50 {
  56. transform: translateY(-50%);
  57. }
  58. .course-detail-page {
  59. @apply flex flex-row items-center;
  60. background-color: #3498DB;
  61. height: 100vh;
  62. color: black;
  63. transition: all 1s ease-in-out;
  64. }
  65. .video-container {
  66. width: 100vw;
  67. height: 100vh;
  68. top: 0;
  69. left: 0;
  70. transform: translate(0, 0);
  71. animation: spin 2s linear 1;
  72. transition: all 2s ease-in-out;
  73. }
  74. @keyframes spin {
  75. 0% {
  76. opacity: 50%;
  77. }
  78. 100% {
  79. opacity: 1;
  80. }
  81. }
  82. .hidden {
  83. opacity: 0;
  84. transition: all 3s ease-in-out;
  85. }
  86. .video-fullscreen_title {
  87. @apply absolute top-3 left-0 pl-[80px] w-[100vw] z-10 flex items-center justify-between flex-row;
  88. color: #fff;
  89. .control-progress {
  90. @apply flex flex-row gap-[3px] relative justify-end;
  91. flex: 1;
  92. .before {
  93. @apply absolute top-1/2 right-0 w-[340px] h-[40px] bg-[#2BA0F3] rounded-l-full;
  94. transform: translateY(-30%);
  95. }
  96. }
  97. }
  98. video::-webkit-media-controls-fullscreen-button,
  99. video::-webkit-media-controls-enter-fullscreen-button,
  100. video::-webkit-media-controls-rotate-button,
  101. video::-webkit-media-controls-seek-back-button,
  102. video::-webkit-media-controls-seek-forward-button {
  103. display: none !important;
  104. }
  105. .mic {
  106. @apply absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2;
  107. }
  108. </style>