|
|
|
@ -19,18 +19,17 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl |
|
|
|
|
/> |
|
|
|
|
} else if (data.brand_album) { |
|
|
|
|
media = <Img |
|
|
|
|
// width={712}
|
|
|
|
|
height={320} |
|
|
|
|
src={data.brand_album.split(",")[0]} |
|
|
|
|
mode="aspectFill" |
|
|
|
|
style={{background: '#ededed'}} |
|
|
|
|
onClick={onClick} |
|
|
|
|
/> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className="bg-white flex flex-column justify-stretch mb-2_4 rounded-10 clip"> |
|
|
|
|
<View className="p-3" onClick={onClick}> |
|
|
|
|
<View className="p-3"> |
|
|
|
|
<View onClick={onClick}> |
|
|
|
|
<View className='mb-2 font-32 flex'> |
|
|
|
|
<Img |
|
|
|
|
width={76} |
|
|
|
@ -54,13 +53,15 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl |
|
|
|
|
<View className="font-24 text-muted mb-4 text-row3 mt-2" style={{lineHeight: 1.4}}> |
|
|
|
|
{data.graphic_introduction} |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<View className="flex gap20rpx font-24 text-muted justify-around"> |
|
|
|
|
<View className={styles.feature}> |
|
|
|
|
<Image src={articleLine}/> |
|
|
|
|
{data.article_count || 0} |
|
|
|
|
</View> |
|
|
|
|
<Collect/> |
|
|
|
|
{JSON.stringify(data.collect)} |
|
|
|
|
<Collect owner_id={data.id} owner_type={4} select={data.collect}/> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -78,9 +79,13 @@ const BrandList: FC = () => { |
|
|
|
|
getData() |
|
|
|
|
}, [page]) |
|
|
|
|
|
|
|
|
|
const getData = useCallback(async () => { |
|
|
|
|
Taro.useDidShow(() => { |
|
|
|
|
brands.length && getData(true) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const getData = useCallback(async (replace = false) => { |
|
|
|
|
try { |
|
|
|
|
const res = await brandApi.list(page, 10) |
|
|
|
|
const res = await brandApi.list(replace ? 1 : page, replace ? 10 * page : 10) |
|
|
|
|
if (page === 1) { |
|
|
|
|
if (res.list.length < 10) { |
|
|
|
|
setText('暂无更多') |
|
|
|
@ -89,10 +94,16 @@ const BrandList: FC = () => { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
setTotal(res.total) |
|
|
|
|
setBrands([ |
|
|
|
|
...brands, |
|
|
|
|
...res.list |
|
|
|
|
]) |
|
|
|
|
const data = res.list.reduce((pre, cur) => { |
|
|
|
|
const index = pre.findIndex(d => d.id === cur.id) |
|
|
|
|
if (index > -1) { |
|
|
|
|
pre.splice(index, 1, cur) |
|
|
|
|
} else { |
|
|
|
|
pre.push(cur) |
|
|
|
|
} |
|
|
|
|
return pre |
|
|
|
|
}, JSON.parse(JSON.stringify(brands))) |
|
|
|
|
setBrands(data) |
|
|
|
|
} catch (e) { |
|
|
|
|
} |
|
|
|
|
setLoading(false) |
|
|
|
@ -111,22 +122,18 @@ const BrandList: FC = () => { |
|
|
|
|
} |
|
|
|
|
}, [total, brands])) |
|
|
|
|
|
|
|
|
|
let content: ReactNode |
|
|
|
|
if (brands.length) { |
|
|
|
|
content = ( |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className='p-2'> |
|
|
|
|
<Spinner enable={loading} overlay/> |
|
|
|
|
{ |
|
|
|
|
brands.length ? |
|
|
|
|
<> |
|
|
|
|
{brands.map(d => <BrandItem data={d} key={d.id} onClick={() => jumpInfo(d.id)}/>)} |
|
|
|
|
<View className='text-center font-24 text-dark mt-3'>{text}</View> |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
content = <Empty name='暂无品牌入驻'/> |
|
|
|
|
: <Empty name='暂无品牌入驻'/> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className='p-2'> |
|
|
|
|
<Spinner enable={loading} overlay/> |
|
|
|
|
{content} |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|