疾病列表调整

v2
一杯沧海 1 year ago
parent 8e465b9d03
commit 1eb468a699
  1. 3
      src/api/illness.ts
  2. 2
      src/pages/home/components/feature_recommended.tsx
  3. 2
      src/pages/preview/illness/list/list.config.ts
  4. 2
      src/pages/preview/illness/list/list.module.scss
  5. 17
      src/pages/preview/illness/list/list.tsx

@ -7,6 +7,7 @@ export const illnessApi = {
return request<{ list: any[], total: number }>(`/home/v1/illness/list`, "GET", {page, page_size, id}) return request<{ list: any[], total: number }>(`/home/v1/illness/list`, "GET", {page, page_size, id})
}, },
articleInfo(owner_id: number, page: number, page_size: number) { articleInfo(owner_id: number, page: number, page_size: number) {
return request<{ list: any[], total: number }>(`/home/v1/article/illness_list`, "GET", {page, page_size, owner_id}) return request<{ illness:{name:string;description:string;resource:any;album:string[]};list:{list: any[], total: number} }>
(`/home/v1/article/illness_list`, "GET", {page, page_size, owner_id})
}, },
} }

@ -61,7 +61,7 @@ const FeatureRecommended: FC<Props> = (props) => {
{ {
titleUrl: illnessTop, titleUrl: illnessTop,
url: '/pages/preview/illness/sort/sort', url: '/pages/preview/illness/sort/sort',
detailsUrl: '/pages/preview/illness/article/article', detailsUrl: '/pages/preview/illness/list/list',
data: [] data: []
}, },
]) ])

@ -1,4 +1,4 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '文章列表', navigationBarTitleText: '',
onReachBottomDistance: 50 onReachBottomDistance: 50
}) })

@ -1,4 +1,4 @@
.brands { .articles {
font-size: 28rpx; font-size: 28rpx;
font-family: PingFang SC-Medium, PingFang SC; font-family: PingFang SC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;

@ -8,7 +8,8 @@ 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 [articles, setArticles] = useState<any[]>([])
const [illness,setIllness] = useState<{name:string;description:string;resource:any;album:string[]}>()
const [total, setTotal] = useState(0) const [total, setTotal] = useState(0)
const [fetchDone, setFetchDone] = useState(false) const [fetchDone, setFetchDone] = useState(false)
@ -20,8 +21,10 @@ const BrandList: FC = () => {
const getData = useCallback(async () => { const getData = useCallback(async () => {
try { try {
const data = await illnessApi.articleInfo(params.id, page, 20) const data = await illnessApi.articleInfo(params.id, page, 20)
setTotal(data.total) Taro.setNavigationBarTitle({title:data.illness.name})
setBrands([...brands, ...data.list]) setIllness(data.illness)
setTotal(data.list.total)
setArticles([...articles, ...data.list.list])
} catch (e) { } catch (e) {
} }
setFetchDone(true) setFetchDone(true)
@ -34,17 +37,17 @@ const BrandList: FC = () => {
useReachBottom(useCallback(() => { useReachBottom(useCallback(() => {
if (brands?.length < total) { if (articles?.length < total) {
setPage(page + 1) setPage(page + 1)
} }
}, [total, brands])) }, [total, articles]))
return ( return (
<View style={{display: fetchDone ? 'block' : 'none'}} className='px-2 mt-2 bg-white'> <View style={{display: fetchDone ? 'block' : 'none'}} className='px-2 mt-2 bg-white'>
{ {
brands.length > 0 ? articles.length > 0 ?
brands.map((d, index) => <View key={d.id} className={styles.brands} onClick={() => jump(d.id)}> articles.map((d, index) => <View key={d.id} className={styles.articles} onClick={() => jump(d.id)}>
{index + 1} . {d.title} {index + 1} . {d.title}
</View>) </View>)
: <Empty name='暂无文章'/> : <Empty name='暂无文章'/>

Loading…
Cancel
Save