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'})