code.uvue 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <script setup lang="ts">
  2. import Back from '@/components/back.uvue'
  3. import Loading from '@/components/loading.uvue'
  4. import { ref, onMounted, watch, nextTick, onUnmounted } from 'vue'
  5. import { type SubjectCourseResult, fetchSubjectCourseApp, updateSubjectProgress } from '@/services/subject/course'
  6. import { router, user } from '@/.cool'
  7. const course = ref<SubjectCourseResult>()
  8. const isLoading = ref(false)
  9. const courseSummary = ref([])
  10. const codeImage = ref([])
  11. const type = ref(0)
  12. //通过路由参数获取课程id
  13. async function fetchCatalog() {
  14. course.value = await fetchSubjectCourseApp({ id: router.query().id })
  15. type.value = parseInt(router.query().type) || 0
  16. courseSummary.value = JSON.parse(course.value?.courseSummary as string)
  17. codeImage.value = JSON.parse(course.value?.codeImage as string)
  18. }
  19. onMounted(async () => {
  20. isLoading.value = true
  21. await fetchCatalog()
  22. isLoading.value = false
  23. })
  24. </script>
  25. <template>
  26. <Loading v-show="isLoading" />
  27. <cl-page>
  28. <Back />
  29. <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill"
  30. src="https://oss.xiaoxiongcode.com/static/scratch/2.jpg" />
  31. <view class="main">
  32. <view class="text-[20px] font-bold text-[#fff] absolute top-6 left-20">
  33. {{ course?.mainTitle }}
  34. </view>
  35. <view class="courseSummary" :show-scrollbar="false" v-if="type === 2">
  36. <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill"
  37. src="https://oss.xiaoxiongcode.com/static/scratch/1.png" />
  38. <view class="text-[20px] w-[60vw] font-bold mb-3 text-[#000] relative z-[2]"
  39. v-for="(item, index) in courseSummary" :key="index">
  40. {{ index + 1 }}. {{ item }}
  41. </view>
  42. </view>
  43. <scroll-view class="codeImage" v-else :show-scrollbar="false">
  44. <cl-row :gutter="12">
  45. <cl-col :span="8" v-for="item in codeImage" :key="item">
  46. <cl-image showMenuByLongpress lazy-load preview :src="item" mode="scaleToFill"
  47. class="!w-full !h-[40vh] mb-[12px] rounded-xl">
  48. </cl-image>
  49. </cl-col>
  50. </cl-row>
  51. </scroll-view>
  52. </view>
  53. </cl-page>
  54. </template>
  55. <style lang="scss" scoped>
  56. .main {
  57. // background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  58. width: 100vw;
  59. height: 100vh;
  60. display: flex;
  61. flex-direction: column;
  62. justify-content: center;
  63. align-items: center;
  64. position: relative;
  65. z-index: 2;
  66. .progress {
  67. position: relative;
  68. z-index: 2;
  69. }
  70. }
  71. .box-shadow {
  72. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  73. }
  74. .courseSummary {
  75. @apply absolute max-w-[1000px] w-[70vw] rounded-[30px] text-white flex flex-col items-center p-[30px] text-center;
  76. aspect-ratio: 585 / 324;
  77. top: 60px;
  78. left: 50%;
  79. transform: translateX(-50%);
  80. }
  81. .codeImage {
  82. @apply absolute max-w-[1000px] w-[80vw] text-white;
  83. top: 70px;
  84. height: calc(100vh - 80px);
  85. }
  86. </style>