catalogs.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 id="catalogs" class="bg-#0F0820 pt-100px pb-160px">
  71. <div class="w-1200-auto text-left pos-relative">
  72. <h2 class="text-36px fw-800 text-#fff !mb-40px">
  73. Download EJET Spark <span class="custom-title-bg">Catalogs</span>
  74. </h2>
  75. <div class="flex gap-20px mb-30px text-center">
  76. <div
  77. v-for="(item, index) in list"
  78. :key="index"
  79. 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"
  80. :class="
  81. solution === item.key
  82. ? '!bg-#fff !text-#000 b-#fff'
  83. : 'bg-#0F0820 text-#fff b-#fff'
  84. "
  85. @click="solution = item.key"
  86. >
  87. <div>{{ item.title }}</div>
  88. </div>
  89. </div>
  90. <div class="w-1200-auto pos-relative">
  91. <div class="flex items-center justify-end text-#fff text-14px fw-bold mb-20px cursor-pointer">
  92. View All
  93. <svgo-arrow-line-r class="w-16px h-16px ml-10px" />
  94. </div>
  95. <div
  96. 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"
  97. @click="onClickLeft()"
  98. >
  99. <img
  100. src="~/assets/images/swiper_icon2_l.png"
  101. alt=""
  102. class="!w-2430px !h-30px"
  103. srcset=""
  104. >
  105. </div>
  106. <div
  107. 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"
  108. @click="onClickRight()"
  109. >
  110. <img
  111. src="~/assets/images/swiper_icon2_r.png"
  112. alt=""
  113. class="!w-30px !h-30px"
  114. srcset=""
  115. >
  116. </div>
  117. <!-- @set-transition="setTransition" -->
  118. <Swiper
  119. v-if="categoryList.length"
  120. :slides-per-view="3"
  121. :space-between="20"
  122. :modules="modules"
  123. :centered-slides="true"
  124. :loop="true"
  125. :navigation="false"
  126. :pagination="true"
  127. class="pos-relative"
  128. @set-translate="setTranslate"
  129. @swiper="onVerticalSwiper"
  130. >
  131. <SwiperSlide v-for="(item, index) in categoryList" :key="index">
  132. <common-catalogs-item :item="item" />
  133. </SwiperSlide>
  134. </Swiper>
  135. </div>
  136. <img
  137. class="w-240px h-148px pos-absolute right-0 bottom--160px z-101"
  138. src="~/assets/images/catalogs_img01.png"
  139. alt=""
  140. >
  141. </div>
  142. </div>
  143. </template>
  144. <style lang="less" scoped>
  145. .swiper-slide{
  146. border-radius: 10px;
  147. background-color: #fff;
  148. }
  149. .custom-title-bg{
  150. position: relative;
  151. display: inline-block;
  152. background: url(~/assets/images/title_bg02.png);
  153. background-repeat: no-repeat;
  154. background-position: center 100%;
  155. background-size: 100% auto;
  156. padding-bottom: 8px;
  157. }
  158. </style>