swiperBrands.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <script lang='ts' setup>
  2. import { Swiper, SwiperSlide } from 'swiper/vue'
  3. import { Navigation, Pagination } from 'swiper/modules'
  4. import {
  5. getSimilarBrandListApi,
  6. } from '~/api/model/brand'
  7. // import "swiper/css/pagination"
  8. import 'swiper/css'
  9. import 'swiper/css/navigation'
  10. const swiperVertical = ref<any>(null)
  11. const modules = [Navigation, Pagination]
  12. const similarBrandList = ref<any>([])
  13. async function getCategoryBrandList() {
  14. try {
  15. const params = {
  16. pageNo: 1,
  17. pageSize: 20,
  18. }
  19. const data: any = await getSimilarBrandListApi(params)
  20. similarBrandList.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.slidePrev()
  31. }
  32. function onClickRight() {
  33. swiperVertical.value.slideNext()
  34. }
  35. getCategoryBrandList()
  36. </script>
  37. <template>
  38. <div class="w-1400px mx-auto mb-160px">
  39. <h2 class="!mb-60px fw-700 text-40px text-#363C40 text-center">
  40. Collection Brands in This Category
  41. </h2>
  42. <div class="w-1300px mx-auto pos-relative">
  43. <div
  44. 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"
  45. @click="onClickLeft()"
  46. >
  47. <img src="~/assets/images/arrow_left.png" alt="" class="w-26px h-26px" srcset="">
  48. </div>
  49. <div
  50. 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"
  51. @click="onClickRight()"
  52. >
  53. <img src="~/assets/images/arrow_right.png" alt="" class="w-26px h-26px" srcset="">
  54. </div>
  55. <Swiper
  56. v-if="similarBrandList.length"
  57. :slides-per-view="4" :space-between="55" :modules="modules" :loop="true" :navigation="false"
  58. :pagination="true" class="pos-relative" @swiper="onVerticalSwiper"
  59. >
  60. <SwiperSlide v-for="(item, index) in similarBrandList" :key="index">
  61. <common-brand-item :item="item" />
  62. </SwiperSlide>
  63. </Swiper>
  64. </div>
  65. <div class="flex justify-center items-center cursor-pointer mt-60px">
  66. <div class="underline fw-500 text-24px hover:text-#CC9879">
  67. View All
  68. </div>
  69. <svgo-arrow class="!w-12px !h-12px ml-14px" />
  70. </div>
  71. </div>
  72. </template>
  73. <style lang='less' scoped>
  74. </style>