banner.vue 4.0 KB

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