progress.uvue 6.6 KB

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