|
|
|
@ -15,7 +15,6 @@ const Adware: FC<Props> = ({data, only_flag, width}) => { |
|
|
|
|
const [adverts, setAdverts] = useState<AdwareType[]>([]) |
|
|
|
|
const [space, setSpace] = useState<any | null>(null) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
const res = data.find(d => d.only_flag === only_flag) |
|
|
|
|
setSpace(res) |
|
|
|
@ -31,36 +30,40 @@ const Adware: FC<Props> = ({data, only_flag, width}) => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View className={styles.adware}> |
|
|
|
|
{ |
|
|
|
|
adverts.length === 1 && <Img |
|
|
|
|
src={adverts[0].image_url} |
|
|
|
|
mode='scaleToFill' |
|
|
|
|
lazyLoad |
|
|
|
|
fadeIn |
|
|
|
|
onClick={() => jumpAdware(adverts[0].image_path)} |
|
|
|
|
width={width} |
|
|
|
|
height={(space.height / space.width) * width}/> |
|
|
|
|
} |
|
|
|
|
<> |
|
|
|
|
{ |
|
|
|
|
adverts.length > 1 && <Swiper |
|
|
|
|
indicatorDots |
|
|
|
|
autoplay |
|
|
|
|
circular |
|
|
|
|
style={{width: width + "rpx", height: (space.height / space.width) * width + "rpx", overflow: 'hidden'}} |
|
|
|
|
indicatorActiveColor='rgba(255,255,255,0.5)'> |
|
|
|
|
{adverts.map(d => <SwiperItem key={d.id}> |
|
|
|
|
<Img |
|
|
|
|
src={d.image_url} |
|
|
|
|
adverts.length > 0 && <View className={styles.adware}> |
|
|
|
|
{ |
|
|
|
|
adverts.length === 1 && <Img |
|
|
|
|
src={adverts[0].image_url} |
|
|
|
|
mode='scaleToFill' |
|
|
|
|
lazyLoad |
|
|
|
|
fadeIn |
|
|
|
|
onClick={() => jumpAdware(adverts[0].image_path)} |
|
|
|
|
width={width} |
|
|
|
|
height={(space.height / space.width) * width} |
|
|
|
|
onClick={() => jumpAdware(d.image_path)}/> |
|
|
|
|
</SwiperItem>)} |
|
|
|
|
</Swiper> |
|
|
|
|
height={(space.height / space.width) * width}/> |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
adverts.length > 1 && <Swiper |
|
|
|
|
indicatorDots |
|
|
|
|
autoplay |
|
|
|
|
circular |
|
|
|
|
style={{width: width + "rpx", height: (space.height / space.width) * width + "rpx", overflow: 'hidden'}} |
|
|
|
|
indicatorActiveColor='rgba(255,255,255,0.5)'> |
|
|
|
|
{adverts.map(d => <SwiperItem key={d.id}> |
|
|
|
|
<Img |
|
|
|
|
src={d.image_url} |
|
|
|
|
lazyLoad |
|
|
|
|
fadeIn |
|
|
|
|
width={width} |
|
|
|
|
height={(space.height / space.width) * width} |
|
|
|
|
onClick={() => jumpAdware(d.image_path)}/> |
|
|
|
|
</SwiperItem>)} |
|
|
|
|
</Swiper> |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
} |
|
|
|
|
</View> |
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|