...
|
...
|
@@ -18,12 +18,6 @@ export default class BrandSwiper extends React.Component { |
|
|
constructor(props) {
|
|
|
super (props);
|
|
|
|
|
|
this.state = {
|
|
|
duration: 1,
|
|
|
width: Dimensions.get('window').width,
|
|
|
height: Math.ceil((310 / 640) * Dimensions.get('window').width),
|
|
|
};
|
|
|
|
|
|
this.dot = <View
|
|
|
style={{
|
|
|
backgroundColor:'rgba(0,0,0,.2)',
|
...
|
...
|
@@ -52,29 +46,26 @@ export default class BrandSwiper extends React.Component { |
|
|
|
|
|
render() {
|
|
|
|
|
|
if (this.props.resource.size == 0) {
|
|
|
let {resource} = this.props;
|
|
|
if (!resource || resource.size == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
let width = this.state.width;
|
|
|
let height = this.state.height;
|
|
|
|
|
|
let data = this.props.resource.toJS();
|
|
|
|
|
|
if (data.length == 1) {
|
|
|
return (
|
|
|
<TouchableOpacity
|
|
|
activeOpacity={1}
|
|
|
style={{width: width, height: swiperHeight}}
|
|
|
onPress={() => {
|
|
|
this.props.onPressBrandItem(data[0].url)
|
|
|
this.props.onPressBrandItem && this.props.onPressBrandItem(data[0].url);
|
|
|
}}
|
|
|
>
|
|
|
<Image
|
|
|
source={{uri: data[0].src}}
|
|
|
style={{ width: width, height: height}}
|
|
|
resizeMode={'cover'}
|
|
|
></Image>
|
|
|
|
|
|
<Image
|
|
|
source={{uri: data[0].src}}
|
|
|
style={{ width: width, height: swiperHeight}}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
} else {
|
...
|
...
|
@@ -84,11 +75,12 @@ export default class BrandSwiper extends React.Component { |
|
|
showsButtons={false}
|
|
|
loop={true}
|
|
|
autoplay={true}
|
|
|
autoplayTimeout={this.state.duration}
|
|
|
autoplayTimeout={2}
|
|
|
paginationStyle={{bottom: 8}}
|
|
|
dot={this.dot}
|
|
|
activeDot={this.activeDot}
|
|
|
height={height}
|
|
|
width={width}
|
|
|
height={swiperHeight}
|
|
|
>
|
|
|
{data.map((item, i) => {
|
|
|
return (
|
...
|
...
|
@@ -96,15 +88,13 @@ export default class BrandSwiper extends React.Component { |
|
|
key={i}
|
|
|
activeOpacity={1}
|
|
|
onPress={() => {
|
|
|
this.props.onPressBrandItem(item.url)
|
|
|
this.props.onPressBrandItem && this.props.onPressBrandItem(item.url);
|
|
|
}}
|
|
|
>
|
|
|
<Image
|
|
|
source={{uri:item.src}}
|
|
|
style={{ width: width, height: height - 20}}
|
|
|
resizeMode={'cover'}
|
|
|
></Image>
|
|
|
|
|
|
source={{uri: item.src}}
|
|
|
style={{width: width, height: swiperHeight - 20}}
|
|
|
/>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
})}
|
...
|
...
|
@@ -114,6 +104,9 @@ export default class BrandSwiper extends React.Component { |
|
|
}
|
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let swiperHeight = Math.ceil((310 / 640) * width);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
|
|
|
banner: {
|
...
|
...
|
|