HomeView.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <script setup lang="ts">
  2. import { useSimpleDataLoader } from '@/composeable/SimpleDataLoader';
  3. import { useRouter } from 'vue-router';
  4. import ImageSwiper from '@/components/small/ImageSwiper.vue';
  5. import Swiper1 from '@/assets/images/Home/swiper1.jpg';
  6. import Swiper2 from '@/assets/images/Home/swiper2.jpg';
  7. import Card1 from '@/assets/images/Home/Card/1.jpg';
  8. import Card2 from '@/assets/images/Home/Card/2.jpg';
  9. import Card3 from '@/assets/images/Home/Card/3.jpg';
  10. import Card4 from '@/assets/images/Home/Card/4.jpg';
  11. import Card5 from '@/assets/images/Home/Card/5.jpg';
  12. import Card6 from '@/assets/images/Home/Card/6.jpg';
  13. import Card7 from '@/assets/images/Home/Card/7.jpg';
  14. import Card8 from '@/assets/images/Home/Card/8.jpg';
  15. import { onMounted } from 'vue';
  16. const router = useRouter();
  17. const mainSwiperData = useSimpleDataLoader(async () => {
  18. return [
  19. {
  20. image: Swiper1,
  21. title: ''
  22. },
  23. {
  24. image: Swiper2,
  25. title: ''
  26. },
  27. ];
  28. });
  29. const mainCardData = [
  30. {
  31. image: Card1,
  32. title: '保护概况',
  33. id: 1,
  34. },
  35. {
  36. image: Card2,
  37. title: '闽南精神',
  38. id: 2,
  39. },
  40. {
  41. image: Card3,
  42. title: '古早话仙',
  43. id: 3,
  44. },
  45. {
  46. image: Card4,
  47. title: '民俗风情',
  48. id: 4,
  49. },
  50. {
  51. image: Card5,
  52. title: '保护传承',
  53. id: 5,
  54. },
  55. {
  56. image: Card6,
  57. title: '闽南时尚',
  58. id: 6,
  59. },
  60. {
  61. image: Card7,
  62. title: '文化之旅',
  63. id: 7,
  64. },
  65. {
  66. image: Card8,
  67. title: '厝边记忆',
  68. id: 8,
  69. },
  70. ];
  71. function handleClick(id: number) {
  72. router.push({ name: 'Content', query: { tab: id } });
  73. }
  74. </script>
  75. <template>
  76. <main class="main-content">
  77. <div class="main-bg absolute">
  78. <ImageSwiper :items="mainSwiperData.content.value ?? []" :autoplay="4000" :showAddons="false" :tabindex="-1">
  79. <template #item="{ item }">
  80. <img :src="item.image" alt="">
  81. </template>
  82. </ImageSwiper>
  83. </div>
  84. <div class="content absolute d-flex flex-col">
  85. <img src="@/assets/images/Home/title.png" alt="" class="main-title">
  86. <div class="main-card-space" />
  87. <div class="main-card-list">
  88. <div
  89. v-for="(item, index) in mainCardData"
  90. :key="index"
  91. :tabindex="1"
  92. :style="{
  93. backgroundImage: `url(${item.image})`
  94. }"
  95. class="main-card round"
  96. @click="handleClick(item.id)"
  97. >
  98. {{ item.title }}
  99. </div>
  100. </div>
  101. </div>
  102. </main>
  103. </template>
  104. <style lang="scss" scoped>
  105. .content {
  106. padding-left: 6%;
  107. padding-right: 6%;
  108. padding-top: 6%;
  109. padding-bottom: 6%;
  110. }
  111. .main-title {
  112. width: 40%;
  113. }
  114. .main-card-space {
  115. height: 50%;
  116. }
  117. .main-card-list {
  118. position: relative;
  119. height: 45%;
  120. min-height: 30vh;
  121. display: grid;
  122. grid-template-columns: repeat(4, 1fr);
  123. grid-gap: 20px;
  124. font-size: 26px;
  125. .main-card {
  126. font-size: 3cqh;
  127. padding: 0 15%;
  128. color: var(--color-primary);
  129. }
  130. }
  131. @media (max-width: 800px) {
  132. .content {
  133. padding-left: 10%;
  134. padding-right: 2%;
  135. }
  136. }
  137. @media (max-height: 400px) {
  138. .main-card-space {
  139. height: 16%;
  140. }
  141. }
  142. @media (max-height: 600px) {
  143. .content {
  144. padding-top: 7%;
  145. padding-bottom: 1%;
  146. }
  147. .main-card-space {
  148. height: 24%;
  149. }
  150. }
  151. </style>