detail.uvue 2.9 KB

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