From 50460bd891b491345eb42407c44f0d8c892884de Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Mon, 21 Aug 2023 18:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E4=B8=9A=E7=9F=A5=E8=AF=86=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/home.ts | 2 +- src/pages/preview/profession/profession.tsx | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) 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} + ) : }