diff --git a/src/api/home.ts b/src/api/home.ts index 0bf1f18..f8817b0 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -58,6 +58,6 @@ export const HomeApi = { return request('/home/v1/skill/category', "GET") }, skillList(categoryId: number, page: number, page_size: number) { - return request('/home/v1/skill/index', "GET", {categoryId, page, page_size}) + return request<{ data: Kill[], total: number }>('/home/v1/skill/index', "GET", {categoryId, page, page_size}) } } diff --git a/src/pages/preview/profession/profession.tsx b/src/pages/preview/profession/profession.tsx index 806da8b..4d93131 100644 --- a/src/pages/preview/profession/profession.tsx +++ b/src/pages/preview/profession/profession.tsx @@ -1,17 +1,21 @@ -import {View} from "@tarojs/components"; +import {Image, View} from "@tarojs/components"; import {HomeApi} from "@/api"; import {useEffect, useState} from "react"; import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; import Empty from "@/components/empty/empty"; +import Taro from "@tarojs/taro"; const Profession = () => { const [tabs, setTabs] = useState([]) const [page, setPage] = useState(1) const [categoryId, setCategoryId] = useState(null) - const [data, setData] = useState([]) + const [data, setData] = useState([]) + const [total, setTotal] = useState(0) async function getData(categoryId: number) { const res = await HomeApi.skillList(categoryId, page, 10) + setTotal(res.total) + setData(res.data) } useEffect(() => { @@ -30,6 +34,10 @@ const Profession = () => { setCategoryId(tab.tab?.value as number) } + function jump(url: string) { + Taro.navigateTo({url: '/pages/preview/videoFull/videoFull?url=' + url}) + } + useEffect(() => { getCategory().then() }, []) @@ -42,7 +50,10 @@ const Profession = () => { { data.length > 0 - ? data.map(d => {JSON.stringify(d)}) + ? data.map(d => jump(d.resource.url)}> + + {d.resource.name} + ) : }