progress.uvue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. visible.value = false
  94. router.push({
  95. path: "/pages/programming/web-view",
  96. query: {
  97. id: router.query().id,
  98. }
  99. });
  100. }
  101. function handleExchange2() {
  102. visible2.value = false
  103. router.push({
  104. path: "/pages/programming/web-view",
  105. query: {
  106. id: router.query().id,
  107. url: course.value?.sbFilePath,
  108. }
  109. });
  110. }
  111. </script>
  112. <template>
  113. <Loading v-show="isLoading" />
  114. <cl-page>
  115. <Back />
  116. <image class="absolute top-0 left-0 z-[1] w-full h-full " mode="aspectFill"
  117. src="https://oss.xiaoxiongcode.com/static/scratch/5.jpg" />
  118. <view class="main relative z-[2]">
  119. <view class="text-[20px] font-bold text-[#333333] absolute top-6 left-20">
  120. {{ course?.mainTitle }}
  121. </view>
  122. <view class="progress w-[90vw] h-[45vw] pb-[5vw] flex items-center justify-end ">
  123. <image class="w-[80vw]" mode="widthFix" src="https://oss.xiaoxiongcode.com/static/scratch/6.png" />
  124. <view v-for="item in menuItems" :key="item.id"
  125. class="w-[10vw] h-[13vw] absolute flex items-center justify-between z-[2]" :style="{
  126. top: `${item.y}vw`,
  127. left: `${item.x}vw`
  128. }" @click="handleClick(item.id)">
  129. <view class="w-[9vw] h-[9vw] flex items-center justify-center bg-[#fff] rounded-[2vw] box-shadow">
  130. <image :src="item.icon" class="w-[4vw] " mode="widthFix" />
  131. <text class="text-[2vw] text-[#000]">{{ item.name }}</text>
  132. </view>
  133. <view class="flex items-center justify-between gap-[1vw]">
  134. <image src="https://oss.xiaoxiongcode.com/static/home/6415.png" class="w-[4vw] " mode="widthFix" />
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. <cl-popup v-model="visible" :size="400" :show-header="false" direction="center">
  140. <view class="flex flex-col items-center justify-center gap-4 py-5 bg-slate-50">
  141. <view class="absolute top-2 right-2" @tap="visible = false">
  142. <cl-icon name="close-circle-fill" color="info" :size="20"></cl-icon>
  143. </view>
  144. <image mode="heightFix" src="https://oss.xiaoxiongcode.com/static/home/coding.png" class="h-[70rpx]" />
  145. <view class="text-center w-[300rpx]">
  146. <cl-text class="text-center" color="#fb923c" :size="16">非平板显示效果较差,建议使用平板或者电脑端操作!</cl-text>
  147. <cl-row :gutter="20">
  148. <cl-col :span="12">
  149. <cl-button type="primary" @tap="visible = false"> 返回 </cl-button>
  150. </cl-col>
  151. <cl-col :span="12">
  152. <cl-button type="warn" @tap="handleExchange"> 继续前往 </cl-button>
  153. </cl-col>
  154. </cl-row>
  155. </view>
  156. </view>
  157. </cl-popup>
  158. <cl-popup v-model="visible2" :size="400" :show-header="false" direction="center">
  159. <view class="flex flex-col items-center justify-center gap-4 py-5 bg-slate-50">
  160. <view class="absolute top-2 right-2" @tap="visible2 = false">
  161. <cl-icon name="close-circle-fill" color="info" :size="20"></cl-icon>
  162. </view>
  163. <image mode="heightFix" src="https://oss.xiaoxiongcode.com/static/home/coding.png" class="h-[70rpx]" />
  164. <view class="text-center w-[300rpx]">
  165. <cl-text class="text-center" color="#fb923c" :size="16">非平板显示效果较差,建议使用平板或者电脑端操作!</cl-text>
  166. <cl-row :gutter="20">
  167. <cl-col :span="12">
  168. <cl-button type="primary" @tap="visible = false"> 返回 </cl-button>
  169. </cl-col>
  170. <cl-col :span="12">
  171. <cl-button type="warn" @tap="handleExchange2"> 继续前往 </cl-button>
  172. </cl-col>
  173. </cl-row>
  174. </view>
  175. </view>
  176. </cl-popup>
  177. </cl-page>
  178. </template>
  179. <style lang="scss" scoped>
  180. .main {
  181. // background: linear-gradient(0deg, #88C5F0, #D0ECFF);
  182. width: 100vw;
  183. height: 100vh;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. .progress {
  189. position: relative;
  190. z-index: 2;
  191. }
  192. }
  193. .box-shadow {
  194. box-shadow: 4px 7px 10px 0px rgba(62, 166, 238, 0.44);
  195. }
  196. </style>