From 45a4a70246fd70a4a2ed5cf3dabc18e3ff71f7db Mon Sep 17 00:00:00 2001 From: sunlizhou <296190577@qq.com> Date: Fri, 25 Aug 2023 17:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=89=8C=E5=88=97=E8=A1=A8=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E6=8B=89=E5=8A=A0=E8=BD=BD=EF=BC=8C=E5=8F=8A=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/components/feature_recommended.tsx | 4 +-- src/pages/preview/brand/article/article.tsx | 13 +++++---- src/pages/preview/brand/list/list.tsx | 29 ++++++++++++++++--- src/pages/preview/illness/article/article.tsx | 4 +-- 4 files changed, 37 insertions(+), 13 deletions(-) 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) =>