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