progress.uvue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <script setup lang="ts">
  2. import Back from '@/components/back.uvue'
  3. import Loading from '@/components/loading.uvue'
  4. import { ref, onMounted, computed, watch, nextTick, onUnmounted } from 'vue'
  5. import { type SubjectCourseResult, fetchSubjectCourseApp, updateSubjectProgress } from '@/services/subject/course'
  6. import { router, user, isTabletDevice } from '@/.cool'
  7. const userInfo = computed(() => user.info.value?.userInfo)
  8. const course = ref<SubjectCourseResult>()
  9. const progress = ref(0)
  10. const isLoading = ref(false)
  11. //通过路由参数获取课程id
  12. async function fetchCatalog() {
  13. course.value = await fetchSubjectCourseApp({ id: router.query().id })
  14. }
  15. onMounted(async () => {
  16. isLoading.value = true
  17. await fetchCatalog()
  18. isLoading.value = false
  19. })
  20. const visible = ref(false)
  21. const menuItems = [
  22. { id: 1, name: '视频学习', icon: 'https://oss.xiaoxiongcode.com/static/home/6419.png', x: 0, y: 21 },
  23. // { id: 2, name: '实战指导', icon: 'https://oss.xiaoxiongcode.com/static/home/6418.png', x: 27, y: 19 },
  24. { id: 4, name: '开始编程', icon: 'https://oss.xiaoxiongcode.com/static/home/6417.png', x: 27, y: 19 },
  25. { id: 3, name: '参考答案', icon: 'https://oss.xiaoxiongcode.com/static/home/6416.png', x: 55, y: 7 },
  26. { id: 5, name: '效果展示', icon: 'https://oss.xiaoxiongcode.com/static/home/6417.png', x: 80, y: 16 },
  27. ]
  28. //点击事件
  29. function handleClick(id: number) {
  30. const res = isTabletDevice()
  31. switch (id) {
  32. case 1:
  33. router.push({
  34. path: "/pages/programming/detail",
  35. query: {
  36. id: router.query().id,
  37. }
  38. });
  39. break
  40. case 2:
  41. router.push({
  42. path: "/pages/programming/code",
  43. query: {
  44. id: router.query().id,
  45. type: 2,
  46. }
  47. });
  48. break
  49. case 3:
  50. router.push({
  51. path: "/pages/programming/code",
  52. query: {
  53. id: router.query().id,
  54. type: 3,
  55. }
  56. });
  57. break
  58. case 4:
  59. if (res) {
  60. router.push({
  61. path: "/pages/programming/web-view",
  62. query: {
  63. id: router.query().id,
  64. }
  65. });
  66. } else {
  67. visible.value = true
  68. }
  69. break
  70. case 5:
  71. if (res) {
  72. router.push({
  73. path: "/pages/programming/web-view",
  74. query: {
  75. id: router.query().id,
  76. url: course.value?.sbFilePath,
  77. }
  78. });
  79. } else {
  80. visible.value = true
  81. }
  82. break
  83. }
  84. }
  85. function copyUrl() {
  86. uni.setClipboardData({
  87. data: 'www.xiaoxiongcode.com',
  88. showToast: true
  89. });
  90. }
  91. function handleExchange() {
  92. router.push({
  93. path: "/pages/programming/web-view",
  94. query: {
  95. id: router.query().id,
  96. }
  97. });
  98. }
  99. </script>
  100. <template>
  101. <Loading v-show="isLoading" />
  102. <cl-page>
  103. <Back />
  104. <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill"
  105. src="https://oss.xiaoxiongcode.com/static/scratch/5.jpg" />
  106. <view class="main relative z-[2]">
  107. <view class="text-[20px] font-bold text-[#333333] absolute top-6 left-20">
  108. {{ course?.mainTitle }}
  109. </view>
  110. <view class="progress w-[90vw] h-[45vw] pb-[5vw] flex items-center justify-end ">
  111. <image class="w-[80vw]" mode="widthFix" src="https://oss.xiaoxiongcode.com/static/scratch/6.png" />
  112. <view v-for="item in menuItems" :key="item.id"
  113. class="w-[10vw] h-[13vw] absolute flex items-center justify-between z-[2]" :style="{
  114. top: `${item.y}vw`,
  115. left: `${item.x}vw`
  116. }" @click="handleClick(item.id)">
  117. <view class="w-[9vw] h-[9vw] flex items-center justify-center bg-[#fff] rounded-[2vw] box-shadow">
  118. <image :src="item.icon" class="w-[4vw] " mode="widthFix" />
  119. <text class="text-[2vw] text-[#000]">{{ item.name }}</text>
  120. </view>
  121. <view class="flex items-center justify-between gap-[1vw]">
  122. <image src="https://oss.xiaoxiongcode.com/static/home/6415.png" class="w-[4vw] " mode="widthFix" />
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <cl-popup v-model="visible" :size="400" :show-header="false" direction="center">
  128. <view class="flex flex-col items-center justify-center gap-4 py-5 bg-slate-50">
  129. <view class="absolute top-2 right-2" @tap="visible = false">
  130. <cl-icon name="close-circle-fill" color="info" :size="20"></cl-icon>
  131. </view>
  132. <image mode="heightFix" src="https://oss.xiaoxiongcode.com/static/home/coding.png" class="h-[70rpx]" />
  133. <view class="text-center w-[300rpx]">
  134. <cl-text class="text-center" color="#fb923c" :size="16">非平板显示效果较差,建议使用平板或者电脑端操作!</cl-text>
  135. <cl-row :gutter="20">
  136. <cl-col :span="12">
  137. <cl-button type="primary" @tap="visible = false"> 返回 </cl-button>
  138. </cl-col>
  139. <cl-col :span="12">
  140. <cl-button type="warn" @tap="handleExchange"> 继续前往 </cl-button>
  141. </cl-col>
  142. </cl-row>
  143. </view>
  144. </view>
  145. </cl-popup>
  146. </cl-page>
  147. </template>
  148. <style lang="scss" scoped>
  149. .main {
  150. // background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  151. width: 100vw;
  152. height: 100vh;
  153. display: flex;
  154. flex-direction: column;
  155. justify-content: center;
  156. align-items: center;
  157. .progress {
  158. position: relative;
  159. z-index: 2;
  160. }
  161. }
  162. .box-shadow {
  163. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  164. }
  165. </style>