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