专业知识列表

v2
king 1 year ago committed by xing
parent a6fed2ec3a
commit 50460bd891
  1. 2
      src/api/home.ts
  2. 17
      src/pages/preview/profession/profession.tsx

@ -58,6 +58,6 @@ export const HomeApi = {
return request<Category[]>('/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})
}
}

@ -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<TabList[]>([])
const [page, setPage] = useState(1)
const [categoryId, setCategoryId] = useState<number | null>(null)
const [data, setData] = useState([])
const [data, setData] = useState<Kill[]>([])
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 => <View>{JSON.stringify(d)}</View>)
? data.map(d => <View className='flex bg-white mt-2' onClick={() => jump(d.resource.url)}>
<Image src={d.url_path} style={{width: '200px', height: '100px', marginRight: '10px'}}/>
<View className='text-ellipsis'>{d.resource.name}</View>
</View>)
: <Empty name='暂无数据'/>
}
</>

Loading…
Cancel
Save