From 9fb280b866f681e387bbd2a89a0081508990923f Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Tue, 5 Sep 2023 11:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E6=96=87=E7=AB=A0=E5=86=85=E5=AE=B9=E4=B8=8D=E8=B6=85?= =?UTF-8?q?=E8=BF=87=E5=8D=8A=E5=B1=8F=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/preview/brand/article/article.tsx | 45 ++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/pages/preview/brand/article/article.tsx b/src/pages/preview/brand/article/article.tsx index 05ed22f..4d54b99 100644 --- a/src/pages/preview/brand/article/article.tsx +++ b/src/pages/preview/brand/article/article.tsx @@ -1,4 +1,4 @@ -import {FC, useEffect, useMemo, useState} from "react"; +import {FC, useCallback, useEffect, useMemo, useState} from "react"; import {Image, Text, View} from "@tarojs/components"; import Taro, {useRouter} from "@tarojs/taro"; import {ArticleRecord, brandApi} from "@/api"; @@ -7,44 +7,69 @@ import down from "@/static/img/doubleDown.png"; import {Profile} from "@/store"; import {parse} from "@/utils/marked/marked"; import Empty from "@/components/empty/empty"; +import Spin from "@/components/spinner"; const article: FC = () => { const {token} = Profile.useContainer() + const [enable, setEnable] = useState(true) const {id} = useRouter().params as unknown as { id: number } const [articleInfo, setArticleInfo] = useState() + const [ultra, setUltra] = useState(true) + const globalData = Taro.getApp().globalData + const pageHeight = globalData.windowHeight - globalData.textBarHeight - globalData.statusBarHeight const {children} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) + useEffect(() => { - getData() - }, [id]) + const query = Taro.createSelectorQuery() + query.select('#childrenNode').boundingClientRect((res) => { + if (!Array.isArray(res)) { + if (res.height !== 240) { + console.log({childrenNode: res}) + setUltra(pageHeight * .45 < res.height) + } + } + }).exec() + }, [children]) + + Taro.useReady(() => { + getData().then() + }) - const getData = async () => { + const getData = useCallback(async () => { try { const data = await brandApi.articleInfo(id) Taro.setNavigationBarTitle({title: data.title}) + if (data.content.length < 200) { + setUltra(false) + } setArticleInfo(data) } catch (e) { } - } + setEnable(false) + }, [id]) function helloWorld() { return ( <> + - { - children.length > 0 ? children : - } + + { + children.length > 0 ? children : + } + { - !token && + !token && ultra && - + { Taro.navigateTo({url: '/pages/login/login'})