detail.uvue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <script setup lang='ts'>
  2. import Back from '@/components/back.uvue'
  3. import Loading from '@/components/loading.uvue'
  4. import { ref, onMounted, getCurrentInstance } from 'vue'
  5. const isLoading = ref(true)
  6. const showProgress = ref(true)
  7. onMounted(async () => {
  8. isLoading.value = false
  9. })
  10. const videoContext = ref<UniApp.VideoContext>()
  11. const data = ref({
  12. src: 'https://oss.xiaoxiongcode.com/course-1/animate/第1集_观察.mp4'
  13. })
  14. const menuItems = [
  15. { id: 'watch', name: '看课', icon: '📺', active: true },
  16. { id: 'practice', name: '练习', icon: '📝', active: false },
  17. { id: 'experiment', name: '虚拟实验', icon: '🧪', active: false },
  18. { id: 'diary', name: '科学日记', icon: '📓', active: false }
  19. ]
  20. onReady(() => {
  21. videoContext.value = uni.createVideoContext("video1", getCurrentInstance()!.proxy!)
  22. })
  23. setTimeout(() => {
  24. showProgress.value = false
  25. }, 2000)
  26. function handleControlsToggle(e) {
  27. videoContext.value?.requestFullScreen({
  28. direction: 0
  29. })
  30. }
  31. </script>
  32. <template>
  33. <Loading v-show="isLoading" />
  34. <cl-page v-show="!isLoading">
  35. <Back />
  36. <view class="w-[64vw] h-[36vw] absolute top-1/2 z-[1] left-[7vw] translate50"
  37. :class="{ ' rounded-2xl p-[3px] bg-black mt-[25px] ': showProgress, 'video-container': !showProgress }">
  38. <video id="video1" class="w-full h-full " :class="{ 'rounded-2xl': showProgress }" :src="data.src"
  39. :show-center-play-btn="false" autoplay>
  40. </video>
  41. <template>
  42. <view class="video-fullscreen_controls" @click="handleControlsToggle">
  43. <view class="control-btn">
  44. <text class="control-icon">23123123123</text>
  45. </view>
  46. <view class="control-btn">
  47. <text class="control-icon">123213</text>
  48. </view>
  49. <view class="control-btn">
  50. <text class="control-icon">123123123123</text>
  51. </view>
  52. </view>
  53. </template>
  54. </view>
  55. <view class="course-detail-page" :class="{ 'hidden': !showProgress }">
  56. <!-- 顶部标题栏 -->
  57. <view class="flex-[1] h-[100vh] relative">
  58. <view class="flex flex-row w-full pr-[3vw] pl-[10vw] items-center justify-between absolute top-[30px]">
  59. <text class="text-[5vh] font-bold">1、物质大揭秘!</text>
  60. <text
  61. class="rounded-full p-[1vh] px-[2vh] border-2 border-[#fff] border-solid text-[#fff] text-[3vh] font-bold">课程收获</text>
  62. </view>
  63. </view>
  64. <!-- 右侧功能菜单 -->
  65. <view class="w-[25vw] h-[100vh] bg-[#5CBDFD] flex flex-col justify-center p-5">
  66. <view v-for="(item, i) in menuItems" :key="item.id" class="h-[20vh] flex flex-row items-center "
  67. :class="{ active: item.active }">
  68. <view
  69. class="h-[15vh] w-[20vh] bg-[#fff] rounded-2xl border-[.5vh] border-[#254AD9] border-b-[1vh] border-solid flex items-center justify-center gap-[1vh]">
  70. <cl-image src="https://oss.xiaoxiongcode.com/static/home/4.png" mode="heightFix"
  71. class="!h-[7vh]"></cl-image>
  72. <text class="text-[2vh] font-bold">{{ item.name }}</text>
  73. </view>
  74. <view class="flex items-center h-[20vh] ml-[2vh] ">
  75. <view class="w-[1vh] bg-[#B4DBF7] flex-1"
  76. :class="{ 'bg-[#71C73D]': item.active, '!bg-[#5CBDFD]': i === 0 }">
  77. </view>
  78. <view class="w-[5vh] bg-[#fff] h-[5vh] rounded-full" :class="{ 'bg-[#71C73D]': item.active }"></view>
  79. <view class="w-[1vh] bg-[#B4DBF7] flex-1"
  80. :class="{ 'bg-[#71C73D]': item.active, '!bg-[#5CBDFD]': i === menuItems.length - 1 }"></view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </cl-page>
  86. </template>
  87. <style lang="scss" scoped>
  88. .translate50 {
  89. transform: translateY(-50%);
  90. }
  91. .course-detail-page {
  92. @apply flex flex-row items-center;
  93. background-color: #3498DB;
  94. height: 100vh;
  95. color: black;
  96. transition: all 1s ease-in-out;
  97. }
  98. .video-container {
  99. width: 100vw;
  100. height: 100vh;
  101. top: 0;
  102. left: 0;
  103. transform: translate(0, 0);
  104. animation: spin 2s linear 1;
  105. transition: all 2s ease-in-out;
  106. }
  107. @keyframes spin {
  108. 0% {
  109. opacity: 50%;
  110. }
  111. 100% {
  112. opacity: 1;
  113. }
  114. }
  115. .hidden {
  116. opacity: 0;
  117. transition: all 3s ease-in-out;
  118. }
  119. .video-fullscreen_controls {
  120. position: absolute;
  121. left: 50%;
  122. transform: translateX(-50%);
  123. bottom: 0px;
  124. height: 50px;
  125. flex-direction: row;
  126. justify-content: flex-start;
  127. align-items: center;
  128. z-index: 10;
  129. width: 80vw;
  130. }
  131. </style>