code.uvue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. <view class="main">
  30. <!-- <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/home/641.png" /> -->
  31. <view class="text-[20px] font-bold text-[#333333] absolute top-6 left-20">
  32. {{ course?.mainTitle }}
  33. </view>
  34. <scroll-view class="courseSummary" :show-scrollbar="false" v-if="type === 2">
  35. <view class="text-[20px] font-bold mb-3 text-[#fff]" v-for="(item, index) in courseSummary"
  36. :key="index">
  37. {{ index + 1 }}. {{ item }}
  38. </view>
  39. </scroll-view>
  40. <scroll-view class="codeImage" v-else :show-scrollbar="false">
  41. <cl-row :gutter="12">
  42. <cl-col :span="8" v-for="item in codeImage" :key="item">
  43. <cl-image showMenuByLongpress lazy-load preview :src="item" mode="scaleToFill"
  44. class="!w-full !h-[40vh] mb-[12px] rounded-xl">
  45. </cl-image>
  46. </cl-col>
  47. </cl-row>
  48. </scroll-view>
  49. </view>
  50. </cl-page>
  51. </template>
  52. <style lang="scss" scoped>
  53. .main {
  54. background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  55. width: 100vw;
  56. height: 100vh;
  57. display: flex;
  58. flex-direction: column;
  59. justify-content: center;
  60. align-items: center;
  61. .progress {
  62. position: relative;
  63. z-index: 2;
  64. }
  65. }
  66. .box-shadow {
  67. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  68. }
  69. .courseSummary {
  70. @apply absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 max-w-[1000px] w-[60vw] max-h-[620px] rounded-[30px] p-[20px] text-white;
  71. }
  72. .codeImage {
  73. @apply absolute max-w-[1000px] w-[80vw] text-white;
  74. top: 70px;
  75. height: calc(100vh - 80px);
  76. }
  77. </style>