|
|
|
@ -1,14 +1,14 @@ |
|
|
|
|
import {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
|
import {Swiper, SwiperItem, Text, Video, View} from "@tarojs/components"; |
|
|
|
|
import {ArticleRecord, brandApi, BrandRecord} from "@/api"; |
|
|
|
|
import { brandApi, BrandRecord} from "@/api"; |
|
|
|
|
import styles from './info.module.scss' |
|
|
|
|
import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; |
|
|
|
|
import LineEllipsis from "@/components/textCollapse/collapse"; |
|
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
|
import Img from "@/components/image/image"; |
|
|
|
|
import {rfc33392time} from "@/utils/day"; |
|
|
|
|
import Spin from "@/components/spinner"; |
|
|
|
|
import Collect from "@/components/collect/collect"; |
|
|
|
|
import ArticlesBox from "@/components/articlesBox/articlesBox"; |
|
|
|
|
|
|
|
|
|
type Params = { |
|
|
|
|
id: number |
|
|
|
@ -16,7 +16,7 @@ type Params = { |
|
|
|
|
const BrandInfo: FC = () => { |
|
|
|
|
const {id} = useRouter().params as unknown as Params |
|
|
|
|
const [brandInfo, setBrandInfo] = useState<BrandRecord>() |
|
|
|
|
const [articleList, setArticleList] = useState<ArticleRecord[]>([]) |
|
|
|
|
const [articleList, setArticleList] = useState<Articles[]>([]) |
|
|
|
|
const [curIndex, setCurIndex] = useState<number>(1) |
|
|
|
|
const [page, setPage] = useState(1) |
|
|
|
|
const [total, setTotal] = useState(0) |
|
|
|
@ -64,15 +64,6 @@ const BrandInfo: FC = () => { |
|
|
|
|
setCurIndex(+e.detail.current + 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function jump(data: ArticleRecord, index: number) { |
|
|
|
|
Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${data.id}`}) |
|
|
|
|
const oldArticle: ArticleRecord[] = JSON.parse(JSON.stringify(articleList)) |
|
|
|
|
oldArticle.splice(index, 1, { |
|
|
|
|
...data, |
|
|
|
|
page_view: (data.page_view || 1) + 1 |
|
|
|
|
}) |
|
|
|
|
setArticleList(oldArticle) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className='flex flex-column' style={{display: 'flex'}}> |
|
|
|
@ -106,7 +97,7 @@ const BrandInfo: FC = () => { |
|
|
|
|
(brandInfo?.brand_album?.length || 0) > 0 |
|
|
|
|
&& brandInfo?.brand_album?.split(',').map((d) => |
|
|
|
|
<SwiperItem> |
|
|
|
|
<Img mode={'aspectFill'} width={750} height={600} src={d}/> |
|
|
|
|
<Img mode={'aspectFill'} width={750} height={600} src={d} errorType='brand'/> |
|
|
|
|
</SwiperItem>) |
|
|
|
|
} |
|
|
|
|
</Swiper> |
|
|
|
@ -123,23 +114,13 @@ const BrandInfo: FC = () => { |
|
|
|
|
<Text className={`${styles['title']} flex-1`}>{brandInfo?.name}</Text> |
|
|
|
|
<Collect owner_type={4} owner_id={id} select={brandInfo?.collect}/> |
|
|
|
|
</View> |
|
|
|
|
<LineEllipsis text={brandInfo?.graphic_introduction || '暂无简介'}></LineEllipsis> |
|
|
|
|
<LineEllipsis text={brandInfo?.graphic_introduction || '暂无简介'}/> |
|
|
|
|
</View> |
|
|
|
|
<View className={styles['bottom']}> |
|
|
|
|
{ |
|
|
|
|
articleList?.length ? <>{ |
|
|
|
|
articleList.map((i, index) => <View className={styles.box} onClick={() => jump(i, index)}> |
|
|
|
|
<View className={styles.inner}> |
|
|
|
|
<View className={styles.leftBox}> |
|
|
|
|
<View className='font-weight mb-2 font-28 lh-40'>{i.title}</View> |
|
|
|
|
<View className={styles.desc}>{rfc33392time(i.created_at)} {i.page_view || 1}阅读</View> |
|
|
|
|
</View> |
|
|
|
|
<View className={styles.image}> |
|
|
|
|
<Img width={172} height={128} src={i.cover} errorType='brand'/> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View>)} |
|
|
|
|
<View className='text-center font-24 text-dark'>暂无更多</View> |
|
|
|
|
articleList.map(d => <ArticlesBox data={d}/>)} |
|
|
|
|
<View className='text-center font-24 text-dark mt-3'>暂无更多</View> |
|
|
|
|
</> |
|
|
|
|
: <Empty name='空空如也'/> |
|
|
|
|
} |
|
|
|
|