diff --git a/src/api/brand.ts b/src/api/brand.ts new file mode 100644 index 0000000..d33b2e1 --- /dev/null +++ b/src/api/brand.ts @@ -0,0 +1,22 @@ +import {request} from "@/api/request"; + +export type BrandRecord = { + id: number + introductory_video: string[] + brand_album: string[] + graphic_introduction: string + disabled: number +} + +export const brandApi = { + list(page: number , page_size: number) { + return request<{ + data: BrandRecord[], + total: number + }>(`/api/v1/department/index?page=${page}&page_size=${page_size}` , "GET") + }, + /** 学习记录 */ + info(id: number) { + return request(`/api/v1/user/record/${id}`, "GET") + }, +} diff --git a/src/api/index.ts b/src/api/index.ts index 341ea63..295c27f 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -5,4 +5,5 @@ export * from './meeting' export * from './public' export * from './manage' export * from './course' +export * from './brand' export * from './home' diff --git a/src/pages/brand/list/list.config.ts b/src/pages/brand/list/list.config.ts index 8617280..89c2e86 100644 --- a/src/pages/brand/list/list.config.ts +++ b/src/pages/brand/list/list.config.ts @@ -1,4 +1,4 @@ export default definePageConfig({ - navigationBarTitleText: '见面会记录', + navigationBarTitleText: '品牌列表', onReachBottomDistance: 30 }) diff --git a/src/pages/brand/list/list.tsx b/src/pages/brand/list/list.tsx index bbd5b0d..c7d5a9a 100644 --- a/src/pages/brand/list/list.tsx +++ b/src/pages/brand/list/list.tsx @@ -1,24 +1,28 @@ import {FC, useCallback, useEffect, useState} from "react"; import {View} from "@tarojs/components"; -import {Meeting, meetingAPi} from "@/api"; -import styles from './meetings.module.scss' +import {brandApi, BrandRecord, Meeting} from "@/api"; +import styles from './list.module.scss' import Taro, {useReachBottom} from "@tarojs/taro"; import Empty from "@/components/empty/empty"; import {formatDate} from "@/utils/time"; +import brandView from "@/pages/brand/list/components/BrandView"; const MeetingsConfig: FC = () => { const [page, setPage] = useState(1) - const [meeting, setMeeting] = useState([]) + const [brands, setBrands] = useState([]) const [total, setTotal] = useState(0) - const getData = useCallback(async () => { + useEffect(() => { + getData() + }, [page]) + + const getData = useCallback( async () => { try { - const res = await meetingAPi.setList(1, 10) - setTotal(res.total) - setMeeting([ - ...(meeting || []), - ...res.data - ]) + // const res = await brandApi.list(1, 10) + // setTotal(res.total) + // setBrands([ + // ...res.data + // ]) } catch (e) { } }, [page]) @@ -31,9 +35,9 @@ const MeetingsConfig: FC = () => { if (confirm) { await meetingAPi.del(id) - const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(meeting)) + const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(brandView)) oldMeeting.splice(index, 1) - setMeeting(oldMeeting) + setBrands(oldMeeting) } } }) @@ -49,21 +53,19 @@ const MeetingsConfig: FC = () => { } useReachBottom(useCallback(() => { - if (meeting?.length < total) { + if (brands?.length < total) { setPage(page + 1) } - }, [total, meeting])) + }, [total, brands])) + - useEffect(() => { - getData() - }, [page]) return ( { - meeting.length ? - meeting.map((d, index) => + brands.length ? + brands.map((d, index) => jumpInfo(d)}> {d.name} {formatDate(new Date(d.estimate_start_time), "MM-dd")} 至 {formatDate(new Date(d.estimate_start_time), "MM-dd")} @@ -75,7 +77,7 @@ const MeetingsConfig: FC = () => { del(d.id, index)}>删除 ) - : + : } )