12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { getBrandListApi } from '~/api/model/brand'
- import { PageSizeEnum } from '~/enums/sizeEnum'
- export function useBrandData(options?: any) {
- const selectedCategoryId = ref('')
- const currentPage = ref(PageSizeEnum.PAGE)
- const page_size = ref(12)
- const total = ref()
- const activeIndex = ref<any>('')
- const brandList = ref<any>([])
- const getBrandList = async (
- params?: any,
- pageNo = currentPage.value,
- pageSize = page_size.value,
- ) => {
- const data: any = await getBrandListApi({
- ...params,
- pageNo,
- pageSize,
- })
- total.value = data.total
- currentPage.value = data.current
- brandList.value = data.records
- }
- const handleSelectedCategory = (key: any) => {
- selectedCategoryId.value = key
- getBrandList({ categoryId: key }, PageSizeEnum.PAGE, page_size.value)
- }
- const changePage = (current: number, size: number) => {
- getBrandList({ categoryId: selectedCategoryId.value || '' }, current, size)
- const dom: any = document.getElementById('app-scroller')
- dom.scrollTo({
- top: 400,
- behavior: 'smooth',
- })
- }
- const updateGoodsList = () => {
- changePage(currentPage.value, page_size.value)
- }
- return { handleSelectedCategory, page_size, brandList, currentPage, selectedCategoryId, changePage, updateGoodsList, getBrandList, total, activeIndex }
- }
|