MyOrderListCell.js
3.66 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
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
TouchableOpacity,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import YH_Image from '../../../common/components/YH_Image';
import SlicedImage from '../../../common/components/SlicedImage';
export default class MyOrderListCell extends React.Component {
constructor(props) {
super(props);
}
render() {
let orderData = this.props.orderData;
if(!orderData)
return null;
let orderGoods = orderData.get("order_goods") ? orderData.get("order_goods").get(0) : null;
let goodsImage = orderGoods ? orderGoods.get("goods_image") : "";
goodsImage = goodsImage ? SlicedImage.getSlicedUrl(goodsImage, 45, 60, 2) : "";
let productName = orderGoods ? orderGoods.get("product_name") : "";
let productSkn = orderGoods ? orderGoods.get("product_skn") : "";
let orderCode = orderData.get("order_code");
let orderTime = orderData.get("create_time");
let orderMoney = orderData.get("amount");
let orderStateText = orderData.get("install_status");
let status = orderData.get("status");
let isOrderPaying = (status == 1 || status == 3);
let colorStyle = isOrderPaying ? {color: '#444444'} : {color: '#b0b0b0'};
return(
<TouchableOpacity activeOpacity={1} onPress={() => this.props.onPressOrder && this.props.onPressOrder(orderCode)}>
<View style={styles.container} >
<YH_Image style={styles.goodsImage} url={goodsImage}/>
<Text style={styles.productName} numberOfLines={1}>{productName}</Text>
<Text style={styles.productSkn} numberOfLines={1}>{productSkn}</Text>
<Text style={styles.orderTime} numberOfLines={1}>{orderTime}</Text>
<Text style={styles.orderMoney} numberOfLines={1}>{orderMoney}</Text>
<Text style={[styles.orderStateText, colorStyle]} numberOfLines={1}>{orderStateText}</Text>
</View>
</TouchableOpacity>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
width: width,
height: 80 * DEVICE_WIDTH_RATIO,
borderBottomColor: '#e0e0e0',
borderBottomWidth: 0.5,
},
goodsImage:{
position: 'absolute',
top: 10 * DEVICE_WIDTH_RATIO,
left: 15 * DEVICE_WIDTH_RATIO,
width: 45 * DEVICE_WIDTH_RATIO,
height: 60 * DEVICE_WIDTH_RATIO,
},
productName:{
position: 'absolute',
top: 15 * DEVICE_WIDTH_RATIO,
left: 70 * DEVICE_WIDTH_RATIO,
color: "#444444",
fontSize: 12 * DEVICE_WIDTH_RATIO,
width: 185 * DEVICE_WIDTH_RATIO,
},
productSkn:{
position: 'absolute',
top: 30 * DEVICE_WIDTH_RATIO,
left: 70 * DEVICE_WIDTH_RATIO,
color: "#444444",
fontSize: 12 * DEVICE_WIDTH_RATIO,
},
orderTime:{
position: 'absolute',
top: 50 * DEVICE_WIDTH_RATIO,
left: 70 * DEVICE_WIDTH_RATIO,
color: "#b0b0b0",
fontSize: 12 * DEVICE_WIDTH_RATIO,
},
orderMoney:{
position: 'absolute',
top: 15 * DEVICE_WIDTH_RATIO,
right: 15 * DEVICE_WIDTH_RATIO,
color: "#444444",
fontSize: 14 * DEVICE_WIDTH_RATIO,
},
orderStateText:{
position: 'absolute',
top: 45 * DEVICE_WIDTH_RATIO,
right: 15 * DEVICE_WIDTH_RATIO,
fontSize: 12 * DEVICE_WIDTH_RATIO,
},
});