疾病知识

v2
king 1 year ago committed by xing
parent c2ee704cf9
commit cccb057722
  1. 3
      .env.playedu
  2. 16
      src/pages/home/components/curRecommended.tsx
  3. 2
      src/pages/home/home.config.ts
  4. 11
      src/pages/home/home.tsx
  5. 2
      src/pages/preview/illness/list/list.config.ts
  6. 42
      src/pages/preview/illness/list/list.tsx
  7. 2
      src/pages/preview/illness/sort/sort.tsx

@ -1,2 +1,3 @@
TARO_APP_API=https://playedu.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top
TARO_APP_API=https://mooc.yaojiankang.top
TARO_APP_LGOIN=false TARO_APP_LGOIN=false

@ -16,13 +16,13 @@ const CurRecommended: FC = () => {
setTotal(res.total) setTotal(res.total)
const newData = res.data.reduce((pre, cut) => { const newData = res.data.reduce((pre, cut) => {
const index = pre.findIndex(d => d.id === cut.id) const index = pre.findIndex(d => d.id === cut.id)
if (index === 1) { if (index === -1) {
pre.push(cut) pre.push(cut)
} else { } else {
pre.splice(index, 1, cut) pre.splice(index, 1, cut)
} }
return pre return pre
}, data) }, JSON.parse(JSON.stringify(data)) as Curriculum[])
setData(newData) setData(newData)
} }
@ -42,12 +42,12 @@ const CurRecommended: FC = () => {
<View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}> <View className={'py-2 flex justify-between flex-wrap ' + styles.videoListBox}>
{ {
data.map(c => <VideoCover data.map(c => <VideoCover
thumb={c.thumb} thumb={c.thumb}
title={c.title} title={c.title}
id={c.id} id={c.id}
depId={c.id} depId={c.id}
key={c.id} key={c.id}
/>) />)
} }
</View> </View>
</View> </View>

@ -1,5 +1,5 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '首页', navigationBarTitleText: '首页',
navigationStyle: 'custom', navigationStyle: 'custom',
onReachBottomDistance: 30 onReachBottomDistance: 50
}) })

@ -1,6 +1,6 @@
import {FC} from "react"; import {FC} from "react";
import {View} from "@tarojs/components"; import {View} from "@tarojs/components";
import styles from "@/pages/index/index.module.scss"; import styles from "./home.module.scss";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import {Search} from "@/pages/home/components/search"; import {Search} from "@/pages/home/components/search";
import Adware from "@/pages/home/components/adware"; import Adware from "@/pages/home/components/adware";
@ -11,12 +11,15 @@ import MyButton from "@/components/button/MyButton";
import {Profile} from "@/store"; import {Profile} from "@/store";
const Home: FC = () => { const Home: FC = () => {
const globalData = Taro.getApp().globalData const menu = Taro.getMenuButtonBoundingClientRect()
const {token, empty} = Profile.useContainer() const {token, empty} = Profile.useContainer()
const headerStyle: React.CSSProperties = {
height: `${menu.bottom}px`,
}
return ( return (
<View className={styles.content} style={`paddingTop:${globalData.statusBarHeight + 30}px`}> <View className={styles.content} style={`paddingTop:${menu.bottom}px`}>
<View className={styles.header} style={`paddingTop:${globalData.statusBarHeight}px`}></View> <View className={styles.header} style={headerStyle}></View>
<Search/> <Search/>
<Adware/> <Adware/>
<Feature/> <Feature/>

@ -1,4 +1,4 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '', navigationBarTitleText: '疾病知识列表',
onReachBottomDistance: 30 onReachBottomDistance: 30
}) })

@ -1,12 +1,13 @@
import {FC, useCallback, useEffect, useState} from "react"; import {FC, useCallback, useEffect, useState} from "react";
import { View} from "@tarojs/components"; import {View} from "@tarojs/components";
import styles from './list.module.scss' import styles from './list.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
import Collapse from "@/components/collapse/collapse"; import Collapse from "@/components/collapse/collapse";
import {illnessApi} from "@/api/illness"; import {illnessApi} from "@/api/illness";
import Empty from "@/components/empty/empty";
const BrandList: FC = () => { const BrandList: FC = () => {
const params = useRouter().params as unknown as {id:number} const params = useRouter().params as unknown as { id: number }
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [brands, setBrands] = useState<any[]>([]) const [brands, setBrands] = useState<any[]>([])
const [total, setTotal] = useState(0) const [total, setTotal] = useState(0)
@ -17,7 +18,7 @@ const BrandList: FC = () => {
const getData = useCallback(async () => { const getData = useCallback(async () => {
try { try {
const data = await illnessApi.list(params.id,1, 100) const data = await illnessApi.list(params.id, 1, 100)
setTotal(data.total) setTotal(data.total)
setBrands([ setBrands([
...data.list ...data.list
@ -38,23 +39,24 @@ const BrandList: FC = () => {
return ( return (
<View className='p-2'> <View className='p-2'>
{ {
brands.length && brands.length > 0 ?
brands.map((d) => brands.map((d) =>
<View className={styles.box} > <View className={styles.box}>
<View className={styles.rightBox}> <View className={styles.rightBox}>
<Collapse title={d.name} children={ <Collapse title={d.name} children={
<> <>
{ {
d.articles?.map((d) => d.articles?.map((d) =>
<View onClick={() => {Taro.navigateTo({url: `/pages/preview/illness/article/article?id=${d.id}`})}} className='mt-2 font-28 ml-5'>{d.title}</View> <View onClick={() => {
Taro.navigateTo({url: `/pages/preview/illness/article/article?id=${d.id}`})
) }} className='mt-2 font-28 ml-5'>{d.title}</View>
} )
</> }
}></Collapse> </>
</View> }></Collapse>
</View> </View>
) </View>
):<Empty name='暂无数据'/>
} }
</View> </View>
) )

@ -53,7 +53,7 @@ const Sort: FC = () => {
<View className={styles.secondaryBox}> <View className={styles.secondaryBox}>
{ {
d.resource_category?.map(c => <View d.resource_category?.map(c => <View
onClick={() => jump(d.id)} onClick={() => jump(c.id)}
key={d.id} key={d.id}
className={styles.secondary}> className={styles.secondary}>
<View className='p-1'>{c.name}</View> <View className='p-1'>{c.name}</View>

Loading…
Cancel
Save