brands.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // import "swiper/css/pagination"
  9. const modules = [Navigation, Pagination]
  10. const brandList = ref<any>([])
  11. const swiperVertical = ref<any>(null)
  12. getHomeBrandList()
  13. async function getHomeBrandList() {
  14. try {
  15. const params = {
  16. pageNo: 1,
  17. pageSize: 8,
  18. }
  19. const data: any = await getHomeBrandListApi(params)
  20. brandList.value = data.records
  21. }
  22. catch (error) {
  23. console.log('error', error)
  24. }
  25. }
  26. function onVerticalSwiper(swiper: any) {
  27. swiperVertical.value = swiper
  28. }
  29. function onClickLeft() {
  30. // swiperVertical.value.slideTo()
  31. swiperVertical.value.slidePrev()
  32. }
  33. function onClickRight() {
  34. // swiperVertical.value.slideTo(4)
  35. swiperVertical.value.slideNext()
  36. }
  37. </script>
  38. <template>
  39. <div class="pt-100px text-center">
  40. <h2 class="fw-600 text-40px text-#363C40 custom-title-font">
  41. Our Top Brands
  42. </h2>
  43. <div class="mt-20px w-500px mx-auto text-#999 text-16px lh-24px">
  44. Wholesale unique and high-quality products from trusted Chinese brands,
  45. all in one place.
  46. </div>
  47. <div class="my-60px">
  48. <div class="w-1300px mx-auto pos-relative">
  49. <div
  50. 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"
  51. @click="onClickLeft()"
  52. >
  53. <img src="~/assets/images/arrow_left.png" alt="" class="w-26px h-26px" srcset="">
  54. </div>
  55. <div
  56. 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"
  57. @click="onClickRight()"
  58. >
  59. <img src="~/assets/images/arrow_right.png" alt="" class="w-26px h-26px" srcset="">
  60. </div>
  61. <Swiper
  62. v-if="brandList.length" :slides-per-view="4" :space-between="55" :modules="modules" :loop="true" :navigation="false"
  63. :pagination="true" class="pos-relative" @swiper="onVerticalSwiper"
  64. >
  65. <SwiperSlide v-for="(item, index) in brandList" :key="index">
  66. <common-brand-item :item="item" />
  67. </SwiperSlide>
  68. </Swiper>
  69. </div>
  70. </div>
  71. <div class="flex justify-center items-center">
  72. <NuxtLink to="/suppliers/all-brands" class="flex justify-center items-center cursor-pointer">
  73. <div class="underline fw-600 text-#5B463E text-22px hover:text-#CC9879 custom-title-font">
  74. View All
  75. </div>
  76. <svgo-arrow class="!w-20px !h-20px ml-16px" />
  77. </NuxtLink>
  78. </div>
  79. </div>
  80. </template>
  81. <style lang="less" scoped></style>