catalogs.vue 4.4 KB

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