progress.uvue 5.3 KB

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