banner.vue 4.5 KB

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