CouponCell.js
7.58 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
View,
TouchableOpacity,
StyleSheet,
Dimensions,
Platform,
Text,
Image,
} = ReactNative;
import Immutable, {Map} from 'immutable';
export default class CouponCell extends React.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.resource?this.props.resource.toJS():null;
let usedType = this.props.usedType;
let index = this.props.index;
let couponDetailInfomation = resource.couponDetailInfomation;
let couponValidity = resource.couponValidity;
let rule4ShortName = resource.rule4ShortName;
let couponValue = resource.couponValue;
let overState = resource.overState;
let isNoLimit = resource.isNoLimit;
let brandNameLimit = resource.brandNameLimit;
let sortNameLimit = resource.sortNameLimit;
let showDetail = resource.showDetail?resource.showDetail:false;
let tipImage = showDetail?require('../../image/up_tip_ic.png'):require('../../image/down_tip_ic.png');
let bottomText = brandNameLimit.length > 0 ? '限品牌:'+brandNameLimit[0] :'';
bottomText = sortNameLimit.length > 0 ? bottomText + '限品类:'+sortNameLimit[0] : bottomText;
bottomText = isNoLimit=='true' ? '全场通用' : bottomText;
let backgroundHeigth = showDetail ? topBackgroundHeigth + detailBackgroundHeigth + 20 : topBackgroundHeigth + 20;
return (
<View style={{width: width, height: backgroundHeigth,backgroundColor: 'white'}}>
<View style={{width: width,height: 20,backgroundColor: 'white',}}/>
<Image source={require('../../image/coupon1_tip_bg.png')} style={styles.couponBackgroundImage} />
<View style={styles.topContent}>
<View style={styles.topTitleView}>
<Text style={styles.topTitle} numberOfLines={1}>{couponDetailInfomation}</Text>
</View>
<View style={styles.topDetail}>
<View style={styles.leftDetail}>
<View style={styles.priceView}>
<Text style={styles.price} numberOfLines={1}>{couponValue}</Text>
</View>
<Text style={styles.priceDetail} numberOfLines={1}>{rule4ShortName}</Text>
</View>
<View style={styles.rigthDetail}>
<View style={styles.timeDetailTopView}>
<Text style={styles.timeDetailTop} numberOfLines={1}>{couponValidity}</Text>
{usedType == 0 && overState ? <Text style={styles.timeDetail2} numberOfLines={1}>({overState})</Text>:null}
</View>
<View style={styles.timeDetailBottomView}>
<TouchableOpacity activeOpacity={1} style={styles.timeDetailBottomView}
onPress={() => {
this.props.showCouponDetail && this.props.showCouponDetail(usedType,index,!showDetail)
}}
>
<Text style={styles.timeDetailSwitch} numberOfLines={1}>详细信息</Text>
<Image source={tipImage} style={styles.timeDetailSwitchIcon} />
</TouchableOpacity>
{usedType == 0 ? <TouchableOpacity activeOpacity={1} style={styles.button}
onPress={() => {
this.props.onPressUseNow && this.props.onPressUseNow(resource)
}}
>
<Image source={require('../../image/ljsy_tip_an.png')} style={{width: 60,height: 23}} />
</TouchableOpacity> : null
}
</View>
{usedType == 1 ? <Image source={require('../../image/coupon_mark_used.png')} style={styles.usedIcon} /> : null}
</View>
</View>
</View>
{showDetail ? <View style={styles.bottom}>
<Image source={require('../../image/coupon2_tip_bg.png')} style={styles.bottomBackgroundImage} />
<View style={styles.bottomContent}>
<Text style={styles.bottomText1} numberOfLines={1}>{bottomText}</Text>
<View style={styles.bottomText2View}>
<Text style={styles.bottomText2} numberOfLines={2}>特例商品(秒杀、限定、境外、预售等)暂不支持使用优惠卷</Text>
</View>
</View>
</View> : null}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let sc = 360/1037;//背景宽高比
let scTop = 90/360;//上面标题栏占背景比例
let scLeft = 345/1037;//左侧占背景比例
let topBackgroundHeigth = sc*(width - 50);
let topBackgroundWidth = width - 50;
let sc2 = 182/1035;//背景宽高比
let detailBackgroundHeigth = sc2*(width - 50);
let detailBackgroundWidth = width - 50;
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
couponBackgroundImage: {
width: topBackgroundWidth,
height: topBackgroundHeigth,
marginLeft: 25,
},
topContent: {
width: topBackgroundWidth,
height: topBackgroundHeigth,
left: 25,
marginTop: -topBackgroundHeigth,
position: 'absolute',
backgroundColor: 'transparent',
},
topTitleView: {
height: topBackgroundHeigth * scTop,
width: topBackgroundWidth,
marginLeft: 10,
justifyContent: 'center',
},
topTitle: {
color: 'white',
},
topDetail: {
height: topBackgroundHeigth - topBackgroundHeigth * scTop,
width: topBackgroundWidth,
backgroundColor: 'transparent',
flexDirection: 'row',
},
leftDetail: {
height: topBackgroundHeigth - topBackgroundHeigth * scTop,
width: topBackgroundWidth*scLeft,
backgroundColor: 'transparent',
},
priceView: {
height: ( topBackgroundHeigth - topBackgroundHeigth * scTop ) * 0.55,
width: topBackgroundWidth*scLeft,
backgroundColor: 'transparent',
alignItems: 'center',
justifyContent: 'center',
marginTop: 10,
},
price: {
color: 'white',
fontSize: 40,
},
priceDetail: {
color: 'white',
fontSize: 11,
textAlign: 'center',
},
rigthDetail: {
height: topBackgroundHeigth - topBackgroundHeigth * scTop,
width: topBackgroundWidth*(1-scLeft),
backgroundColor: 'transparent',
},
timeDetailTopView: {
height: (topBackgroundHeigth - topBackgroundHeigth * scTop)/2,
width: topBackgroundWidth*(1-scLeft),
backgroundColor: 'transparent',
},
timeDetailTop: {
color: 'white',
fontSize: 13,
marginLeft: 15,
marginTop: 12,
},
timeDetail2: {
fontSize: 13,
marginLeft: 15,
},
timeDetailBottomView: {
height: (topBackgroundHeigth - topBackgroundHeigth * scTop)/2 - 10,
width: topBackgroundWidth*(1-scLeft),
backgroundColor: 'transparent',
marginTop: 5,
alignItems: 'center',
flexDirection: 'row',
},
timeDetailSwitch: {
color: 'white',
fontSize: 12,
marginLeft: 15,
},
timeDetailSwitchIcon: {
marginLeft: 5,
},
button: {
width: 60,
height: 23,
position: 'absolute',
right: 15,
bottom: 5,
backgroundColor: 'transparent',
},
usedIcon: {
width: detailBackgroundHeigth + 8,
height: detailBackgroundHeigth + 8,
position: 'absolute',
right: 10,
bottom: 1,
},
bottom: {
width: detailBackgroundWidth,
height: detailBackgroundHeigth,
marginLeft: 25,
},
bottomBackgroundImage: {
width: detailBackgroundWidth,
height: detailBackgroundHeigth,
},
bottomContent: {
width: detailBackgroundWidth,
height: detailBackgroundHeigth,
marginTop: -detailBackgroundHeigth,
position: 'absolute',
},
bottomText1: {
color: 'white',
fontSize: 12,
marginLeft: 15,
backgroundColor: 'transparent',
marginTop: 10,
},
bottomText2View: {
height: 30,
marginLeft: 15,
backgroundColor: 'transparent',
marginTop: 2,
justifyContent: 'center',
},
bottomText2: {
color: 'white',
fontSize: 12,
marginTop: 2,
},
});