index.uvue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <script setup lang='ts'>
  2. import Back from '@/components/back.uvue'
  3. import Loading from '@/components/loading.uvue'
  4. import { ref, onMounted } from 'vue'
  5. import { type SubjectKnowledgeCardResult, getSubjectKnowledgeCard } from '@/services/subject/card'
  6. import { fetchSubjectConfigInfo } from '@/services/subject/info'
  7. import type { SubjectCatalogResult } from '@/services/subject/catalog'
  8. const activeCategory = ref<string>()
  9. const isLoading = ref(true)
  10. const categories = ref<SubjectCatalogResult[]>([])
  11. const cards = ref<SubjectKnowledgeCardResult[]>([])
  12. async function getDataList() {
  13. const res = await fetchSubjectConfigInfo({ id: '69afc7e048070409048c06b6' })
  14. categories.value = res.catalogList || []
  15. handleSelect(categories.value[0].id as string)
  16. }
  17. function handleSelect(subjectId: string) {
  18. activeCategory.value = subjectId
  19. getSubjectKnowledgeCard({ subjectId }).then(res => {
  20. console.log(res)
  21. cards.value = res.catalogList || []
  22. })
  23. }
  24. onMounted(async () => {
  25. await getDataList()
  26. isLoading.value = false
  27. })
  28. </script>
  29. <template>
  30. <Loading v-if="isLoading" />
  31. <cl-page v-else>
  32. <Back />
  33. <!-- 顶部标题栏 -->
  34. <view class="content">
  35. <!-- 左侧导航菜单 -->
  36. <scroll-view direction="vertical" :show-scrollbar="false" class="sidebar">
  37. <view v-for="category in categories" :key="category.id" class="sidebar-item"
  38. :class="{ active: activeCategory === category.id }" @tap="handleSelect(category.id as string)">
  39. <cl-image :src="category?.fileList?.[0]?.url" mode="heightFix" class="!h-[28px]"></cl-image>
  40. <text class="sidebar-text">{{ category.name }}</text>
  41. </view>
  42. </scroll-view>
  43. <!-- 右侧卡片网格 -->
  44. <view class="cards-container">
  45. <view class="header">
  46. <view class="title-tabs">
  47. <view class="tab active">知识卡</view>
  48. <view class="tab">荣誉</view>
  49. </view>
  50. </view>
  51. <scroll-view direction="vertical" :show-scrollbar="false" class="cards">
  52. <view class="grid grid-cols-5 gap-4">
  53. <view class="card" v-for="card in cards" :key="card.id">
  54. <image src="/static/home/21.png" class="w-full h-full" />
  55. <view class="card-title">{{ card.title }}</view>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. </view>
  60. </view>
  61. </cl-page>
  62. </template>
  63. <style lang="scss" scoped>
  64. .header {
  65. @apply absolute left-1/2 top-5;
  66. transform: translateX(-50%);
  67. text-align: center;
  68. .title-tabs {
  69. @apply flex flex-row items-center justify-center rounded-full;
  70. background-color: #9AD2FA;
  71. .tab {
  72. @apply rounded-full;
  73. padding: 5px 10px;
  74. font-size: 16px;
  75. transition: all 0.3s ease;
  76. &.active {
  77. background-color: white;
  78. color: #1E88E5;
  79. font-weight: bold;
  80. }
  81. }
  82. }
  83. }
  84. .content {
  85. display: flex;
  86. flex-direction: row;
  87. .sidebar {
  88. width: 200px;
  89. background-color: #116FE9;
  90. padding: 20px;
  91. padding-top: 70px;
  92. height: 100vh;
  93. .sidebar-item {
  94. @apply text-white rounded-full py-1 cursor-pointer flex flex-row items-center;
  95. margin-bottom: 8px;
  96. transition: all 0.3s ease;
  97. font-size: 12px;
  98. width: 100%;
  99. &.active {
  100. background-color: rgba(255, 255, 255, 1);
  101. color: #1E88E5;
  102. font-weight: bold;
  103. }
  104. .sidebar-icon {
  105. font-size: 28px;
  106. margin-right: 2px;
  107. }
  108. }
  109. }
  110. .cards-container {
  111. @apply relative;
  112. flex: 1;
  113. width: 100%;
  114. padding: 20px;
  115. padding-top: 70px;
  116. background: linear-gradient(0deg, #2EB2FD, #0B85F4);
  117. .cards {
  118. height: calc(100vh - 90px);
  119. }
  120. .card {
  121. // background-color: rgba(255, 255, 255, 0.9);
  122. // border-radius: 16px;
  123. // padding: 16px;
  124. display: flex;
  125. flex-direction: column;
  126. align-items: center;
  127. // box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  128. aspect-ratio: 3/4;
  129. .card-content {
  130. width: 100%;
  131. height: 120px;
  132. background-color: #E3F2FD;
  133. border-radius: 12px;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. margin-bottom: 12px;
  138. aspect-ratio: 3/4;
  139. .question-mark {
  140. font-size: 60px;
  141. font-weight: bold;
  142. color: #1E88E5;
  143. }
  144. }
  145. .card-title {
  146. @apply text-center font-bold absolute bottom-[13%] left-0 w-full text-[#0E3E87] text-[1.5vw];
  147. }
  148. }
  149. }
  150. }
  151. </style>