TripleImage.js
16.3 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
import React, {Component } from 'react'
import {View, StyleSheet, Text, Dimensions,TouchableOpacity} from 'react-native';
import Immutable, {Map} from 'immutable';
import YH_Image from '../../../common/components/YH_Image';
export default class RedPersonPicThree extends Component{
constructor(props) {
super(props);
}
shouldComponentUpdate(nextProps){
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
render() {
let {resource} = this.props;
if (!resource) {
return null;
}
let list = resource.get('module_data').get('data').toJS();
let properties = resource.get('module_data').get('properties').toJS();
let isModuleMargin = properties.isModuleMargin;
let displayType = properties.displayType;
let data1 = list?list[0]:null;
let backgroundImage1 = data1?data1.pic:'';
let linkType1 = data1.linkType;
let showProductInfo1 = data1.showProductInfo;
let product1 = data1.product;
let salePrice1 = product1?parseFloat(product1.sales_price):0;
let originPrice1 = product1?parseFloat(product1.market_price):0;
let name1 = product1?product1.product_name:'';
let price1 = '¥' + salePrice1.toFixed(2);
let sale1 = '¥' + originPrice1.toFixed(2);
let saleAble1 = false;//salePrice1>0?true:false;
let linkReource1 = data1.resource;
let data2 = list?list[1]:null;
let backgroundImage2 = data2.pic;
let linkType2 = data2.linkType;
let showProductInfo2 = data2.showProductInfo;
let product2 = data2.product;
let salePrice2 = product2?parseFloat(product2.sales_price):0;
let originPrice2 = product2?parseFloat(product2.market_price):0;
let name2 = product2?product2.product_name:'';
let price2 = '¥' + salePrice2.toFixed(2);
let sale2 = '¥' + originPrice2.toFixed(2);
let saleAble2 = false;//salePrice2>0?true:false;
let linkReource2 = data2.resource;
let data3 = list?list[2]:null;
let backgroundImage3 = data3.pic;
let linkType3 = data3.linkType;
let showProductInfo3 = data3.showProductInfo;
let product3 = data3.product;
let salePrice3 = product3?parseFloat(product3.sales_price):0;
let originPrice3= product3?parseFloat(product3.market_price):0;
let name3 = product3?product3.product_name:'';
let price3 = '¥' + salePrice3.toFixed(2);
let sale3 = '¥' + originPrice3.toFixed(2);
let saleAble3 = false;//salePrice3>0?true:false;
let linkReource3 = data3.resource;
switch (displayType) {
case '1':
return (
<View style={{flexDirection: 'row',width:width,height: isModuleMargin=='1'?containerHeigth4+nullHeigth:containerHeigth4,backgroundColor: 'white'}}>
<TouchableOpacity style={styles.imagetype4} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType1,linkReource1)}} >
<YH_Image url={backgroundImage1} style={styles.imagetype4}/>
{linkType1=='1' && showProductInfo1 ?<View style={styles.maskContainer4}>
<Text style={styles.titleText4} numberOfLines={1}>{name1}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble1?'red':'white',}}>{price1}</Text>
{saleAble1?<Text style={styles.deleteSale}>{sale1}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
<TouchableOpacity style={styles.imagetype4} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType2,linkReource2)}} >
<YH_Image url={backgroundImage2} style={styles.imagetype4}/>
{linkType2=='1' && showProductInfo2?<View style={styles.maskContainer4}>
<Text style={styles.titleText4} numberOfLines={1}>{name2}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble2?'red':'white',}}>{price2}</Text>
{saleAble2?<Text style={styles.deleteSale}>{sale2}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
<TouchableOpacity style={styles.imagetype4} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType3,linkReource3)}} >
<YH_Image url={backgroundImage3} style={styles.imagetype4}/>
{linkType3=='1' && showProductInfo3?<View style={styles.maskContainer4}>
<Text style={styles.titleText4} numberOfLines={1}>{name3}</Text>
<View style={styles.saleView}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble3?'red':'white',}}>{price3}</Text>
{saleAble3?<Text style={styles.deleteSale}>{sale3}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
</View>
)
break;
case '2':
return (
<View style={{flexDirection: 'row',width:width,height: isModuleMargin=='1'?containerHeigth3+nullHeigth:containerHeigth3,backgroundColor: 'white'}}>
<TouchableOpacity style={styles.imagetype3} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType1,linkReource1)}} >
<YH_Image url={backgroundImage1} style={styles.imagetype3}/>
{linkType1=='1'?<View style={styles.maskContainer3}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble1?'red':'white',}}>{price1}</Text>
{saleAble1?<Text style={styles.deleteSale}>{sale1}</Text>:null}
</View>:null}
</TouchableOpacity>
<TouchableOpacity style={styles.imagetype3} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType2,linkReource2)}} >
<YH_Image url={backgroundImage2} style={styles.imagetype3}/>
{linkType2=='1'?<View style={styles.maskContainer3}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble2?'red':'white',}}>{price2}</Text>
{saleAble2?<Text style={styles.deleteSale}>{sale2}</Text>:null}
</View>:null}
</TouchableOpacity>
<TouchableOpacity style={styles.imagetype3} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType3,linkReource3)}} >
<YH_Image url={backgroundImage3} style={styles.imagetype3}/>
{linkType3=='1'?<View style={styles.maskContainer3}>
<Text style={{marginTop: 2,marginLeft: 10,fontSize: 11,backgroundColor: 'transparent',color: saleAble3?'red':'white',}}>{price3}</Text>
{saleAble3?<Text style={styles.deleteSale}>{sale3}</Text>:null}
</View>:null}
</TouchableOpacity>
</View>
)
break;
case '3':
return (
<View style={{flexDirection: 'row',width:width,height: isModuleMargin=='1'?containerHeigth+nullHeigth:containerHeigth,backgroundColor: 'white'}}>
<View style={styles.subContainer}>
<TouchableOpacity style={styles.image} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType1,linkReource1)}} >
<YH_Image url={backgroundImage1} style={styles.image}/>
{linkType1=='1'?<View style={styles.maskContainer1}>
<Text style={styles.titleText} numberOfLines={2}>{name1}</Text>
<View style={{backgroundColor: 'transparent',flexDirection: 'row',marginRight: 10}}>
<Text style={{fontSize: 12,backgroundColor: 'transparent',color: saleAble1?'red':'white'}}>{price1}</Text>
{saleAble1?<Text style={styles.deleteSale3}>{sale1}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
<TouchableOpacity style={styles.image} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType2,linkReource2)}} >
<YH_Image url={backgroundImage2} style={styles.image}/>
{linkType2=='1'?<View style={styles.maskContainer1}>
<Text style={styles.titleText} numberOfLines={2}>{name2}</Text>
<View style={{backgroundColor: 'transparent',flexDirection: 'row',marginRight: 10}}>
<Text style={{fontSize: 12,backgroundColor: 'transparent',color: saleAble2?'red':'white'}}>{price2}</Text>
{saleAble2?<Text style={styles.deleteSale3}>{sale2}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
</View>
<TouchableOpacity style={styles.imageBig} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType3,linkReource3)}} >
<YH_Image url={backgroundImage3} style={styles.imageBig}/>
{linkType3=='1'?<View style={styles.maskContainer2}>
<Text style={styles.titleText} numberOfLines={2}>{name3}</Text>
<View style={{backgroundColor: 'transparent',flexDirection: 'row'}}>
<Text style={{fontSize: 12,backgroundColor: 'transparent',color: saleAble3?'red':'white'}}>{price3}</Text>
{saleAble3?<Text style={styles.deleteSale3}>{sale3}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
</View>
)
break;
case '4':
return (
<View style={{flexDirection: 'row',width:width,height: isModuleMargin=='1'?containerHeigth+nullHeigth:containerHeigth,backgroundColor: 'white'}}>
<TouchableOpacity onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType1,linkReource1)}} >
<View style={styles.subContainer}>
<YH_Image url={backgroundImage1} style={styles.imageBig}/>
{linkType1=='1'?<View style={styles.maskContainer2}>
<Text style={styles.titleText} numberOfLines={2}>{name1}</Text>
<View style={{backgroundColor: 'transparent',flexDirection: 'row'}}>
<Text style={{fontSize: 12,backgroundColor: 'transparent',color: saleAble1?'red':'white'}}>{price1}</Text>
{saleAble1?<Text style={styles.deleteSale3}>{sale1}</Text>:null}
</View>
</View>:null}
</View>
</TouchableOpacity>
<View style={styles.subContainer}>
<TouchableOpacity style={styles.image} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType2,linkReource2)}} >
<YH_Image url={backgroundImage2} style={styles.image}/>
{linkType2=='1'?<View style={styles.maskContainer1}>
<Text style={styles.titleText} numberOfLines={2}>{name2}</Text>
<View style={{backgroundColor: 'transparent',flexDirection: 'row',marginRight: 10}}>
<Text style={{fontSize: 12,backgroundColor: 'transparent',color: saleAble2?'red':'white'}}>{price2}</Text>
{saleAble2?<Text style={styles.deleteSale3}>{sale2}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
<TouchableOpacity style={styles.image} onPress={() => {this.props.onPressProduct && this.props.onPressProduct(linkType3,linkReource3)}} >
<YH_Image url={backgroundImage3} style={styles.image}/>
{linkType3=='1'?<View style={styles.maskContainer1}>
<Text style={styles.titleText} numberOfLines={2}>{name3}</Text>
<View style={{backgroundColor: 'transparent',flexDirection: 'row',marginRight: 10}}>
<Text style={{fontSize: 12,backgroundColor: 'transparent',color: saleAble3?'red':'white'}}>{price3}</Text>
{saleAble3?<Text style={styles.deleteSale3}>{sale3}</Text>:null}
</View>
</View>:null}
</TouchableOpacity>
</View>
</View>
)
break;
default:
return null;
}
}
}
let {width, height} = Dimensions.get('window');
let containerHeigth = Math.ceil((468/750)*width);
let containerHeigth3 = Math.ceil(width/3);
let containerHeigth4 = Math.ceil((333/750)*width);
let maskHeight = 30;
let nullHeigth = 10;
let styles = StyleSheet.create({
subContainer:{
width:width / 2,
flexDirection: 'column',
},
maskContainer1: {
position: 'absolute',
width: width/2,
height: maskHeight,
backgroundColor: 'rgba(0,0,0,0.3)',
top: containerHeigth/2-maskHeight,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
maskContainer2: {
position: 'absolute',
width: width/2,
height: maskHeight,
backgroundColor: 'rgba(0,0,0,0.3)',
top: containerHeigth-maskHeight,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-around',
},
maskContainer3:{
position: 'absolute',
width: width/3,
height: 24,
backgroundColor: 'rgba(0,0,0,0.3)',
top: containerHeigth3-24,
flexDirection: 'row',
alignItems: 'center',
flexDirection: 'row',
},
maskContainer4: {
position: 'absolute',
width: width/3,
height: 40,
backgroundColor: 'rgba(0,0,0,0.3)',
top: containerHeigth4-40,
},
imagetype3: {
width:width/3 ,
height:containerHeigth3,
},
imagetype4:{
width:width/3,
height:containerHeigth4,
},
image:{
width:width/2,
height: containerHeigth / 2,
},
imageBig:{
width:width/2,
height: containerHeigth,
},
titleText: {
color:'white',
width : 80,
fontSize: 11,
textAlign :'left',
backgroundColor: 'transparent',
fontWeight: 'bold',
marginLeft: 10,
},
price: {
color:'white',
width : 80,
fontSize: 11,
textAlign :'right',
},
price3: {
width:width/3 ,
height:maskHeight / 2,
color: 'white',
marginLeft: 10,
fontSize: 11,
textAlign :'left',
},
titleText4: {
width:width/3 -10,
height:maskHeight / 2,
color: 'white',
marginLeft: 10,
fontSize: 11,
textAlign :'left',
marginTop: 4,
fontWeight: 'bold',
},
price4: {
width:width/3 ,
height:maskHeight / 2,
color: 'white',
marginLeft: 10,
fontSize: 11,
textAlign : 'left',
marginTop: 2,
},
deleteSale: {
marginLeft: 2,
marginTop: 4,
fontSize: 11,
backgroundColor: 'transparent',
color: 'white',
textDecorationLine: 'line-through',
},
deleteSale3: {
marginLeft: 2,
marginTop: 4,
fontSize: 11,
backgroundColor: 'transparent',
color: 'white',
textDecorationLine: 'line-through',
},
saleView:{
flexDirection: 'row',
},
});