ProductListView.js
7.98 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
'use strict';
import React, {Component} from "react";
import {View, Text, Image, ListView, StyleSheet, Dimensions, TouchableOpacity} from "react-native";
import SlicedImage from "../../../common/components/SlicedImage";
import YH_Image from '../../../common/components/YH_Image';
export default class ProductListView extends Component {
constructor(props) {
super(props);
this.tipMessage = '';
this.state = {
selectedIndex: 0,
};
}
render() {
let {
rowData,
tipMessage,
} = this.props;
this.tipMessage = tipMessage;
let brandIconUrl = SlicedImage.getSlicedUrl(rowData.defaultImages, 152, 203, 2);
let tipState = '';
let btnBgColor = '#d30018';
let btnTextcolor = 'white';
let url = rowData.shopUrl;
if (rowData.over) {
tipState = '已抢光';
btnBgColor = '#b2b2b2';
} else if (rowData.wait) {
if (!rowData.remindFlag) {
tipState = '提醒我';
btnBgColor = '#444444';
} else {
tipState = '取消提醒';
btnBgColor = 'white';
btnTextcolor = '#000000';
}
} else {
tipState = '去抢购';
}
return (
<TouchableOpacity activeOpacity={1.0} onPress={() => {
this.props.onPressProductItem && this.props.onPressProductItem(rowData);
}}>
<View style={styles.rowContainer}>
<View style={styles.leftImage}>
<YH_Image style={{flex:1}} url={brandIconUrl} />
{tipState == '已抢光' ?
<View style={styles.soldOutContainer}>
<Image source={require('../../images/yqg.png')}/>
</View>
: null }
</View>
<View style={styles.rowRight}>
<Text style={styles.productTitle}
numberOfLines={2}>{rowData.productName}</Text>
<View style={{
flexDirection: 'row',
flex: 1,
alignItems: 'flex-end',
justifyContent: 'space-between'
}}>
<View style={{}}>
<Text
style={styles.seckillPrice}>¥{parseFloat(rowData.secKillPrice + "").toFixed(2)}</Text>
<Text style={styles.originPrice}>
{'¥' + parseFloat(rowData.marketPrice + '').toFixed(2)}</Text>
</View>
<View style={{justifyContent: 'center', alignItems: 'flex-end'}}>
{tipState == '已抢光' && url && url.length ?
<TouchableOpacity onPress={()=> {
this.props.onPressGuangShopWithURL && this.props.onPressGuangShopWithURL(url);
}} style={[styles.priceClickTipViewRight, {
backgroundColor: 'white',
borderColor: 'black',
borderWidth: 1
}]}>
<Text style={{color: 'black'}}>进店逛逛</Text>
</TouchableOpacity>
: null}
{tipState != '已抢光' ? <TouchableOpacity onPress={() => {
if (this.tipMessage == '') {
if (rowData.wait) {
this.props.onPressRemindBtn && this.props.onPressRemindBtn(rowData);
} else {
this.props.onPressProductItem && this.props.onPressProductItem(rowData);
}
}
}}>
{
(tipState == '取消提醒') ?
<View style={[styles.priceClickTipViewRight, {
backgroundColor: btnBgColor,
borderWidth: 1.0
}]}>
<Text style={{color: btnTextcolor}}>{tipState}</Text>
</View>
: <View
style={[styles.priceClickTipViewRight, {backgroundColor: btnBgColor}]}>
<Text style={{color: btnTextcolor}}>{tipState}</Text>
</View>
}
</TouchableOpacity> : null
}
{rowData.wait &&
<Text style={styles.seckillBeginTimeTip}>{rowData.readableTime + ' 开始'}</Text>}
</View>
</View>
</View>
<View style={styles.separator}/>
</View>
</TouchableOpacity>
);
}
}
let {width, height} = Dimensions.get('window');
let backgroundWidth = width;
let backgroundHeight = 121;
let rowHeight = backgroundHeight;
let WIDTH_RATION = width / 375.0;
let imageWidth = 80;
let imageHeight = 106;
let adjustPx = (number) => Math.round(number * WIDTH_RATION)
let styles = StyleSheet.create({
rowContainer: {
flexDirection: 'row',
paddingLeft: adjustPx(15),
paddingRight: adjustPx(15),
paddingTop: adjustPx(10),
paddingBottom: adjustPx(10),
backgroundColor: 'white',
},
leftImage: {
width: adjustPx(imageWidth),
height: adjustPx(imageHeight),
},
soldOutContainer: {
backgroundColor: '#0000007F',
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0,
alignItems: 'center',
justifyContent: 'center',
},
rowRight: {
flexDirection: 'column',
marginLeft: 10,
justifyContent: 'space-between',
flex: 1,
},
priceClickTipView: {
flexDirection: 'row',
justifyContent: 'space-between',
width: width - imageWidth - 35,
height: 50,
backgroundColor: 'yellow',
},
priceClickTipViewLeft: {
top: 25,
},
priceClickTipViewRight: {
width: 80,
height: 30,
marginTop: 10,
alignItems: 'center',
justifyContent: 'center',
borderRadius: 3,
backgroundColor: '#d0021b',
},
secKillMarketPriceContainer: {
flexDirection: 'row',
alignItems: 'center'
},
bottomToolBar: {
top: 200,
height: 44,
backgroundColor: '#000',
},
closeScan: {
left: 10,
width: 25,
height: 25,
top: 10,
},
productTitle: {
fontSize: 14,
color: '#444444',
lineHeight: 20,
marginRight: 20,
},
seckillPrice: {
fontSize: 18,
lineHeight: 21,
fontWeight: 'bold',
color: '#d0021b',
},
originPrice: {
textDecorationLine: 'line-through',
color: '#B0B0B0',
fontSize: 12,
lineHeight: 17
},
seckillBeginTimeTip: {
fontSize: 9,
marginTop: 6,
color: '#D0021B',
},
separator: {
position: 'absolute',
left: 15,
right: 0,
bottom: 0,
height: 0.5,
backgroundColor: '#e5e5e5',
},
});