catalogs.vue 4.1 KB

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