|
@@ -9,38 +9,59 @@ export default class SwiperBanner extends Component {
|
9
|
9
|
list: [],
|
10
|
10
|
onClick: function () { }
|
11
|
11
|
}
|
|
12
|
+ state = {
|
|
13
|
+ visiable: true
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ componentDidHide() {
|
|
17
|
+ console.log('加载页面啦红红火火恍恍惚惚')
|
|
18
|
+
|
|
19
|
+ this.setState({
|
|
20
|
+ visiable: false
|
|
21
|
+ })
|
|
22
|
+ }
|
|
23
|
+ componentDidShow() {
|
|
24
|
+ this.setState({
|
|
25
|
+ visiable: true
|
|
26
|
+ })
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ componentWillMount() {
|
|
30
|
+ console.log('componentWillMount#######')
|
|
31
|
+ }
|
12
|
32
|
|
13
|
33
|
onBannerClick(item) {
|
14
|
34
|
this.props.onClick(item)
|
15
|
35
|
}
|
16
|
36
|
render() {
|
17
|
|
- const { list, indicatorDots} = this.props
|
|
37
|
+ const { list, indicatorDots } = this.props
|
18
|
38
|
return (
|
19
|
39
|
<View className='home-banner'>
|
20
|
|
- <Swiper
|
21
|
|
- className='home-banner__swiper'
|
22
|
|
- circular
|
23
|
|
- autoplay
|
24
|
|
- indicatorDots={indicatorDots}
|
25
|
|
- indicatorActiveColor='rgb(178, 42, 49)'
|
26
|
|
- // TODO 目前 H5、RN 暂不支持 previousMargin、nextMargin
|
27
|
|
- // previousMargin
|
28
|
|
- // nextMargin
|
29
|
|
- >
|
30
|
|
- {list.map((item, index) => (
|
31
|
|
- <SwiperItem
|
32
|
|
- key={index+'swiper3'}
|
33
|
|
- onClick={this.onBannerClick.bind(this, item)}
|
34
|
|
- className='home-banner__swiper-item'
|
35
|
|
- >
|
36
|
|
- <Image
|
37
|
|
- mode="aspectFill"
|
38
|
|
- className='home-banner__swiper-item-img'
|
39
|
|
- src={transferImage(item.image)}
|
40
|
|
- />
|
41
|
|
- </SwiperItem>
|
42
|
|
- ))}
|
43
|
|
- </Swiper>
|
|
40
|
+ {
|
|
41
|
+ this.state.visiable && <Swiper
|
|
42
|
+ className='home-banner__swiper'
|
|
43
|
+ circular
|
|
44
|
+ autoplay
|
|
45
|
+ indicatorDots={indicatorDots}
|
|
46
|
+ indicatorActiveColor='rgb(178, 42, 49)'
|
|
47
|
+
|
|
48
|
+ >
|
|
49
|
+ {list.map((item, index) => (
|
|
50
|
+ <SwiperItem
|
|
51
|
+ key={index + 'swiper3'}
|
|
52
|
+ onClick={this.onBannerClick.bind(this, item)}
|
|
53
|
+ className='home-banner__swiper-item'
|
|
54
|
+ >
|
|
55
|
+ <Image
|
|
56
|
+ mode="aspectFill"
|
|
57
|
+ className='home-banner__swiper-item-img'
|
|
58
|
+ src={transferImage(item.image)}
|
|
59
|
+ />
|
|
60
|
+ </SwiperItem>
|
|
61
|
+ ))}
|
|
62
|
+ </Swiper>
|
|
63
|
+ }
|
|
64
|
+
|
44
|
65
|
</View>
|
45
|
66
|
)
|
46
|
67
|
}
|