index.uvue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <script lang="ts" setup>
  2. import { ref, onMounted } from 'vue'
  3. import { fetchSubjectConfigInfo } from '@/services/subject/info'
  4. import type { SubjectCatalogResult } from '@/services/subject/catalog'
  5. import Lock from '@/components/lock.uvue'
  6. import Progress from './components/progress.uvue'
  7. import Back from '@/components/back.uvue'
  8. import Loading from '@/components/loading.uvue'
  9. import { config } from '@/config'
  10. import { dict } from '@/.cool/store'
  11. import { router } from "@/.cool";
  12. const isLoading = ref(true)
  13. const visible = ref<boolean>(false)
  14. const dataList = ref<SubjectCatalogResult[]>([])
  15. const catalog = ref<SubjectCatalogResult>()
  16. async function getDataList() {
  17. const id = dict.getValueByLabelMapByType('index_subject_id')['物理']
  18. const res = await fetchSubjectConfigInfo({ id })
  19. dataList.value = res.catalogList || []
  20. catalog.value = res?.catalogList?.[0]
  21. }
  22. onMounted(async () => {
  23. try {
  24. await getDataList()
  25. isLoading.value = false
  26. } catch (err) {
  27. console.log(err);
  28. isLoading.value = false
  29. }
  30. })
  31. function handleSelect(item: SubjectCatalogResult) {
  32. catalog.value = item
  33. visible.value = false
  34. }
  35. function handleDetail(item: SubjectCatalogResult) {
  36. router.push({
  37. path: "/pages/catalog/detail",
  38. query: {
  39. id: item.id,
  40. }
  41. });
  42. }
  43. </script>
  44. <template>
  45. <Loading v-show="isLoading" />
  46. <cl-page v-show="!isLoading">
  47. <Back />
  48. <img src="https://oss.xiaoxiongcode.com/static/home/2.png" alt="" class="w-full h-full object-cover" />
  49. <!-- 精灵图动画 -->
  50. <cl-image src="https://oss.xiaoxiongcode.com/static/home/3.gif" mode="heightFix"
  51. class="!absolute bottom-0 left-0 !w-[44vh] !h-[55vh] z-[1]" />
  52. <view>
  53. </view>
  54. <!-- 顶部右侧光标签 -->
  55. <view class="light-tag" @tap="visible = true">
  56. <image class="light-icon" v-if="catalog?.fileList?.[0]?.url" :src="config.baseUrl + catalog?.fileList?.[0]?.url">
  57. </image>
  58. <text class="light-text">{{ catalog?.name }}</text>
  59. <cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
  60. </view>
  61. <view class="boxs">
  62. <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false">
  63. <view class="scroll-view-item_H bg-[white]" v-for="course in catalog?.courseList || []" :key="course.id"
  64. @tap="handleDetail(course)">
  65. <cl-image :src="config.baseUrl + course?.fileList?.[0]?.url" mode="heightFix"
  66. class="!w-full !h-[26vh] mb-[2px] rounded-xl"></cl-image>
  67. <text class="text-[16px] font-bold">{{
  68. course.mainTitle }}</text>
  69. <text class="text-[14px] text-[#666]">{{
  70. course.assistantTitle }}</text>
  71. <view>
  72. <Progress :num="2" :percentage="course.sortNum" />
  73. </view>
  74. <Lock v-if="!course.trialPlay" />
  75. </view>
  76. </scroll-view>
  77. </view>
  78. <view class="footer">
  79. <view>
  80. <cl-image src="https://oss.xiaoxiongcode.com/static/home/4.png" mode="heightFix"
  81. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  82. <text class="text-[14px] text-white font-bold text-stroke-custom">虚拟实验</text>
  83. </view>
  84. <view>
  85. <cl-image src="https://oss.xiaoxiongcode.com/static/home/5.png" mode="heightFix"
  86. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  87. <text class="text-[14px] text-white font-bold text-stroke-custom">我的收获</text>
  88. </view>
  89. <view>
  90. <cl-image src="https://oss.xiaoxiongcode.com/static/home/6.png" mode="heightFix"
  91. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  92. <text class="text-[14px] text-white font-bold text-stroke-custom">学习报告</text>
  93. </view>
  94. </view>
  95. <cl-popup v-model="visible" :show-header="false" direction="center" :size="600">
  96. <view class="p-4">
  97. <cl-row :gutter="0">
  98. <cl-col :span="6" v-for="item in dataList || []" :key="item.id" :pt="{
  99. className: '!p-2'
  100. }" @tap="handleSelect(item)">
  101. <view class="select-item" :class="{ selected: item.id === catalog?.id }">
  102. <image :src="config.baseUrl + item?.fileList?.[0]?.url" class="w-[30rpx] h-[30rpx] mb-[2px]"></image>
  103. <text>{{ item.name }}</text>
  104. </view>
  105. </cl-col>
  106. </cl-row>
  107. </view>
  108. </cl-popup>
  109. </cl-page>
  110. </template>
  111. <style lang="scss" scoped>
  112. .boxs {
  113. @apply w-[100vw] h-[50vh] absolute top-1/2 left-[50vh] z-[1];
  114. transform: translateY(-50%);
  115. }
  116. .scroll-view_H {
  117. width: 100%;
  118. height: 100%;
  119. flex-direction: row;
  120. }
  121. .scroll-view-item_H {
  122. @apply w-[40vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center relative;
  123. }
  124. .light-tag {
  125. @apply absolute top-3 left-1/2 z-[1] flex flex-row items-center bg-white px-3 py-2 font-bold rounded-full shadow-md;
  126. transform: translateX(-50%);
  127. .light-icon {
  128. width: 20px;
  129. height: 20px;
  130. margin-right: 3px;
  131. }
  132. .light-text {
  133. font-size: 16px;
  134. min-width: 100px;
  135. padding-right: 5px;
  136. }
  137. }
  138. .select-item {
  139. @apply flex items-center justify-center rounded-xl border-[3px] border-[#1D4BD9] border-solid border-b-[5px] px-4 py-2 font-bold;
  140. }
  141. .selected {
  142. @apply border-green-500;
  143. }
  144. .footer {
  145. @apply absolute bottom-2 right-5 z-[1] flex flex-row items-center justify-center gap-4;
  146. }
  147. .text-stroke-custom {
  148. color: white;
  149. text-shadow:
  150. /* 左上角投影 */
  151. -1px -1px 0 #1D4BD9,
  152. /* 右上角投影 */
  153. 1px -1px 0 #1D4BD9,
  154. /* 左下角投影 */
  155. -1px 1px 0 #1D4BD9,
  156. /* 右下角投影 */
  157. 1px 1px 0 #1D4BD9;
  158. }
  159. </style>