catalogs.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 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 { data, pending, error, refresh } = await useAsyncData(
  23. 'brand-detail',
  24. () => $fetch(`${ConstKeys.DOMAINPRO}/client/brand/list/default`, { params: { pageNo: 1, pageNo: 1 } }),
  25. )
  26. categoryList.value = data.value?.result.records
  27. function onVerticalSwiper(swiper: any) {
  28. swiperVertical.value = swiper
  29. }
  30. function onClickLeft() {
  31. // swiperVertical.value.slideTo()
  32. swiperVertical.value.slidePrev()
  33. }
  34. function onClickRight() {
  35. // swiperVertical.value.slideTo(4)
  36. swiperVertical.value.slideNext()
  37. }
  38. function setTranslate(swiper: any, _translate: any) {
  39. // 设置第一个位置的背景色为#D7C4FF
  40. if (swiper) {
  41. swiper.slides.forEach((_slide: any, _i: number) => {
  42. const slider = swiper.slides[_i]
  43. if (_i === 1)
  44. slider.style.backgroundColor = '#D7C4FF'
  45. else
  46. slider.style.backgroundColor = ''
  47. })
  48. }
  49. }
  50. // function setTransition(swiper: any, _transition: any) {
  51. // if (!swiper)
  52. // return
  53. // for (let i = 0; i < swiper.slides.length; i++) {
  54. // const slider = swiper.slides[i]
  55. // // console.log('slide------222', slider)
  56. // slider.style.transition = `${_transition}ms`
  57. // }
  58. // }
  59. </script>
  60. <template>
  61. <div
  62. id="catalogs" class="bg-#0F0820 pt-100px pb-160px data-section"
  63. data-section-color="#0F0820"
  64. >
  65. <div class="w-1200-auto text-left pos-relative">
  66. <h2 class="text-36px fw-800 text-#fff !mb-40px">
  67. Download EJET Spark <span class="custom-title-bg">Catalogs</span>
  68. </h2>
  69. <div class="flex gap-20px mb-30px text-center">
  70. <div
  71. v-for="(item, index) in list"
  72. :key="index"
  73. 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"
  74. :class="
  75. solution === item.key
  76. ? '!bg-#fff !text-#000 b-#fff'
  77. : 'bg-#0F0820 text-#fff b-#fff'
  78. "
  79. @click="solution = item.key"
  80. >
  81. <div>{{ item.title }}</div>
  82. </div>
  83. </div>
  84. <div class="w-1200-auto pos-relative">
  85. <div class="flex items-center justify-end text-#fff text-14px fw-bold mb-20px cursor-pointer">
  86. View All
  87. <svgo-arrow-line-r class="w-16px h-16px ml-10px" />
  88. </div>
  89. <div
  90. 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"
  91. @click="onClickLeft()"
  92. >
  93. <img
  94. src="~/assets/images/swiper_icon2_l.png"
  95. alt=""
  96. class="!w-2430px !h-30px"
  97. srcset=""
  98. >
  99. </div>
  100. <div
  101. 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"
  102. @click="onClickRight()"
  103. >
  104. <img
  105. src="~/assets/images/swiper_icon2_r.png"
  106. alt=""
  107. class="!w-30px !h-30px"
  108. srcset=""
  109. >
  110. </div>
  111. <!-- @set-transition="setTransition" -->
  112. <Swiper
  113. v-if="categoryList.length"
  114. :slides-per-view="3"
  115. :space-between="20"
  116. :modules="modules"
  117. :centered-slides="true"
  118. :loop="true"
  119. :navigation="false"
  120. :pagination="true"
  121. class="pos-relative"
  122. @set-translate="setTranslate"
  123. @swiper="onVerticalSwiper"
  124. >
  125. <SwiperSlide v-for="(item, index) in categoryList" :key="index">
  126. <common-catalogs-item :item="item" />
  127. </SwiperSlide>
  128. </Swiper>
  129. </div>
  130. <img
  131. class="w-240px h-148px pos-absolute right-0 bottom--160px z-101"
  132. src="~/assets/images/catalogs_img01.png"
  133. alt=""
  134. >
  135. </div>
  136. </div>
  137. </template>
  138. <style lang="less" scoped>
  139. .swiper-slide{
  140. border-radius: 10px;
  141. background-color: #fff;
  142. }
  143. .custom-title-bg{
  144. position: relative;
  145. display: inline-block;
  146. background: url(~/assets/images/title_bg02.png);
  147. background-repeat: no-repeat;
  148. background-position: center 100%;
  149. background-size: 100% auto;
  150. padding-bottom: 8px;
  151. }
  152. </style>