diff --git a/src/api/home.ts b/src/api/home.ts index 3b39499..0bf1f18 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -1,4 +1,5 @@ import {request} from "@/api/request"; +import {Category} from "@/api/public"; export interface AdwareParams { key: string @@ -52,5 +53,11 @@ export const HomeApi = { /** 技能 */ skillTop(count: number) { return request('/home/v1/skill/top', "GET", {count}) + }, + skillCategory() { + 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}) } } diff --git a/src/app.config.ts b/src/app.config.ts index 8e793b3..8a383d5 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -83,6 +83,7 @@ export default defineAppConfig({ 'brand/list/list', 'brand/info/info', 'brand/article/article', + 'profession/profession', 'health/health', // 健康 'videoFull/videoFull', // 资源id 视频全屏 ] diff --git a/src/pages/home/components/feature.tsx b/src/pages/home/components/feature.tsx index f82dd0b..0ab46de 100644 --- a/src/pages/home/components/feature.tsx +++ b/src/pages/home/components/feature.tsx @@ -9,8 +9,8 @@ import Taro from "@tarojs/taro"; const Feature: FC = () => { const list = [ {url: '/pages/preview/brand/list/list', image: article, text: '品牌'}, - {url: '', image: health, text: '健康管理'}, - {url: '', image: profession, text: '专业技能'}, + {url: '/pages/preview/health/health', image: health, text: '健康管理'}, + {url: '/pages/preview/profession/profession', image: profession, text: '专业技能'}, {url: '', image: illness, text: '疾病知识'}, ] diff --git a/src/pages/home/components/feature_recommended.tsx b/src/pages/home/components/feature_recommended.tsx index 1444989..779a5e7 100644 --- a/src/pages/home/components/feature_recommended.tsx +++ b/src/pages/home/components/feature_recommended.tsx @@ -24,17 +24,22 @@ interface Data { const FeatureRecommended: FC = () => { const [data, setData] = useState([ - {title: "品牌TOP3", url: '', detailsUrl: '', data: []}, + { + title: "品牌TOP3", + url: '/pages/preview/brand/list/list', + detailsUrl: '/pages/preview/brand/info/info', + data: [] + }, { title: "健康知识TOP3", url: '/pages/preview/health/health', - detailsUrl: '/pages/preview/videoFull/videoFull?url=', + detailsUrl: '/pages/preview/videoFull/videoFull', data: [] }, { - url: '', + url: '/pages/preview/profession/profession', title: "专业技能TOP3", - detailsUrl: '/pages/preview/videoFull/videoFull?url=', + detailsUrl: '/pages/preview/videoFull/videoFull', data: [] }, {title: "疾病知识TOP3", url: '', detailsUrl: '', data: []}, @@ -49,7 +54,7 @@ const FeatureRecommended: FC = () => { title: d.name, imageUrl: d.brand_album, description: d.graphic_introduction, - path: '', + path: `?id=${d.id}`, })) } catch (e) { } @@ -65,7 +70,7 @@ const FeatureRecommended: FC = () => { title: d.title, imageUrl: d.url_path, description: d.introduction, - path: d.resource.url + path: `?url=${d.resource.url}` })) } catch (e) { } @@ -81,7 +86,7 @@ const FeatureRecommended: FC = () => { imageUrl: d.url_path, description: '', title: d.resource.name, - path: d.resource.url + path: `?url=${d.resource.url}` })) } catch (e) { } @@ -99,7 +104,6 @@ const FeatureRecommended: FC = () => { }, []) function jump(url: string) { - console.log(url) Taro.navigateTo({url}) } diff --git a/src/pages/preview/health/health.tsx b/src/pages/preview/health/health.tsx index b85116a..d6d59b4 100644 --- a/src/pages/preview/health/health.tsx +++ b/src/pages/preview/health/health.tsx @@ -4,6 +4,7 @@ import {HomeApi} from "@/api"; import Taro, {useReachBottom} from "@tarojs/taro"; import styles from './health.module.scss' import play from '@/static/img/play.png' +import Empty from "@/components/empty/empty"; const Health: FC = () => { const [page, setPage] = useState(1) @@ -33,12 +34,16 @@ const Health: FC = () => { { - data.map(d => jump(d.resource.url, d.id)}> - - - {d.title} - {d.video_view}观看 - ) + data.length > 0 + ? data.map(d => jump(d.resource.url, d.id)}> + + + {d.title} + {d.video_view}观看 + ) + : } diff --git a/src/pages/preview/profession/profession.config.ts b/src/pages/preview/profession/profession.config.ts new file mode 100644 index 0000000..72f4ae5 --- /dev/null +++ b/src/pages/preview/profession/profession.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '专业知识', + onReachBottomDistance: 30 +}) diff --git a/src/pages/preview/profession/profession.tsx b/src/pages/preview/profession/profession.tsx new file mode 100644 index 0000000..806da8b --- /dev/null +++ b/src/pages/preview/profession/profession.tsx @@ -0,0 +1,51 @@ +import {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"; + +const Profession = () => { + const [tabs, setTabs] = useState([]) + const [page, setPage] = useState(1) + const [categoryId, setCategoryId] = useState(null) + const [data, setData] = useState([]) + + async function getData(categoryId: number) { + const res = await HomeApi.skillList(categoryId, page, 10) + } + + useEffect(() => { + categoryId && getData(categoryId) + }, [categoryId, page]) + + async function getCategory() { + const res = await HomeApi.skillCategory() + const newTabs = res.map(d => ({title: d.name, value: d.id})) + setTabs(newTabs) + setCategoryId(newTabs[0].value as number) + } + + function tabsChange(tab: OnChangOpt) { + setPage(1) + setCategoryId(tab.tab?.value as number) + } + + useEffect(() => { + getCategory().then() + }, []) + + return ( + <> + + + + + { + data.length > 0 + ? data.map(d => {JSON.stringify(d)}) + : + } + + ) +} +export default Profession