catalogs.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { Swiper, SwiperSlide } from 'swiper/vue'
  4. import { Navigation, Pagination } from 'swiper/modules'
  5. import 'swiper/css'
  6. import 'swiper/css/navigation'
  7. import { ConstKeys } from '~/enums/const-enums'
  8. import { Api } from '@/api/model/url'
  9. const modules = [Navigation, Pagination]
  10. const catalogueList = ref<any>([])
  11. const swiperVertical = ref<any>(null)
  12. const solution = ref('category')
  13. const list = ref([
  14. {
  15. key: 'category',
  16. title: 'By Category',
  17. },
  18. {
  19. key: 'trend',
  20. title: 'By Trend',
  21. },
  22. ])
  23. const requestUrl = `${ConstKeys.DOMAINDEV}${Api.CatalogueList}`
  24. const params = { pageNo: 1, pageSize: 9, state: 1, trend: 1, order: 'desc' }
  25. const { data, pending, error, refresh } = await useAsyncData(
  26. 'catalogue-list',
  27. () => $fetch(requestUrl, { params }),
  28. )
  29. catalogueList.value = data.value?.result?.records || []
  30. function onVerticalSwiper(swiper: any) {
  31. swiperVertical.value = swiper
  32. }
  33. function onClickLeft() {
  34. // swiperVertical.value.slideTo()
  35. swiperVertical.value.slidePrev()
  36. }
  37. function onClickRight() {
  38. // swiperVertical.value.slideTo(4)
  39. swiperVertical.value.slideNext()
  40. }
  41. function switchCatalogs(item: any) {
  42. solution.value = item.key
  43. if (item.key === 'category')
  44. params.trend = 0
  45. else
  46. params.trend = 1
  47. refresh()
  48. }
  49. </script>
  50. <template>
  51. <div
  52. id="catalogs" class="bg-#0F0820 pt-100px pb-160px data-section"
  53. data-section-color="#0F0820"
  54. >
  55. <div class="w-1200-auto text-left pos-relative">
  56. <h2 class="text-36px fw-800 text-#fff !mb-40px custom-title-font">
  57. Download EJET Spark <span class="custom-title-bg02">Catalogs</span>
  58. </h2>
  59. <div class="flex gap-20px mb-30px text-center">
  60. <div
  61. v-for="(item, index) in list"
  62. :key="index"
  63. class="py-8px w-132px b-rd-6px text-14px fw-bold b-solid b-1px cursor-pointer hover:bg-#fff hover:text-#000 transition-all duration-300"
  64. :class="
  65. solution === item.key
  66. ? '!bg-#fff !text-#000 b-#fff'
  67. : 'bg-#0F0820 text-#fff b-#fff'
  68. "
  69. @click="switchCatalogs(item)"
  70. >
  71. <div>{{ item.title }}</div>
  72. </div>
  73. </div>
  74. <div class="w-1200-auto pos-relative">
  75. <div class="flex items-center justify-end text-#fff text-14px fw-bold mb-20px cursor-pointer">
  76. <nuxt-link class="text-#fff hover:text-#D7C4FF" :to="solution === 'category' ? '/categories' : '/trends'">
  77. View All
  78. </nuxt-link>
  79. <svgo-arrow-line-r class="w-16px h-16px ml-10px" />
  80. </div>
  81. <div
  82. class="pos-absolute cursor-pointer left-48% bottom--60px w-30px h-30px transform-translate-x--50% cursor-not-allowed !cursor-pointer flex justify-center items-center"
  83. @click="onClickLeft()"
  84. >
  85. <img
  86. src="~/assets/images/swiper_icon2_l.png"
  87. alt=""
  88. class="!w-2430px !h-30px"
  89. srcset=""
  90. >
  91. </div>
  92. <div
  93. class="pos-absolute cursor-pointer left-52% bottom--60px w-28px h-28px transform-translate-x--50% cursor-not-allowed !cursor-pointer flex justify-center items-center"
  94. @click="onClickRight()"
  95. >
  96. <img
  97. src="~/assets/images/swiper_icon2_r.png"
  98. alt=""
  99. class="!w-30px !h-30px"
  100. srcset=""
  101. >
  102. </div>
  103. <Swiper
  104. v-if="catalogueList.length"
  105. :slides-per-view="3"
  106. :space-between="20"
  107. :modules="modules"
  108. :centered-slides="true"
  109. :loop="true"
  110. :navigation="false"
  111. :pagination="true"
  112. class="pos-relative"
  113. @swiper="onVerticalSwiper"
  114. >
  115. <SwiperSlide v-for="(item, index) in catalogueList" :key="index">
  116. <common-catalogs-item :item="item" class="catalog-item" />
  117. </SwiperSlide>
  118. </Swiper>
  119. </div>
  120. <img
  121. class="w-240px h-148px pos-absolute right-0 bottom--160px z-101"
  122. src="~/assets/images/catalogs_img01.png"
  123. alt=""
  124. >
  125. </div>
  126. </div>
  127. </template>
  128. <style lang="less" scoped>
  129. .swiper-slide{
  130. border-radius: 10px;
  131. background-color: #fff;
  132. }
  133. .swiper-slide{
  134. background-color: #F3F4FB;
  135. &.swiper-slide-prev{
  136. background-color: #D7C4FF!important;
  137. transition: all 0.3s ease-in-out;
  138. }
  139. }
  140. </style>