progress.uvue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 progress = ref(0)
  9. const isLoading = ref(false)
  10. const progressStatus = ref(0)
  11. //通过路由参数获取课程id
  12. async function fetchCatalog() {
  13. course.value = await fetchSubjectCourseApp({ id: router.query().id })
  14. if (!course.value?.courseUserProgress) {
  15. await updateSubjectProgress({
  16. courseId: course.value?.id,
  17. mainProgress: 1,
  18. assistantProgress: 1,
  19. status: 0
  20. })
  21. progress.value = 1
  22. } else if (course.value?.courseUserProgress.status == 0) {
  23. progressStatus.value = course.value?.courseUserProgress.status
  24. progress.value = course.value?.courseUserProgress.assistantProgress
  25. } else {
  26. progress.value = 6
  27. progressStatus.value = course.value?.courseUserProgress.status
  28. }
  29. }
  30. onShow(async () => {
  31. isLoading.value = true
  32. await fetchCatalog()
  33. isLoading.value = false
  34. })
  35. const menuItems = [
  36. { id: 1, name: '视频学习', icon: 'https://oss.xiaoxiongcode.com/static/home/6419.png', x: 0, y: 21 },
  37. { id: 2, name: '实战指导', icon: 'https://oss.xiaoxiongcode.com/static/home/6418.png', x: 27, y: 19 },
  38. { id: 3, name: '核心代码', icon: 'https://oss.xiaoxiongcode.com/static/home/6416.png', x: 80, y: 16 },
  39. { id: 4, name: '开始编程', icon: 'https://oss.xiaoxiongcode.com/static/home/6417.png', x: 55, y: 7 },
  40. ]
  41. //点击事件
  42. function handleClick(id: number) {
  43. switch (id) {
  44. case 1:
  45. router.push({
  46. path: "/pages/programming/detail",
  47. query: {
  48. id: router.query().id,
  49. }
  50. });
  51. break
  52. case 2:
  53. progress.value = 2
  54. break
  55. case 3:
  56. progress.value = 3
  57. break
  58. case 4:
  59. progress.value = 4
  60. break
  61. }
  62. }
  63. </script>
  64. <template>
  65. <Loading v-show="isLoading" />
  66. <cl-page>
  67. <Back />
  68. <view class="main">
  69. <!-- <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/home/641.png" /> -->
  70. <view class="text-[20px] font-bold text-[#333333] absolute top-6 left-20">
  71. {{ course?.mainTitle }}
  72. </view>
  73. <view class="progress w-[90vw] h-[45vw] pb-[5vw] flex items-center justify-end ">
  74. <image class="w-[80vw]" mode="widthFix" src="https://oss.xiaoxiongcode.com/static/home/形状 1.png" />
  75. <view v-for="item in menuItems" :key="item.id"
  76. class="w-[10vw] h-[13vw] absolute flex items-center justify-between z-[2]" :style="{
  77. top: `${item.y}vw`,
  78. left: `${item.x}vw`
  79. }" @click="handleClick(item.id)">
  80. <view class="w-[9vw] h-[9vw] flex items-center justify-center bg-[#fff] rounded-[2vw] box-shadow">
  81. <image :src="item.icon" class="w-[4vw] " mode="widthFix" />
  82. <text class="text-[2vw] text-[#000]">{{ item.name }}</text>
  83. </view>
  84. <view class="flex items-center justify-between gap-[1vw]">
  85. <image src="https://oss.xiaoxiongcode.com/static/home/6415.png" class="w-[4vw] " mode="widthFix" />
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </cl-page>
  91. </template>
  92. <style lang="scss" scoped>
  93. .main {
  94. background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  95. width: 100vw;
  96. height: 100vh;
  97. display: flex;
  98. flex-direction: column;
  99. justify-content: center;
  100. align-items: center;
  101. .progress {
  102. position: relative;
  103. z-index: 2;
  104. }
  105. }
  106. .box-shadow {
  107. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  108. }
  109. </style>