index.uvue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. // if (!item.payFlag && !item.trialPlay) {
  37. // uni.showToast({
  38. // title: '请先购买',
  39. // icon: 'none'
  40. // })
  41. // return
  42. // }
  43. router.push({
  44. path: "/pages/catalog/detail",
  45. query: {
  46. id: item.id,
  47. }
  48. });
  49. }
  50. </script>
  51. <template>
  52. <Loading v-show="isLoading" />
  53. <cl-page v-show="!isLoading">
  54. <Back />
  55. <img src="https://oss.xiaoxiongcode.com/static/home/2.png" alt="" class="w-full h-full object-cover" />
  56. <!-- 精灵图动画 -->
  57. <cl-image src="https://oss.xiaoxiongcode.com/static/home/3.gif" mode="heightFix"
  58. class="!absolute bottom-0 left-0 !w-[44vh] !h-[55vh] z-[1]" />
  59. <view>
  60. </view>
  61. <!-- 顶部右侧光标签 -->
  62. <view class="light-tag" @tap="visible = true">
  63. <image class="light-icon" v-if="catalog?.fileList?.[0]?.url" :src="config.baseUrl + catalog?.fileList?.[0]?.url">
  64. </image>
  65. <text class="light-text">{{ catalog?.name }}</text>
  66. <cl-icon name="arrow-left-right-line" color="primary"></cl-icon>
  67. </view>
  68. <view class="boxs">
  69. <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false">
  70. <view class="scroll-view-item_H bg-[white]" v-for="course in catalog?.courseList || []" :key="course.id"
  71. @tap="handleDetail(course)">
  72. <cl-image :src="config.baseUrl + course?.fileList?.[0]?.url" mode="heightFix"
  73. class="!w-full !h-[26vh] mb-[2px] rounded-xl"></cl-image>
  74. <text class="text-[16px] font-bold">{{
  75. course.mainTitle }}</text>
  76. <text class="text-[14px] text-[#666]">{{
  77. course.assistantTitle }}</text>
  78. <view>
  79. <Progress :num="2" :percentage="course.sortNum" />
  80. </view>
  81. <Lock v-if="!course.trialPlay && !course.payFlag" :record="course" />
  82. </view>
  83. </scroll-view>
  84. </view>
  85. <view class="footer">
  86. <view>
  87. <cl-image src="https://oss.xiaoxiongcode.com/static/home/4.png" mode="heightFix"
  88. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  89. <text class="text-[14px] text-white font-bold text-stroke-custom">虚拟实验</text>
  90. </view>
  91. <view>
  92. <cl-image src="https://oss.xiaoxiongcode.com/static/home/5.png" mode="heightFix"
  93. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  94. <text class="text-[14px] text-white font-bold text-stroke-custom">我的收获</text>
  95. </view>
  96. <view>
  97. <cl-image src="https://oss.xiaoxiongcode.com/static/home/6.png" mode="heightFix"
  98. class=" !h-[40px] mb-[2px] rounded-xl"></cl-image>
  99. <text class="text-[14px] text-white font-bold text-stroke-custom">学习报告</text>
  100. </view>
  101. </view>
  102. <cl-popup v-model="visible" :show-header="false" direction="center" :size="600">
  103. <view class="p-4">
  104. <cl-row :gutter="0">
  105. <cl-col :span="6" v-for="item in dataList || []" :key="item.id" :pt="{
  106. className: '!p-2'
  107. }" @tap="handleSelect(item)">
  108. <view class="select-item" :class="{ selected: item.id === catalog?.id }">
  109. <image :src="config.baseUrl + item?.fileList?.[0]?.url" class="w-[30rpx] h-[30rpx] mb-[2px]"></image>
  110. <text>{{ item.name }}</text>
  111. </view>
  112. </cl-col>
  113. </cl-row>
  114. </view>
  115. </cl-popup>
  116. </cl-page>
  117. </template>
  118. <style lang="scss" scoped>
  119. .boxs {
  120. @apply w-[100vw] h-[50vh] absolute top-1/2 left-[50vh] z-[1];
  121. transform: translateY(-50%);
  122. }
  123. .scroll-view_H {
  124. width: 100%;
  125. height: 100%;
  126. flex-direction: row;
  127. }
  128. .scroll-view-item_H {
  129. @apply w-[40vh] h-[50vh] mr-[20px] rounded-2xl border-[5px] border-[#1D4BD9] border-solid border-b-[10px] p-1 flex items-center relative;
  130. }
  131. .light-tag {
  132. @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;
  133. transform: translateX(-50%);
  134. .light-icon {
  135. width: 20px;
  136. height: 20px;
  137. margin-right: 3px;
  138. }
  139. .light-text {
  140. font-size: 16px;
  141. min-width: 100px;
  142. padding-right: 5px;
  143. }
  144. }
  145. .select-item {
  146. @apply flex items-center justify-center rounded-xl border-[3px] border-[#1D4BD9] border-solid border-b-[5px] px-4 py-2 font-bold;
  147. }
  148. .selected {
  149. @apply border-green-500;
  150. }
  151. .footer {
  152. @apply absolute bottom-2 right-5 z-[1] flex flex-row items-center justify-center gap-4;
  153. }
  154. .text-stroke-custom {
  155. color: white;
  156. text-shadow:
  157. /* 左上角投影 */
  158. -1px -1px 0 #1D4BD9,
  159. /* 右上角投影 */
  160. 1px -1px 0 #1D4BD9,
  161. /* 左下角投影 */
  162. -1px 1px 0 #1D4BD9,
  163. /* 右下角投影 */
  164. 1px 1px 0 #1D4BD9;
  165. }
  166. </style>