Sale1T1L4R.js
6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import TimerMixin from 'react-timer-mixin';
import SlicedImage from '../../../common/components/SlicedImage';
import YH_Image from '../../../common/components/YH_Image';
import HeadTitleCell from '../cell/HeadTitleCell';
import ImageSlider from '../cell/ImageSlider';
/**
* 首页 sale 楼层,
* 这个楼层是标题、banner、左带倒计时大图,右四小图
**/
export default class Sale1T1L4R extends Component{
constructor(props) {
super(props);
this.state = {
remainTime : "",
};
}
componentWillUnmount() {
this.timer && TimerMixin.clearTimeout(this.timer);
}
render(){
let data = this.props.data;
let banner = data.get("banner");
let title = data.get("title");
let imglst = data.get("list");
//初始化时间,待测
let leftBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(0).get("src"), leftBigImageWidth, leftBigImageHeight, 2);
let rightTopBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(1).get("src"), rightBigImageWidth, rightBigImageHeight, 2);
let rightTopSmallImageUrl = SlicedImage.getSlicedUrl(imglst.get(2).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
let rightBottomBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(3).get("src"), rightBigImageWidth, rightBigImageHeight, 2);
let rightBottomSmallImageUrl = SlicedImage.getSlicedUrl(imglst.get(4).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
return(
<View style={styles.container}>
<HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} onPressTitleMore={this.props.onPressTitleMore} />
<ImageSlider
resource={banner}
sliderWidth={width}
sliderHeight={bannerHeight}
onPressSlideItem={this.props.onPressSlideItem}
/>
<View style={styles.imageContainer}>
<TouchableOpacity style={styles.leftBigImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(0).toJS())}>
<YH_Image style={styles.leftBigImage} url={leftBigImageUrl}/>
<Image style={styles.timerImage} source={require("../../images/ic_limit_times.png")}/>
<Text style={styles.timerText}>{remainTime}</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.rightTopBigImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(1).toJS())}>
<YH_Image style={styles.rightTopBigImage} url={rightTopBigImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightTopSmallImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(2).toJS())}>
<YH_Image style={styles.rightTopSmallImage} url={rightTopSmallImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightBottomBigImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(3).toJS())}>
<YH_Image style={styles.rightBottomBigImage} url={rightBottomBigImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightBottomSmallImageContainer} activeOpacity={1}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(4).toJS())}>
<YH_Image style={styles.rightBottomSmallImage} url={rightBottomSmallImageUrl}/>
</TouchableOpacity>
</View>
</View>
);
}
};
let {width} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let bannerHeight = Math.floor(width / 3);
let leftBigImageWidth = width * 310 / 740;
let leftBigImageHeight = leftBigImageWidth * 422 / 310;
let rightBigImageWidth = width * 330 / 740;
let rightBigImageHeight = rightBigImageWidth * 210 / 330;
let rightSmallImageWidth = width * 100 / 740;
let rightSmallImageHeight = rightSmallImageWidth * 210 / 100;
let styles = StyleSheet.create({
container: {
width: width,
height: 40 + bannerHeight + leftBigImageHeight,
backgroundColor: "#e5e5e5",
},
imageContainer: {
width: width,
height: 422 * DEVICE_WIDTH_RATIO,
},
leftBigImageContainer: {
position: 'absolute',
top: 0,
left: 0,
width: leftBigImageWidth,
height: leftBigImageHeight,
},
leftBigImage: {
width: leftBigImageWidth,
height: leftBigImageHeight,
},
timerImage:{
position: 'absolute',
top: 20,
},
timerText:{
position: 'absolute',
top: 50,
textAlign: 'center',
},
rightTopBigImageContainer: {
position: 'absolute',
top: 0,
left: leftBigImageWidth,
width: rightBigImageWidth,
height: rightBigImageHeight,
},
rightTopBigImage: {
width: rightBigImageWidth,
height: rightBigImageHeight,
},
rightTopSmallImageContainer: {
position: 'absolute',
top: 0,
left: leftBigImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightTopSmallImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightBottomBigImageContainer: {
position: 'absolute',
top: rightBigImageHeight,
left: leftBigImageWidth,
width: rightBigImageWidth,
height: rightBigImageHeight,
marginTop: 2,
},
rightBottomBigImage: {
width: rightBigImageWidth,
height: rightBigImageHeight,
},
rightBottomSmallImageContainer: {
position: 'absolute',
top: rightBigImageHeight,
left: leftBigImageWidth + rightBigImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
marginTop: 2,
},
rightBottomSmallImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
});