progress.uvue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 } 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: 15 },
  37. { id: 2, name: '交互', icon: 'https://oss.xiaoxiongcode.com/static/home/6414.png', x: 15, y: 22 },
  38. { id: 3, name: '思考', icon: 'https://oss.xiaoxiongcode.com/static/home/6418.png', x: 29, y: 13 },
  39. { id: 4, name: '假设', icon: 'https://oss.xiaoxiongcode.com/static/home/6412.png', x: 41, y: 3 },
  40. { id: 5, name: '总结', icon: 'https://oss.xiaoxiongcode.com/static/home/6416.png', x: 59, y: 7 },
  41. { id: 6, name: '实验', icon: 'https://oss.xiaoxiongcode.com/static/home/6417.png', x: 80, y: 10 },
  42. ]
  43. //点击事件
  44. function handleClick(id: number) {
  45. if (!course.value?.courseUserProgress) {
  46. updateSubjectProgress({
  47. courseId: course.value?.id,
  48. mainProgress: 1,
  49. assistantProgress: id,
  50. status: 0
  51. })
  52. router.push({
  53. path: "/pages/catalog/detail",
  54. query: {
  55. id: router.query().id,
  56. progress: id,
  57. }
  58. });
  59. return
  60. }
  61. if (course.value?.id && course.value?.courseUserProgress.status == 0) {
  62. updateSubjectProgress({
  63. courseId: course.value?.id,
  64. mainProgress: 1,
  65. assistantProgress: id,
  66. status: course.value?.courseUserProgress.status
  67. })
  68. }
  69. router.push({
  70. path: "/pages/catalog/detail",
  71. query: {
  72. id: router.query().id,
  73. progress: id,
  74. }
  75. });
  76. }
  77. </script>
  78. <template>
  79. <Loading v-show="isLoading" />
  80. <cl-page>
  81. <Back />
  82. <view class="main">
  83. <!-- <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill" src="https://oss.xiaoxiongcode.com/static/home/641.png" /> -->
  84. <view class="text-[20px] font-bold text-[#333333] absolute top-6 left-20">
  85. {{ course?.mainTitle }}
  86. </view>
  87. <view class="progress w-[90vw] h-[45vw] pb-[5vw] flex items-center justify-end ">
  88. <image class="w-[80vw]" mode="widthFix" src="https://oss.xiaoxiongcode.com/static/home/形状 1.png" />
  89. <view v-for="item in menuItems" :key="item.id"
  90. class="w-[10vw] h-[19vw] absolute flex items-center justify-between z-[2]" :style="{
  91. top: `${item.y}vw`,
  92. left: `${item.x}vw`
  93. }" @click="handleClick(item.id)">
  94. <view class="w-[9vw] h-[9vw] flex items-center justify-center bg-[#fff] rounded-[2vw] box-shadow">
  95. <image :src="item.icon" class="w-[4vw] " mode="widthFix" />
  96. <text class="text-[2vw] text-[#000]">{{ item.name }}</text>
  97. </view>
  98. <view class="flex items-center justify-between gap-[1vw]">
  99. <image v-if="progress === item.id && progressStatus == 0"
  100. src="https://oss.xiaoxiongcode.com/static/home/6411.png" class="h-[4vw] " mode="heightFix" />
  101. <view v-else-if="progress < item.id && progressStatus == 0"
  102. class="text-[2vw] w-[4vw] h-[4vw] flex items-center justify-center text-bold text-[#333] bg-[#fff] rounded-full ">
  103. {{ item.id }}
  104. </view>
  105. <image v-else src="https://oss.xiaoxiongcode.com/static/home/6413.png" class="h-[4vw] " mode="heightFix" />
  106. <image src="https://oss.xiaoxiongcode.com/static/home/6415.png" class="w-[4vw] " mode="widthFix" />
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </cl-page>
  112. </template>
  113. <style lang="scss" scoped>
  114. .main {
  115. background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  116. width: 100vw;
  117. height: 100vh;
  118. display: flex;
  119. flex-direction: column;
  120. justify-content: center;
  121. align-items: center;
  122. .progress {
  123. position: relative;
  124. z-index: 2;
  125. }
  126. }
  127. .box-shadow {
  128. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  129. }
  130. </style>