main
king 1 year ago
parent b6134378f0
commit af5acef018
  1. 9
      src/api/illness.ts
  2. 2
      src/pages/preview/illness/article/article.config.ts
  3. 1
      src/pages/preview/illness/article/article.tsx
  4. 4
      src/pages/preview/illness/list/list.config.ts
  5. 38
      src/pages/preview/illness/list/list.module.scss
  6. 51
      src/pages/preview/illness/list/list.tsx
  7. 20
      src/pages/preview/illness/sort/sort.module.scss
  8. 31
      src/pages/preview/illness/sort/sort.tsx

@ -4,12 +4,9 @@ import {request} from "@/api/request";
export const illnessApi = {
/** 疾病列表 */
list(id: number, page: number, page_size: number) {
return request<{
list: any[],
total: number,
}>(`/home/v1/illness/list?page=${page}&page_size=${page_size}&id=${id}` , "GET")
return request<{ list: any[], total: number }>(`/home/v1/illness/list`, "GET", {page, page_size, id})
},
articleInfo(id: number ) {
return request<{ content: string }>(`/home/v1/article/${id}` , "GET")
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})
},
}

@ -1,4 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '',
onReachBottomDistance: 30
onReachBottomDistance: 50
})

@ -13,7 +13,6 @@ const article:FC = () => {
const [show,setShow] = useState(false)
const [articleInfo,setArticleInfo] = useState<ArticleRecord>()
const { children, headings } = useMemo(() => parse(articleInfo?.content || ''), [articleInfo])
console.log(headings,'headings')
const query = Taro.createSelectorQuery()

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

@ -1,34 +1,8 @@
page{
background-color: #fff !important;
}
.box {
display: flex;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 16rpx;
box-sizing: border-box;
}
.image{
width: 128rpx;
height:128rpx;
background-color: pink;
border-radius: 8rpx;
}
.rightBox{
padding-left: 24rpx;
box-sizing: border-box;
flex: 1;
}
.desc{
font-size: 24rpx;
.brands {
font-size: 28rpx;
font-family: PingFang SC-Medium, PingFang SC;
font-weight: 500;
color: #909795;
line-height: 34rpx;
display: -webkit-box;
word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
color: #323635;
padding: 30rpx;
border-bottom: 1px solid #F5F8F7;
}

@ -2,7 +2,6 @@ import {FC, useCallback, useEffect, useState} from "react";
import {View} from "@tarojs/components";
import styles from './list.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
import Collapse from "@/components/collapse/collapse";
import {illnessApi} from "@/api/illness";
import Empty from "@/components/empty/empty";
@ -14,29 +13,25 @@ const BrandList: FC = () => {
const [fetchDone, setFetchDone] = useState(false)
useEffect(() => {
Taro.showLoading({
title: '加载中',
mask: true
})
setTimeout(function () {
Taro.hideLoading()
setFetchDone(true)
}, 800)
getData()
Taro.showLoading({title: '加载中', mask: true})
getData().then()
}, [page])
const getData = useCallback(async () => {
try {
const data = await illnessApi.list(params.id, 1, 100)
const data = await illnessApi.articleInfo(params.id, page, 20)
setTotal(data.total)
setBrands([
...data.list
])
Taro.setNavigationBarTitle({title: data.list?.[0].resourceCategories?.[0]?.name ?? '文章列表'})
setBrands([...brands, ...data.list])
} catch (e) {
}
setFetchDone(true)
Taro.hideLoading()
}, [page])
function jump(id: number) {
Taro.navigateTo({url: '/pages/preview/illness/article/article?id=' + id})
}
useReachBottom(useCallback(() => {
if (brands?.length < total) {
@ -46,29 +41,13 @@ const BrandList: FC = () => {
return (
<View className='p-2' style={{display:fetchDone?'block':'none'}}>
<View style={{display: fetchDone ? 'block' : 'none'}} className='px-2 pt-2 bg-white'>
{
brands.length > 0 ?
brands.map((d) =>
<View className={styles.box}>
<View className={styles.rightBox}>
<Collapse title={d.name} children={
<>
{
d.articles?.map((d) => <View
onClick={() => {
Taro.navigateTo({url: `/pages/preview/illness/article/article?id=${d.id}`})
}}
className='py-3 font-36'
style={{borderBottom: "1px solid #ddd"}}
>{d.title}</View>
)
}
</>
}></Collapse>
</View>
</View>
) : <Empty name='暂无数据'/>
brands.map((d, index) => <View key={d.id} className={styles.brands} onClick={() => jump(d.id)}>
{index + 1} . {d.title}
</View>)
: <Empty name='暂无文章'/>
}
</View>
)

@ -1,6 +1,16 @@
.scrollView{
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
display: flex;
}
.firstOrder {
width: 300rpx;
height: calc(100vh - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 200rpx);
height: 100%;
View {
width: 100%;
@ -54,10 +64,16 @@
padding: 0 15rpx;
background: #fff;
box-sizing: border-box;
height: calc(100vh - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 200rpx)
height: 100%;
}
.list {
padding: 20rpx;
border-bottom: 1px solid #F5F8F7;
width: 100%;
min-height: 100rpx;
color: #323635;
box-sizing: border-box;
display: flex;
align-items: center;
}

@ -4,7 +4,6 @@ import {Category, HomeApi} from "@/api";
import Taro from "@tarojs/taro";
import styles from './sort.module.scss'
import Tabs, {TabList} from "@/components/tabs/tabs";
import {Search} from "@/pages/home/components/search";
import {illnessApi} from "@/api/illness";
import Empty from "@/components/empty/empty";
import leftArrow from "@/static/img/leftArrow.png"
@ -16,10 +15,10 @@ const Sort: FC = () => {
const [secondId, setSecondId] = useState<number | undefined>(undefined)
const [list, setList] = useState<any[]>([])
const globalData = Taro.getApp().globalData
const menu = Taro.getMenuButtonBoundingClientRect()
async function getData() {
const res = await HomeApi.category(3)
setData(res)
@ -30,7 +29,7 @@ const Sort: FC = () => {
}
function jump(id: number) {
Taro.navigateTo({url: '/pages/preview/illness/article/article?id=' + id})
Taro.navigateTo({url: '/pages/preview/illness/list/list?id=' + id})
}
const getTabList = useMemo((): TabList[] => {
@ -48,10 +47,6 @@ const Sort: FC = () => {
paddingLeft: '10px'
}
function onConfirm(value: string) {
console.log(value)
}
function firstIdChange(id: number) {
setFirstId(id)
const resource_category = data.find(d => d.id === id)?.resource_category
@ -64,16 +59,14 @@ const Sort: FC = () => {
if (secondId) {
Taro.showLoading({title: '加载中'})
illnessApi.list(secondId, 1, 100).then(res => {
const data = []
res.list.forEach(d => {
data.push(...d.articles as [])
})
setList(data)
setList(res.list)
}).finally(() => {
Taro.hideLoading()
}).catch(() => {
setList([])
})
} else {
setList([])
}
}, [secondId])
@ -86,13 +79,11 @@ const Sort: FC = () => {
onClick={() => Taro.navigateBack()}/>
<Tabs tabList={getTabList} onChange={(data) => firstIdChange(data.tab?.value as number)}/>
</View>
<Search onConfirm={onConfirm}/>
<View className='flex'>
<ScrollView
scrollY
scrollWithAnimation
scrollIntoView={`${prefix}-${secondId}`}
className={styles.firstOrder}>
{/*<Search onConfirm={onConfirm}/>*/}
<View className={styles.scrollView} style={{top: `${globalData.statusBarHeight + 59}px`}}>
<ScrollView scrollY className={styles.firstOrder}>
{
data.find(d => d.id === firstId)?.resource_category?.map(d => <View
id={`${prefix}-${d.id}`}
@ -110,7 +101,7 @@ const Sort: FC = () => {
scrollWithAnimation>
{
list.length ?
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.title}</View>)
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>)
: <Empty name='暂无数据'/>
}
</ScrollView>

Loading…
Cancel
Save