|
|
|
@ -19,40 +19,40 @@ 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='mb-2 font-32 flex'> |
|
|
|
|
<Img |
|
|
|
|
width={76} |
|
|
|
|
height={76} |
|
|
|
|
src={data.logo} |
|
|
|
|
mode='aspectFill' |
|
|
|
|
errorType='avatar' |
|
|
|
|
className="rounded-10 clip" |
|
|
|
|
style={{background: '#ededed'}} |
|
|
|
|
/> |
|
|
|
|
<View className="ml-2 flex-1"> |
|
|
|
|
<View className="text-row1 font-28">{data.name}</View> |
|
|
|
|
<View className='font-24 mt-2 text-muted'>{beforeTime(data.created_at)}·加入</View> |
|
|
|
|
<View className="p-3"> |
|
|
|
|
<View onClick={onClick}> |
|
|
|
|
<View className='mb-2 font-32 flex'> |
|
|
|
|
<Img |
|
|
|
|
width={76} |
|
|
|
|
height={76} |
|
|
|
|
src={data.logo} |
|
|
|
|
mode='aspectFill' |
|
|
|
|
errorType='avatar' |
|
|
|
|
className="rounded-10 clip" |
|
|
|
|
style={{background: '#ededed'}} |
|
|
|
|
/> |
|
|
|
|
<View className="ml-2 flex-1"> |
|
|
|
|
<View className="text-row1 font-28">{data.name}</View> |
|
|
|
|
<View className='font-24 mt-2 text-muted'>{beforeTime(data.created_at)}·加入</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<View className={styles.previewImag}> |
|
|
|
|
{media} |
|
|
|
|
</View> |
|
|
|
|
<View className={styles.previewImag}> |
|
|
|
|
{media} |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<View className="font-24 text-muted mb-4 text-row3 mt-2" style={{lineHeight: 1.4}}> |
|
|
|
|
{data.graphic_introduction} |
|
|
|
|
<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"> |
|
|
|
@ -60,7 +60,8 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl |
|
|
|
|
<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 = ( |
|
|
|
|
<> |
|
|
|
|
{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='暂无品牌入驻'/> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className='p-2'> |
|
|
|
|
<Spinner enable={loading} overlay/> |
|
|
|
|
{content} |
|
|
|
|
{ |
|
|
|
|
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> |
|
|
|
|
</> |
|
|
|
|
: <Empty name='暂无品牌入驻'/> |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|