diff --git a/src/pages/home/home.tsx b/src/pages/home/home.tsx index dc00b96..f65b8e1 100644 --- a/src/pages/home/home.tsx +++ b/src/pages/home/home.tsx @@ -12,6 +12,7 @@ import {HomeApi, HomeData} from "@/api"; import logo from '@/static/img/logo.svg' import Spin from "@/components/spinner"; import NavigationBar from "@/components/navigationBar/navigationBar"; +// import {Search} from "./components/search" const Home: FC = () => { const globalData = Taro.getApp().globalData diff --git a/src/pages/preview/collect/collect.tsx b/src/pages/preview/collect/collect.tsx index 98f6667..b81243f 100644 --- a/src/pages/preview/collect/collect.tsx +++ b/src/pages/preview/collect/collect.tsx @@ -23,6 +23,7 @@ const Profession = () => { const [data, setData] = useState>(new Map) const [enable, setEnable] = useState(true) + /** * more 开启加载更多 */ @@ -62,31 +63,31 @@ const Profession = () => { } } - Taro.useDidShow(useCallback(() => { - if (categoryId) { - let tempMap = new Map() - tempMap.set(categoryId, { - data: [], - total: undefined, - page: 1 - }) - setData(tempMap) - getData() - } - }, [data])) useEffect(() => { console.log(categoryId,'categoryId') categoryId && getData() }, [categoryId]) - async function getCategory() { + Taro.useDidShow(async () => { + const oldData = new Map(data) + if (categoryId) { + const data = await userApi.collectList(categoryId!, 1, 10) + oldData.delete(categoryId) + oldData.set(categoryId, { + data: data.list, + total: data.total, + page: 1 + }) + setData(oldData) + } + }) + async function getCategory() { const res = [{name: '视频', id: 2}, {name: '文章', id: 1}, {name: '课程', id: 3}, {name: '其他', id: 4}] const newTabs = res.map(d => ({title: d.name, value: d.id})) setTabs(newTabs) setCategoryId(newTabs[0].value as number) - // setEnable(false) } @@ -95,7 +96,7 @@ const Profession = () => { } function jumpInfo(info: any) { - console.log(info, 'info') + if (info.article) { Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${info.owner_id}`}) } else if (info.course) { @@ -105,6 +106,9 @@ const Profession = () => { } else if (info.brand) { Taro.navigateTo({url: `/pages/preview/brand/info/info?id=${info.owner_id}`}) } + + + } function swiperChange(e) { diff --git a/src/pages/preview/search/search/components/list.tsx b/src/pages/preview/search/search/components/list.tsx index 6928569..fd91ce7 100644 --- a/src/pages/preview/search/search/components/list.tsx +++ b/src/pages/preview/search/search/components/list.tsx @@ -28,12 +28,14 @@ const SearchList: FC = ({name, clear}) => { setLoading(true) } }, [clear]) + useEffect(() => { if (name && clear) { getData() } }, [page, name, clear]) + const getData = useCallback(async () => { try { const data = await SearchApi.list(page, 10, name)