专业知识

main
king 1 year ago
parent 5f0da7ce0f
commit 73cfd07fca
  1. 7
      src/api/home.ts
  2. 1
      src/app.config.ts
  3. 4
      src/pages/home/components/feature.tsx
  4. 20
      src/pages/home/components/feature_recommended.tsx
  5. 17
      src/pages/preview/health/health.tsx
  6. 4
      src/pages/preview/profession/profession.config.ts
  7. 51
      src/pages/preview/profession/profession.tsx

@ -1,4 +1,5 @@
import {request} from "@/api/request"; import {request} from "@/api/request";
import {Category} from "@/api/public";
export interface AdwareParams { export interface AdwareParams {
key: string key: string
@ -52,5 +53,11 @@ export const HomeApi = {
/** 技能 */ /** 技能 */
skillTop(count: number) { skillTop(count: number) {
return request<Kill[]>('/home/v1/skill/top', "GET", {count}) return request<Kill[]>('/home/v1/skill/top', "GET", {count})
},
skillCategory() {
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})
} }
} }

@ -83,6 +83,7 @@ export default defineAppConfig({
'brand/list/list', 'brand/list/list',
'brand/info/info', 'brand/info/info',
'brand/article/article', 'brand/article/article',
'profession/profession',
'health/health', // 健康 'health/health', // 健康
'videoFull/videoFull', // 资源id 视频全屏 'videoFull/videoFull', // 资源id 视频全屏
] ]

@ -9,8 +9,8 @@ import Taro from "@tarojs/taro";
const Feature: FC = () => { const Feature: FC = () => {
const list = [ const list = [
{url: '/pages/preview/brand/list/list', image: article, text: '品牌'}, {url: '/pages/preview/brand/list/list', image: article, text: '品牌'},
{url: '', image: health, text: '健康管理'}, {url: '/pages/preview/health/health', image: health, text: '健康管理'},
{url: '', image: profession, text: '专业技能'}, {url: '/pages/preview/profession/profession', image: profession, text: '专业技能'},
{url: '', image: illness, text: '疾病知识'}, {url: '', image: illness, text: '疾病知识'},
] ]

@ -24,17 +24,22 @@ interface Data {
const FeatureRecommended: FC = () => { const FeatureRecommended: FC = () => {
const [data, setData] = useState<Data[]>([ const [data, setData] = useState<Data[]>([
{title: "品牌TOP3", url: '', detailsUrl: '', data: []}, {
title: "品牌TOP3",
url: '/pages/preview/brand/list/list',
detailsUrl: '/pages/preview/brand/info/info',
data: []
},
{ {
title: "健康知识TOP3", title: "健康知识TOP3",
url: '/pages/preview/health/health', url: '/pages/preview/health/health',
detailsUrl: '/pages/preview/videoFull/videoFull?url=', detailsUrl: '/pages/preview/videoFull/videoFull',
data: [] data: []
}, },
{ {
url: '', url: '/pages/preview/profession/profession',
title: "专业技能TOP3", title: "专业技能TOP3",
detailsUrl: '/pages/preview/videoFull/videoFull?url=', detailsUrl: '/pages/preview/videoFull/videoFull',
data: [] data: []
}, },
{title: "疾病知识TOP3", url: '', detailsUrl: '', data: []}, {title: "疾病知识TOP3", url: '', detailsUrl: '', data: []},
@ -49,7 +54,7 @@ const FeatureRecommended: FC = () => {
title: d.name, title: d.name,
imageUrl: d.brand_album, imageUrl: d.brand_album,
description: d.graphic_introduction, description: d.graphic_introduction,
path: '', path: `?id=${d.id}`,
})) }))
} catch (e) { } catch (e) {
} }
@ -65,7 +70,7 @@ const FeatureRecommended: FC = () => {
title: d.title, title: d.title,
imageUrl: d.url_path, imageUrl: d.url_path,
description: d.introduction, description: d.introduction,
path: d.resource.url path: `?url=${d.resource.url}`
})) }))
} catch (e) { } catch (e) {
} }
@ -81,7 +86,7 @@ const FeatureRecommended: FC = () => {
imageUrl: d.url_path, imageUrl: d.url_path,
description: '', description: '',
title: d.resource.name, title: d.resource.name,
path: d.resource.url path: `?url=${d.resource.url}`
})) }))
} catch (e) { } catch (e) {
} }
@ -99,7 +104,6 @@ const FeatureRecommended: FC = () => {
}, []) }, [])
function jump(url: string) { function jump(url: string) {
console.log(url)
Taro.navigateTo({url}) Taro.navigateTo({url})
} }

@ -4,6 +4,7 @@ import {HomeApi} from "@/api";
import Taro, {useReachBottom} from "@tarojs/taro"; import Taro, {useReachBottom} from "@tarojs/taro";
import styles from './health.module.scss' import styles from './health.module.scss'
import play from '@/static/img/play.png' import play from '@/static/img/play.png'
import Empty from "@/components/empty/empty";
const Health: FC = () => { const Health: FC = () => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
@ -33,12 +34,16 @@ const Health: FC = () => {
<ScrollView> <ScrollView>
<View className={styles.container}> <View className={styles.container}>
{ {
data.map(d => <View key={d.id} className={styles.health} onClick={() => jump(d.resource.url, d.id)}> data.length > 0
<Image src={d.url_path} mode='widthFix' lazyLoad fadeIn/> ? data.map(d => <View key={d.id}
<Image src={play} className={styles.play} mode='aspectFit'/> className={styles.health}
<View className='text-ellipsis-2 m-2 text-dark'>{d.title}</View> onClick={() => jump(d.resource.url, d.id)}>
<View className='font-26 text-muted mx-2 mb-2'>{d.video_view}</View> <Image src={d.url_path} mode='widthFix' lazyLoad fadeIn/>
</View>) <Image src={play} className={styles.play} mode='aspectFit'/>
<View className='text-ellipsis-2 m-2 text-dark'>{d.title}</View>
<View className='font-26 text-muted mx-2 mb-2'>{d.video_view}</View>
</View>)
: <Empty name='暂无数据'/>
} }
</View> </View>
</ScrollView> </ScrollView>

@ -0,0 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '专业知识',
onReachBottomDistance: 30
})

@ -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<TabList[]>([])
const [page, setPage] = useState(1)
const [categoryId, setCategoryId] = useState<number | null>(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<TabList>(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 (
<>
<View className='bg-white'>
<Tabs tabList={tabs} onChange={tabsChange}/>
</View>
{
data.length > 0
? data.map(d => <View>{JSON.stringify(d)}</View>)
: <Empty name='暂无数据'/>
}
</>
)
}
export default Profession
Loading…
Cancel
Save