banner.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 class="bg-#0F0820">
  48. <div class="w-1200-auto pos-relative h-800px">
  49. <div class="text-center pos-absolute top-200px left-50% translate-x--50%">
  50. <div class="pos-relative">
  51. <h1 class="text-58px text-#fff fw-800 ls-2">
  52. Spark The Trend
  53. </h1>
  54. <h1 class="text-58px text-#fff fw-800 ls-2">
  55. Ignite Sales
  56. </h1>
  57. <div
  58. class="pos-absolute top--26px right--60px w-150px py-8px bg-#FFFF66 b-rd-20px transform-rotate-16deg"
  59. >
  60. #Trendy Product
  61. </div>
  62. <div
  63. class="pos-absolute bottom-24px left--46px py-8px w-120px text-#fff bg-#1AC18E b-rd-20px transform-rotate--12deg"
  64. >
  65. #Wholesale
  66. </div>
  67. </div>
  68. <el-button class="my-80px !b-#fff !text-#fff !bg-#878490" round @click="scrollToCatalogs">
  69. View Catalogs
  70. </el-button>
  71. </div>
  72. <div
  73. class="pos-absolute bottom--100px left-50% translate-x--50% w-1100px mx-auto"
  74. >
  75. <div
  76. 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"
  77. @click="onClickLeft()"
  78. >
  79. <img
  80. src="~/assets/images/swiper_icon_l.png"
  81. alt=""
  82. class="!w-24px !h-24px"
  83. srcset=""
  84. >
  85. </div>
  86. <div
  87. 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"
  88. @click="onClickRight()"
  89. >
  90. <img
  91. src="~/assets/images/swiper_icon_r.png"
  92. alt=""
  93. class="!w-24px !h-24px"
  94. srcset=""
  95. >
  96. </div>
  97. <Swiper
  98. v-if="categoryList.length"
  99. :slides-per-view="3"
  100. :space-between="30"
  101. :modules="modules"
  102. :centered-slides="true"
  103. :loop="true"
  104. :autoplay="{
  105. delay: 3000,
  106. disableOnInteraction: false,
  107. pauseOnMouseEnter: true,
  108. }"
  109. :navigation="false"
  110. :pagination="true"
  111. class="pos-relative"
  112. @swiper="onVerticalSwiper"
  113. >
  114. <SwiperSlide v-for="(item, index) in categoryList" :key="index">
  115. <common-category-item :item="item" />
  116. </SwiperSlide>
  117. </Swiper>
  118. </div>
  119. </div>
  120. </div>
  121. </template>
  122. <style lang="less" scoped>
  123. .swiper-slide {
  124. text-align: center;
  125. font-size: 18px;
  126. /* Center slide text vertically */
  127. display: -webkit-box;
  128. display: -ms-flexbox;
  129. display: -webkit-flex;
  130. display: flex;
  131. -webkit-box-pack: center;
  132. -ms-flex-pack: center;
  133. -webkit-justify-content: center;
  134. justify-content: center;
  135. -webkit-box-align: center;
  136. -ms-flex-align: center;
  137. -webkit-align-items: center;
  138. align-items: center;
  139. transition: 300ms;
  140. transform: scale(0.835);
  141. }
  142. .swiper-slide-active,
  143. .swiper-slide-duplicate-active {
  144. transform: scale(1);
  145. }
  146. </style>