NewProductFloor.js
5.78 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
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import SlicedImage from '../../../common/components/SlicedImage';
import YH_Image from '../../../common/components/YH_Image';
import HeadTitleCell from '../cell/HeadTitleCell';
/**
* 新品到着楼层,
* 这个楼层是左边一个大图(第一条数据),右边是四张小图,左上图(第二条数据),左下图(第三条数据),右上图(第四条数据),右下图(第五条数据)
**/
export default class NewProductFloor extends Component{
constructor(props) {
super(props);
}
render(){
let data = this.props.data;
let title = data.get("title");
let imglst = data.get("list");
let leftBigImageUrl = SlicedImage.getSlicedUrl(imglst.get(0).get("src"), leftBigImageWidth, leftBigImageHeight, 2);
let rightSmallTopLeftImageUrl = SlicedImage.getSlicedUrl(imglst.get(1).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
let rightSmallBottomLeftImageUrl = SlicedImage.getSlicedUrl(imglst.get(2).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
let rightSmallTopRightImageUrl = SlicedImage.getSlicedUrl(imglst.get(3).get("src"), rightSmallImageWidth, rightSmallImageHeight, 2);
let rightSmallBottomRightImageUrl = 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} yh_exposureData={title.get('yh_exposureData')}/>
<View style={styles.imageContainer}>
<TouchableOpacity style={styles.leftBigImageContainer} activeOpacity={1} yh_exposureData={imglst.get(0).get('yh_exposureData')}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(0).get('url'), leftBigImageUrl, 0)}>
<YH_Image style={styles.leftBigImage} url={leftBigImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightSmallTopLeftImageContainer} activeOpacity={1} yh_exposureData={imglst.get(1).get('yh_exposureData')}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(1).get('url'), rightSmallTopLeftImageUrl, 1)}>
<YH_Image style={styles.rightSmallTopLeftImage} url={rightSmallTopLeftImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightSmallBottomLeftImageContainer} activeOpacity={1} yh_exposureData={imglst.get(2).get('yh_exposureData')}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(2).get('url'), rightSmallBottomLeftImageUrl, 2)}>
<YH_Image style={styles.rightSmallBottomLeftImage} url={rightSmallBottomLeftImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightSmallTopRightImageContainer} activeOpacity={1} yh_exposureData={imglst.get(3).get('yh_exposureData')}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(3).get('url'), rightSmallTopRightImageUrl, 3)}>
<YH_Image style={styles.rightSmallTopRightImage} url={rightSmallTopRightImageUrl}/>
</TouchableOpacity>
<TouchableOpacity style={styles.rightSmallBottomRightImageContainer} activeOpacity={1} yh_exposureData={imglst.get(4).get('yh_exposureData')}
onPress={() => this.props.onPressImageItem && this.props.onPressImageItem(imglst.get(4).get('url'), rightSmallBottomRightImageUrl ,4)}>
<YH_Image style={styles.rightSmallBottomRightImage} url={rightSmallBottomRightImageUrl}/>
</TouchableOpacity>
</View>
</View>
);
}
};
let {width} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let leftBigImageWidth = width * 315 / 750;
let leftBigImageHeight = leftBigImageWidth * 420 / 315;
let rightSmallImageWidth = (width - leftBigImageWidth) / 2;
let rightSmallImageHeight = leftBigImageHeight / 2;
let containerHeight = 40 + leftBigImageHeight;
let styles = StyleSheet.create({
container: {
width: width,
height: containerHeight,
backgroundColor: "#e5e5e5",
},
imageContainer: {
width: width,
height: leftBigImageHeight,
},
leftBigImageContainer: {
position: 'absolute',
top: 0,
left: 0,
width: leftBigImageWidth,
height: leftBigImageHeight,
},
leftBigImage: {
width: leftBigImageWidth,
height: leftBigImageHeight,
},
rightSmallTopLeftImageContainer: {
position: 'absolute',
top: 0,
left: leftBigImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallTopLeftImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallBottomLeftImageContainer: {
position: 'absolute',
top: rightSmallImageHeight,
left: leftBigImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallBottomLeftImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallTopRightImageContainer: {
position: 'absolute',
top: 0,
left: leftBigImageWidth + rightSmallImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallTopRightImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallBottomRightImageContainer: {
position: 'absolute',
top: rightSmallImageHeight,
left: leftBigImageWidth + rightSmallImageWidth,
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
rightSmallBottomRightImage: {
width: rightSmallImageWidth,
height: rightSmallImageHeight,
},
});