catalogs.vue 4.4 KB

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