|
@@ -1,13 +1,14 @@
|
|
<!-- @format -->
|
|
<!-- @format -->
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
|
+import { onMounted, ref } from 'vue'
|
|
import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
import { Autoplay, Navigation, Pagination } from 'swiper/modules'
|
|
import { Autoplay, Navigation, Pagination } from 'swiper/modules'
|
|
|
|
+import { ConstKeys } from '~/enums/const-enums'
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
import 'swiper/css'
|
|
import 'swiper/css'
|
|
import 'swiper/css/navigation'
|
|
import 'swiper/css/navigation'
|
|
import 'swiper/css/autoplay'
|
|
import 'swiper/css/autoplay'
|
|
-import { getHomeBrandListApi } from '~/api/model/brand'
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
const { isLogin } = storeToRefs(userStore)
|
|
const { isLogin } = storeToRefs(userStore)
|
|
@@ -15,20 +16,11 @@ const modules = [Navigation, Pagination, Autoplay]
|
|
const categoryList = ref<any>([])
|
|
const categoryList = ref<any>([])
|
|
const swiperVertical = ref<any>(null)
|
|
const swiperVertical = ref<any>(null)
|
|
|
|
|
|
-getHomeBrandList()
|
|
|
|
-async function getHomeBrandList() {
|
|
|
|
- try {
|
|
|
|
- const params = {
|
|
|
|
- pageNo: 1,
|
|
|
|
- pageSize: 8,
|
|
|
|
- }
|
|
|
|
- const data: any = await getHomeBrandListApi(params)
|
|
|
|
- categoryList.value = data.records
|
|
|
|
- }
|
|
|
|
- catch (error) {
|
|
|
|
- console.log('error', error)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+const { data, pending, error, refresh } = await useAsyncData(
|
|
|
|
+ 'brand-detail',
|
|
|
|
+ () => $fetch(`${ConstKeys.DOMAINPRO}/client/brand/list/default`, { params: { pageNo: 1, pageSize: 8 } }),
|
|
|
|
+)
|
|
|
|
+categoryList.value = data.value?.result.records
|
|
|
|
|
|
function onVerticalSwiper(swiper: any) {
|
|
function onVerticalSwiper(swiper: any) {
|
|
swiperVertical.value = swiper
|
|
swiperVertical.value = swiper
|
|
@@ -46,6 +38,12 @@ function scrollToCatalogs() {
|
|
if (catalogs)
|
|
if (catalogs)
|
|
catalogs.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
catalogs.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
}
|
|
}
|
|
|
|
+onUnmounted(() => {
|
|
|
|
+ if (swiperVertical.value) {
|
|
|
|
+ swiperVertical.value.destroy()
|
|
|
|
+ swiperVertical.value = null
|
|
|
|
+ }
|
|
|
|
+})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -74,11 +72,12 @@ function scrollToCatalogs() {
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <el-button class="my-80px !b-#fff !text-#fff !bg-#878490" round @click="scrollToCatalogs">
|
|
|
|
|
|
+ <el-button class="my-80px !text-#fff !bg-#878490 !w-160px !h-40px !b-#fff !b-rd-400px" round @click="scrollToCatalogs">
|
|
View Catalogs
|
|
View Catalogs
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
|
|
+ v-if="categoryList.length"
|
|
class="pos-absolute bottom--100px left-50% translate-x--50% w-1100px mx-auto"
|
|
class="pos-absolute bottom--100px left-50% translate-x--50% w-1100px mx-auto"
|
|
>
|
|
>
|
|
<div
|
|
<div
|
|
@@ -104,7 +103,6 @@ function scrollToCatalogs() {
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
<Swiper
|
|
<Swiper
|
|
- v-if="categoryList.length"
|
|
|
|
:slides-per-view="3"
|
|
:slides-per-view="3"
|
|
:space-between="30"
|
|
:space-between="30"
|
|
:modules="modules"
|
|
:modules="modules"
|