brands.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { getCollectBrandsListApi } from '@/api/model/my'
  4. import { PageSizeEnum } from '~/enums/sizeEnum'
  5. const props = defineProps<{
  6. activeName: string
  7. }>()
  8. const list = ref<any[]>([])
  9. const currentPage = ref(PageSizeEnum.PAGE)
  10. const total = ref()
  11. const page_size = ref(8)
  12. watch(() => props.activeName, (newVal) => {
  13. if (newVal === 'following')
  14. getCollectBrandsList()
  15. }, { immediate: true })
  16. async function getCollectBrandsList(pageNo = currentPage.value, pageSize = page_size.value) {
  17. const data: any = await getCollectBrandsListApi({
  18. pageNo,
  19. pageSize,
  20. })
  21. total.value = data.total
  22. currentPage.value = data.current
  23. list.value = data.records
  24. }
  25. function changePage(current: number, size: number) {
  26. getCollectBrandsList(current, size)
  27. }
  28. </script>
  29. <template>
  30. <div class="min-h-400px flex items-center">
  31. <div v-if="list.length">
  32. <div class="grid grid-gap-y-41px grid-gap-x-55px grid-cols-4">
  33. <div v-for="item in list" :key="item.id">
  34. <common-brand-item :item />
  35. </div>
  36. </div>
  37. <div class="mt-60px flex justify-center">
  38. <el-pagination
  39. v-model:current-page="currentPage"
  40. :page-size="page_size"
  41. :pager-count="10"
  42. layout="prev, pager, next" :total="total"
  43. @change="changePage"
  44. />
  45. </div>
  46. </div>
  47. <common-empty v-else />
  48. </div>
  49. </template>
  50. <style lang="less" scoped></style>