ProductCell.js
7.02 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
'use strict';
import React, {Component} from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
TouchableOpacity,
Platform,
} from 'react-native';
import YH_Image from '../../../common/components/YH_Image';
export default class ProductCell extends Component {
constructor(props) {
super(props);
}
render(){
let {width,height} = Dimensions.get('window');
let scale = width/320;
let goodsData = this.props.goodsData;
let goodsImageURL = YH_Image.getSlicedUrl(goodsData.get('goods_image',''),90*scale,120*scale,2);
let goodsName = goodsData.get('product_name','');
let goodsSize = goodsData.get('size_name','');
let goodsColor = goodsData.get('color_name','');
let goodsPrice = goodsData.get('goods_price','');
let goodsCount = goodsData.get('buy_number','');
let arrivalTime = goodsData.get('expect_arrival_time');
let goodsSKN = goodsData.get('product_skn','');
let colorString = '';
let sizeString = '';
let refundExchangeImagePath = '';
let showStatusImage = false;
if (this.props.isVirtualOrder) {
if (goodsSKN == this.props.yohoodTicketsSkn) {
colorString = '日期:'+goodsColor;
sizeString = '区域:'+goodsSize;
}else if (goodsSKN == this.props.yohoodTicketSkn) {
colorString = '日期:'+goodsColor;
}else {
colorString = '颜色:'+goodsColor;
}
}else {
colorString = '颜色:'+goodsColor;
sizeString = '尺码:'+goodsSize;
let goodsStatus = goodsData.get('goods_status','');
if (goodsStatus == '已退货') {
showStatusImage = true;
refundExchangeImagePath=require('../../image/has_refunded.png')
}else if (goodsStatus == '已换货') {
showStatusImage = true;
refundExchangeImagePath=require('../../image/had_exchanged.png')
}else if (goodsStatus == '已退换') {
showStatusImage = true;
refundExchangeImagePath=require('../../image/has_refundedExchange.png')
}
}
let goodsTyle = goodsData.get('goods_type',0)//商品类型,默认0为普通商品
let typeTipColor = 'transparent';
let typeTipString = '';
switch (goodsTyle) {
case 'gift':{
typeTipString='赠品';
typeTipColor='rgba(133, 196, 91, 1.0)'
}
break;
case 'price_gift':{
typeTipString='加价购';
typeTipColor='rgba(245, 91, 144, 1.0)'
}
break;
case 'outlet':{
typeTipString='OUTLET';
typeTipColor='#ff9900'
}
break;
default:
}
let showDate = arrivalTime.length > 0 && !this.props.isPresaleOrder;
return (
<TouchableOpacity style={styles.container} activeOpacity={1} onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(goodsSKN);
}}>
<View style={styles.leftMiddleContainer}>
<View style={styles.leftContainer}>
<YH_Image style={styles.goodsImageStyle}
url={goodsImageURL}
/>
<View style={[styles.goodsTypeStyle,{backgroundColor:typeTipColor}]}>
<Text style={{fontSize: 8,color: 'white',textAlign:'center'}}>
{typeTipString}
</Text>
</View>
</View>
<View style={styles.middleContainer}>
<Text style={styles.nameStyle} numberOfLines={2}>
{goodsName}
</Text>
<Text style={styles.colorStyle} >
{(colorString)+' '+(sizeString)}
</Text>
</View>
</View>
<View style={styles.rightContainer}>
<Text style={styles.priceStyle}> {'¥'+(goodsPrice)} </Text>
<Text style={styles.countStyle}> {'x'+(goodsCount)} </Text>
{showDate > 0 ?<Text style={styles.dateStyle}> {'上市期:' + (arrivalTime)} </Text> : null}
{showStatusImage ?
<TouchableOpacity
onPress={() => {
this.props._onPressRefundExchange && this.props._onPressRefundExchange()
}}
>
<Image style={styles.refundImageStyle}
source={refundExchangeImagePath}
/>
</TouchableOpacity>
: null}
</View>
</TouchableOpacity>
);
}
}
let {width,height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
height: 82,
width:width,
backgroundColor: 'white',
borderColor: '#f0f0f0',
borderBottomWidth: 0.5,
},
leftMiddleContainer:{
flexDirection:'row',
},
leftContainer: {
backgroundColor: 'transparent',
flexDirection:'column',
marginLeft: 15,
marginTop: 10,
width: 45,
height: 60,
},
middleContainer: {
flexDirection: 'column',
justifyContent : 'flex-start',
marginLeft: 10,
width:200*(width/375)
},
rightContainer: {
flexDirection: 'column',
marginRight: 15,
alignItems: 'flex-end',
},
goodsImageStyle: {
width: 45,
height: 60,
},
goodsTypeStyle: {
position: 'absolute',
justifyContent: 'center',
top: 48,
left: 0,
height: 12,
width: 45,
},
nameStyle: {
fontSize: 14,
color: '#444444',
backgroundColor: 'transparent',
marginTop: 11,
},
colorSizeContainer: {
flexDirection: 'row',
},
colorStyle:{
fontSize: 11,
color: '#b0b0b0',
marginTop: 5,
},
sizeStyle: {
fontSize: 11,
color: '#b0b0b0',
},
priceStyle: {
fontSize: 14,
color: '#d0021b',
marginTop: 13,
},
countStyle: {
fontSize: 12,
color: '#b0b0b0',
marginTop: 4,
},
dateStyle:{
fontSize: 14,
color: '#d0021b',
marginTop: 5,
},
taxImageStyle:{
},
taxInfoStyle:{
},
refundImageStyle:{
marginTop:10,
},
refundInfoStyle:{
fontSize: 10,
color: '#b0b0b0',
},
lineStyle: {
color: "#e5e5e5",
height: 0.5,
}
});