catalogs.vue 4.7 KB

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