index.uvue 4.6 KB

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