code.uvue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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, i) in codeImage" :key="i">
  46. <view class="flex flex-col items-center w-full mb-[12rpx]">
  47. <cl-text color="#fff" :size="14">
  48. {{ i + 1 }}、 参考代码(点击可放大)
  49. </cl-text>
  50. <cl-image showMenuByLongpress lazy-load preview :src="item" mode="scaleToFill"
  51. class="!w-full !h-[200rpx] mt-[5rpx] rounded-xl relative">
  52. </cl-image>
  53. </view>
  54. </cl-col>
  55. </cl-row>
  56. </scroll-view>
  57. </view>
  58. </cl-page>
  59. </template>
  60. <style lang="scss" scoped>
  61. .main {
  62. // background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  63. width: 100vw;
  64. height: 100vh;
  65. display: flex;
  66. flex-direction: column;
  67. justify-content: center;
  68. align-items: center;
  69. position: relative;
  70. z-index: 2;
  71. .progress {
  72. position: relative;
  73. z-index: 2;
  74. }
  75. }
  76. .box-shadow {
  77. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  78. }
  79. .courseSummary {
  80. @apply absolute max-w-[1000px] w-[70vw] rounded-[30px] text-white flex flex-col items-center p-[30px] text-center;
  81. aspect-ratio: 585 / 324;
  82. top: 60px;
  83. left: 50%;
  84. transform: translateX(-50%);
  85. }
  86. .codeImage {
  87. @apply absolute max-w-[1000px] w-[80vw] text-white;
  88. top: 70px;
  89. height: calc(100vh - 80px);
  90. }
  91. </style>