|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import {FC, useCallback, useEffect, useMemo, useState} from "react"; |
|
|
|
|
import {Image, PageContainer, Text, View} from "@tarojs/components"; |
|
|
|
|
import Taro, {useRouter} from "@tarojs/taro"; |
|
|
|
|
import {ArticleRecord, brandApi} from "@/api"; |
|
|
|
|
import {ArticleRecord, brandApi, HomeApi} from "@/api"; |
|
|
|
|
import styles from "./article.module.scss"; |
|
|
|
|
import down from "@/static/img/doubleDown.png"; |
|
|
|
|
import {Profile} from "@/store"; |
|
|
|
@ -13,6 +13,7 @@ import Img from "@/components/image/image"; |
|
|
|
|
import Collect from "@/components/collect/collect"; |
|
|
|
|
import catalogue from "@/static/img/catalogue-inactive.png"; |
|
|
|
|
import Icon from "@/components/icon"; |
|
|
|
|
import articlesEvent from "@/hooks/articlesEvent"; |
|
|
|
|
|
|
|
|
|
const article: FC = () => { |
|
|
|
|
const {token} = Profile.useContainer() |
|
|
|
@ -25,6 +26,8 @@ const article: FC = () => { |
|
|
|
|
const {children, headings} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) |
|
|
|
|
const query = Taro.createSelectorQuery() |
|
|
|
|
const [maoId, setMaoId] = useState('') |
|
|
|
|
const [timing, setTiming] = useState<NodeJS.Timeout | undefined>(undefined) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
setTimeout(() => { |
|
|
|
@ -69,9 +72,24 @@ const article: FC = () => { |
|
|
|
|
getData().then() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
Taro.useUnload(() => { |
|
|
|
|
clearTimeout(timing) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const getData = useCallback(async () => { |
|
|
|
|
try { |
|
|
|
|
const data = await brandApi.articleInfo(id) |
|
|
|
|
|
|
|
|
|
setTiming(setTimeout(() => { |
|
|
|
|
HomeApi.articleViews(id).then(() => { |
|
|
|
|
setArticleInfo({ |
|
|
|
|
...data, |
|
|
|
|
page_view: data.page_view + 1 |
|
|
|
|
}) |
|
|
|
|
articlesEvent.recordsAdd({id: Number(id), view: (data?.page_view || 0) + 1}) |
|
|
|
|
}) |
|
|
|
|
}, 10000)) |
|
|
|
|
|
|
|
|
|
Taro.setNavigationBarTitle({title: data.title}) |
|
|
|
|
if (data.content.length < 200) { |
|
|
|
|
setUltra(false) |
|
|
|
@ -124,7 +142,7 @@ const article: FC = () => { |
|
|
|
|
<View>{d?.name}</View> |
|
|
|
|
<View className='flex mt-1 text-muted font-24'> |
|
|
|
|
<View className='mr-2'>{beforeTime(articleInfo?.created_at)} . </View> |
|
|
|
|
<View>阅读 {articleInfo.page_view || 1}</View> |
|
|
|
|
<View>阅读 {articleInfo.page_view || 0}</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -152,7 +170,7 @@ const article: FC = () => { |
|
|
|
|
<View>{d?.name}</View> |
|
|
|
|
<View className='flex mt-1 text-muted font-24'> |
|
|
|
|
<View className='mr-2'>{beforeTime(articleInfo?.created_at)} . </View> |
|
|
|
|
<View>阅读 {articleInfo.page_view || 1}</View> |
|
|
|
|
<View>阅读 {articleInfo.page_view || 0}</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|