|
|
@ -11,7 +11,6 @@ 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 [articles, setArticles] = 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) |
|
|
|
const [enable, setEnable] = useState(true) |
|
|
|
const [enable, setEnable] = useState(true) |
|
|
@ -24,7 +23,6 @@ const BrandList: FC = () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const data = await illnessApi.articleInfo(params.id, page, 20) |
|
|
|
const data = await illnessApi.articleInfo(params.id, page, 20) |
|
|
|
Taro.setNavigationBarTitle({title: data?.illness?.name || '暂无文章'}) |
|
|
|
Taro.setNavigationBarTitle({title: data?.illness?.name || '暂无文章'}) |
|
|
|
// setIllness(data.illness)
|
|
|
|
|
|
|
|
setTotal(data.list.total) |
|
|
|
setTotal(data.list.total) |
|
|
|
setArticles([...articles, ...data.list.list]) |
|
|
|
setArticles([...articles, ...data.list.list]) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
@ -34,8 +32,14 @@ const BrandList: FC = () => { |
|
|
|
Taro.hideLoading() |
|
|
|
Taro.hideLoading() |
|
|
|
}, [page]) |
|
|
|
}, [page]) |
|
|
|
|
|
|
|
|
|
|
|
function jump(id: number) { |
|
|
|
function jump(data: any, index: number) { |
|
|
|
Taro.navigateTo({url: '/pages/preview/brand/article/article?id=' + id}) |
|
|
|
Taro.navigateTo({url: '/pages/preview/brand/article/article?id=' + data.id}) |
|
|
|
|
|
|
|
const oldArticles: any[] = JSON.parse(JSON.stringify(articles)) |
|
|
|
|
|
|
|
oldArticles.splice(index, 1, { |
|
|
|
|
|
|
|
...data, |
|
|
|
|
|
|
|
page_view: data.page_view + 1 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
setArticles(oldArticles) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -54,7 +58,7 @@ const BrandList: FC = () => { |
|
|
|
<> |
|
|
|
<> |
|
|
|
<View className='bg-white rounded-20 clip'> |
|
|
|
<View className='bg-white rounded-20 clip'> |
|
|
|
{ |
|
|
|
{ |
|
|
|
articles.map((d, i) => <View className='p-3 relative' onClick={() => jump(d.id)}> |
|
|
|
articles.map((d, i) => <View className='p-3 relative' onClick={() => jump(d, i)}> |
|
|
|
{i > 0 && <View className='absolute top left right divided ml-3 mr-3'/>} |
|
|
|
{i > 0 && <View className='absolute top left right divided ml-3 mr-3'/>} |
|
|
|
<View className="font-34 text-black">{d.title}</View> |
|
|
|
<View className="font-34 text-black">{d.title}</View> |
|
|
|
{(d.intro || '').length > 40 && (<View className='flex mt-1'> |
|
|
|
{(d.intro || '').length > 40 && (<View className='flex mt-1'> |
|
|
|