diff --git a/src/pages/home/components/feature_recommended.tsx b/src/pages/home/components/feature_recommended.tsx index 8de747f..01e3396 100644 --- a/src/pages/home/components/feature_recommended.tsx +++ b/src/pages/home/components/feature_recommended.tsx @@ -110,7 +110,7 @@ const FeatureRecommended: FC = () => { return res.list.map(d => ({ id: d.id, imageUrl: '', - description: d.content, + description: d.content?.replace(/[^\u4e00-\u9fa5]/gi,"") ?? '暂无描述', title: d.title, path: `?id=${d.id}` })) @@ -155,7 +155,7 @@ const FeatureRecommended: FC = () => { {c.title} - {c.description} + {c.description || '暂无描述'} ) } diff --git a/src/pages/preview/brand/article/article.tsx b/src/pages/preview/brand/article/article.tsx index a0f341f..64fa15c 100644 --- a/src/pages/preview/brand/article/article.tsx +++ b/src/pages/preview/brand/article/article.tsx @@ -1,16 +1,18 @@ -import {FC, useEffect, useState} from "react"; +import {FC, useEffect, useMemo, useState} from "react"; import {Image, Text, View} from "@tarojs/components"; import Taro, {useRouter} from "@tarojs/taro"; import {ArticleRecord, brandApi} from "@/api"; import styles from "@/pages/preview/illness/article/article.module.scss"; import down from "@/static/img/doubleDown.png"; import {Profile} from "@/store"; +import {parse} from "@/utils/marked/marked"; const article:FC = () => { - const {token,empty} = Profile.useContainer() + const {token,} = Profile.useContainer() const {id} = useRouter().params as unknown as { id: number} const [articleInfo,setArticleInfo] = useState() + const { children } = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) useEffect(() => { getData() }, [id]) @@ -24,10 +26,11 @@ const article:FC = () => { } } function helloWorld() { - const html = articleInfo?.content; return ( <> - + + { children } + { !token && @@ -35,7 +38,7 @@ const article:FC = () => { - + {Taro.navigateTo({url: '/pages/login/login'})}}> 登录查看更多内容 diff --git a/src/pages/preview/brand/list/list.tsx b/src/pages/preview/brand/list/list.tsx index 25ca4c8..6b315aa 100644 --- a/src/pages/preview/brand/list/list.tsx +++ b/src/pages/preview/brand/list/list.tsx @@ -9,14 +9,30 @@ const BrandList: FC = () => { const [page, setPage] = useState(1) const [brands, setBrands] = useState([]) const [total, setTotal] = useState(0) + const [text, setText] = useState('') useEffect(() => { + Taro.showLoading({ + title: '加载中', + mask: true + }) + setTimeout(function () { + Taro.hideLoading() + }, 650) getData() }, [page]) const getData = useCallback(async () => { try { + setText('加载中..') const res = await brandApi.list(page, 10) + if(page === 1){ + if(res.list.length < 10) { + setText('没有更多了~') + }else{ + setText('上拉加载更多~') + } + } setTotal(res.total) setBrands([ ...brands, @@ -34,22 +50,27 @@ const BrandList: FC = () => { useReachBottom(useCallback(() => { if (brands?.length < total) { setPage(page + 1) + }else{ + setText('没有更多了~') } }, [total, brands])) return ( - + { - brands.length ? brands.map((d) => - jumpInfo(d.id)} className={styles.box} key={d.id}> + brands.length ? + <> + { brands.map((d) => jumpInfo(d.id)} className={styles.box} key={d.id}> {d.name} {d.graphic_introduction} ) - : + } + {text} + : } ) diff --git a/src/pages/preview/illness/article/article.tsx b/src/pages/preview/illness/article/article.tsx index 45f3250..9da4689 100644 --- a/src/pages/preview/illness/article/article.tsx +++ b/src/pages/preview/illness/article/article.tsx @@ -63,14 +63,14 @@ const article:FC = () => { - + Taro.navigateTo({url: '/pages/login/login'})}> 登录查看更多内容 } - + { setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0.3)'} > {headings.length > 0 && headings.map((d) =>