event.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <main>
  3. <section class="visual--section">
  4. <div class="img--wrap">
  5. <picture>
  6. <img src="/img/company/img--about1.jpg" alt="" />
  7. </picture>
  8. </div>
  9. <div class="title--wrap color--white">
  10. <h2>Company</h2>
  11. </div>
  12. </section>
  13. <div class="detail--container">
  14. <section>
  15. <div class="desc--section full--type">
  16. <h3 class="big--title">EVENT</h3>
  17. </div>
  18. </section>
  19. <div class="content--wrap">
  20. <div class="event--wrap">
  21. <!-- 현재 페이지의 이벤트만 표시 -->
  22. <div
  23. v-for="event in paginatedEvents"
  24. :key="event.id"
  25. class="event--card"
  26. >
  27. <div class="img--wrap">
  28. <img :src="event.image" :alt="event.title">
  29. </div>
  30. <h3 class="ellipsis2">{{ event.title }}</h3>
  31. <NuxtLink :to="event.link">자세히 알아보기 <i class="ico"></i></NuxtLink>
  32. </div>
  33. </div>
  34. <!-- 페이지네이션 -->
  35. <div class="pagination--wrap">
  36. <button
  37. class="pagination--btn prev"
  38. @click="goToPage(currentPage - 1)"
  39. :disabled="currentPage === 1"
  40. >
  41. <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px">
  42. <use href="/img/ico--back--s.svg#main"></use>
  43. </svg>
  44. </button>
  45. <div class="pagination--numbers">
  46. <button
  47. v-for="page in displayPages"
  48. :key="page"
  49. class="pagination--number"
  50. :class="{ active: page === currentPage }"
  51. @click="goToPage(page)"
  52. >
  53. {{ page }}
  54. </button>
  55. </div>
  56. <button
  57. class="pagination--btn next"
  58. @click="goToPage(currentPage + 1)"
  59. :disabled="currentPage === totalPages"
  60. >
  61. <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px">
  62. <use href="/img/ico--forward--s.svg#main"></use>
  63. </svg>
  64. </button>
  65. </div>
  66. </div>
  67. </div>
  68. </main>
  69. </template>
  70. <script setup>
  71. const events = ref([
  72. {
  73. id: 1,
  74. title: 'Evolution x Vision: 아우디의 빠트로 드라이브',
  75. image: '/img/stories/technology/img--tech1.jpg',
  76. link: '/company/view'
  77. },
  78. {
  79. id: 2,
  80. title: 'Evolution x Vision: 아우디의 까트로 드라이브',
  81. image: '/img/stories/technology/img--tech1.jpg',
  82. link: '/company/view'
  83. },
  84. {
  85. id: 1,
  86. title: 'Evolution x Vision: 아우디의 염트로 드라이브',
  87. image: '/img/stories/technology/img--tech1.jpg',
  88. link: '/company/view'
  89. },
  90. {
  91. id: 1,
  92. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  93. image: '/img/stories/technology/img--tech1.jpg',
  94. link: '/company/view'
  95. },
  96. {
  97. id: 1,
  98. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  99. image: '/img/stories/technology/img--tech1.jpg',
  100. link: '/company/view'
  101. },
  102. {
  103. id: 1,
  104. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  105. image: '/img/stories/technology/img--tech1.jpg',
  106. link: '/company/view'
  107. },
  108. {
  109. id: 1,
  110. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  111. image: '/img/stories/technology/img--tech1.jpg',
  112. link: '/company/view'
  113. },
  114. {
  115. id: 1,
  116. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  117. image: '/img/stories/technology/img--tech1.jpg',
  118. link: '/company/view'
  119. },
  120. {
  121. id: 1,
  122. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  123. image: '/img/stories/technology/img--tech1.jpg',
  124. link: '/company/view'
  125. },
  126. {
  127. id: 1,
  128. title: 'Evolution x Vision: 아우디의 콰트로 드라이브',
  129. image: '/img/stories/technology/img--tech1.jpg',
  130. link: '/company/view'
  131. },
  132. ]);
  133. const currentPage = ref(1);
  134. const itemsPerPage = 9;
  135. // 전체 페이지 수 계산
  136. const totalPages = computed(() => {
  137. return Math.ceil(events.value.length / itemsPerPage);
  138. });
  139. // 현재 페이지에 표시할 이벤트
  140. const paginatedEvents = computed(() => {
  141. const start = (currentPage.value - 1) * itemsPerPage;
  142. const end = start + itemsPerPage;
  143. return events.value.slice(start, end);
  144. });
  145. // 표시할 페이지 번호 (최대 5개)
  146. const displayPages = computed(() => {
  147. const pages = [];
  148. const maxDisplay = 5;
  149. let startPage = Math.max(1, currentPage.value - 2);
  150. let endPage = Math.min(totalPages.value, startPage + maxDisplay - 1);
  151. if (endPage - startPage < maxDisplay - 1) {
  152. startPage = Math.max(1, endPage - maxDisplay + 1);
  153. }
  154. for (let i = startPage; i <= endPage; i++) {
  155. pages.push(i);
  156. }
  157. return pages;
  158. });
  159. // 페이지 이동
  160. const goToPage = (page) => {
  161. if (page >= 1 && page <= totalPages.value) {
  162. currentPage.value = page;
  163. // 페이지 이동 시 스크롤 최상단으로
  164. window.scrollTo({ top: 0, behavior: 'smooth' });
  165. }
  166. };
  167. </script>