banner.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { Swiper, SwiperSlide } from 'swiper/vue'
  4. import { Autoplay, Navigation, Pagination } from 'swiper/modules'
  5. import { useUserStore } from '@/stores/modules/user'
  6. import 'swiper/css'
  7. import 'swiper/css/navigation'
  8. import 'swiper/css/autoplay'
  9. import { getHomeBrandListApi } from '~/api/model/brand'
  10. const userStore = useUserStore()
  11. const { isLogin } = storeToRefs(userStore)
  12. const modules = [Navigation, Pagination, Autoplay]
  13. const categoryList = ref<any>([])
  14. const swiperVertical = ref<any>(null)
  15. getHomeBrandList()
  16. async function getHomeBrandList() {
  17. try {
  18. const params = {
  19. pageNo: 1,
  20. pageSize: 8,
  21. }
  22. const data: any = await getHomeBrandListApi(params)
  23. categoryList.value = data.records
  24. }
  25. catch (error) {
  26. console.log('error', error)
  27. }
  28. }
  29. function onVerticalSwiper(swiper: any) {
  30. swiperVertical.value = swiper
  31. }
  32. function onClickLeft() {
  33. // swiperVertical.value.slideTo()
  34. swiperVertical.value.slidePrev()
  35. }
  36. function onClickRight() {
  37. // swiperVertical.value.slideTo(4)
  38. swiperVertical.value.slideNext()
  39. }
  40. function scrollToCatalogs() {
  41. const catalogs = document.getElementById('catalogs')
  42. if (catalogs)
  43. catalogs.scrollIntoView({ behavior: 'smooth', block: 'start' })
  44. }
  45. </script>
  46. <template>
  47. <div
  48. class="bg-#0F0820 data-section"
  49. data-section-color="#0F0820"
  50. >
  51. <div class="w-1200-auto pos-relative h-800px">
  52. <div class="text-center pos-absolute top-200px left-50% translate-x--50%">
  53. <div class="pos-relative">
  54. <h1 class="text-58px text-#fff fw-800 ls-2">
  55. Spark The Trend
  56. </h1>
  57. <h1 class="text-58px text-#fff fw-800 ls-2">
  58. Ignite Sales
  59. </h1>
  60. <div
  61. class="pos-absolute top--26px right--60px w-150px py-8px bg-#FFFF66 b-rd-20px transform-rotate-16deg"
  62. >
  63. #Trendy Product
  64. </div>
  65. <div
  66. class="pos-absolute bottom-24px left--46px py-8px w-120px text-#fff bg-#1AC18E b-rd-20px transform-rotate--12deg"
  67. >
  68. #Wholesale
  69. </div>
  70. </div>
  71. <el-button class="my-80px !b-#fff !text-#fff !bg-#878490" round @click="scrollToCatalogs">
  72. View Catalogs
  73. </el-button>
  74. </div>
  75. <div
  76. class="pos-absolute bottom--100px left-50% translate-x--50% w-1100px mx-auto"
  77. >
  78. <div
  79. class="pos-absolute cursor-pointer left--46px top-200px w-28px h-28px transform-translate-y--50% cursor-not-allowed !cursor-pointer flex justify-center items-center"
  80. @click="onClickLeft()"
  81. >
  82. <img
  83. src="~/assets/images/swiper_icon_l.png"
  84. alt=""
  85. class="!w-24px !h-24px"
  86. srcset=""
  87. >
  88. </div>
  89. <div
  90. class="pos-absolute cursor-pointer right--46px top-200px w-28px h-28px transform-translate-y--50% cursor-not-allowed !cursor-pointer flex justify-center items-center"
  91. @click="onClickRight()"
  92. >
  93. <img
  94. src="~/assets/images/swiper_icon_r.png"
  95. alt=""
  96. class="!w-24px !h-24px"
  97. srcset=""
  98. >
  99. </div>
  100. <Swiper
  101. v-if="categoryList.length"
  102. :slides-per-view="3"
  103. :space-between="30"
  104. :modules="modules"
  105. :centered-slides="true"
  106. :loop="true"
  107. :autoplay="{
  108. delay: 3000,
  109. disableOnInteraction: false,
  110. pauseOnMouseEnter: true,
  111. }"
  112. :navigation="false"
  113. :pagination="true"
  114. class="pos-relative"
  115. @swiper="onVerticalSwiper"
  116. >
  117. <SwiperSlide v-for="(item, index) in categoryList" :key="index">
  118. <common-category-item :item="item" />
  119. </SwiperSlide>
  120. </Swiper>
  121. </div>
  122. </div>
  123. </div>
  124. </template>
  125. <style lang="less" scoped>
  126. .swiper-slide {
  127. text-align: center;
  128. font-size: 18px;
  129. /* Center slide text vertically */
  130. display: -webkit-box;
  131. display: -ms-flexbox;
  132. display: -webkit-flex;
  133. display: flex;
  134. -webkit-box-pack: center;
  135. -ms-flex-pack: center;
  136. -webkit-justify-content: center;
  137. justify-content: center;
  138. -webkit-box-align: center;
  139. -ms-flex-align: center;
  140. -webkit-align-items: center;
  141. align-items: center;
  142. transition: 300ms;
  143. transform: scale(0.835);
  144. }
  145. .swiper-slide-active,
  146. .swiper-slide-duplicate-active {
  147. transform: scale(1);
  148. }
  149. </style>