OrderDetail.js
5.18 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
'use strict';
import React, {Component} from 'react';
import {Dimensions, Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import ListView from 'deprecated-react-native-listview'
import {Immutable} from 'immutable';
export default class OrderDetail extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
_renderHeader() {
let status = this.props.orderDetail.status === '10' ? '(待结算)' : '';
return (
<View>
<View style={styles.header}>
<Text style={[styles.headerText]}>{this.props.orderDetail.orderStatus}</Text>
</View>
<View style={styles.lineView}/>
<View style={styles.content}>
<Text style={styles.contentText}>订单编号:{this.props.orderDetail.orderCode}</Text>
<Text style={styles.contentText}>下单时间:{this.props.orderDetail.orderTimeStr.replace(/-/g,'.')}</Text>
<Text style={styles.contentText}>商品金额:{this.props.orderDetail.lastOrderAmountStr}</Text>
<View style={{flexDirection: 'row'}}>
<Text style={styles.contentText}>佣金金额:</Text>
<Text style={[styles.contentText, {fontWeight: 'bold', color: '#D0021B'}]}>{this.props.orderDetail.amountStr}</Text>
<Text style={styles.contentText}>{status}</Text>
</View>
</View>
<View style={{height: 10, backgroundColor: '#f0f0f0'}}/>
</View>
)
}
_renderRow(rowData, sectionID, rowID) {
let url = rowData.get('image');
return (
<TouchableOpacity activeOpacity={1} onPress={() => {
this.props.onPressProduct && this.props.onPressProduct(rowData);
}}>
<View style={styles.rowView}>
<Image style={styles.picImage} source={{uri: url}} resizeMode={'contain'}/>
<Text style={styles.titleText}>{rowData.get('productName')}</Text>
<View style={styles.rightView}>
<Text style={styles.priceText}>{rowData.get('priceStr')}</Text>
<Text style={styles.numText}>x {rowData.get('num')}</Text>
</View>
</View>
<View style={[styles.lineView, {marginLeft: 15}]}/>
</TouchableOpacity>
);
}
render() {
let {orderDetail} = this.props;
let productList = orderDetail.productList ? orderDetail.productList.toArray() : [];
return (
<View style={styles.container}>
<ListView
ref={(c) => {
this.listView = c;
}}
// yh_viewVisible={true}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(productList)}
renderRow={this._renderRow}
renderHeader={this._renderHeader}/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0',
alignItems: 'center'
},
contentContainer: {
width: width,
backgroundColor: 'white'
},
header: {
width: width,
height: 50,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#FFFFFF',
},
content: {
width: width,
height: 140,
padding: 15,
backgroundColor: '#FFFFFF',
},
headerText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 17,
paddingLeft: 15,
color: '#444444',
letterSpacing: -0,
fontWeight: 'bold',
},
contentText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
paddingBottom: 10,
color: '#444444',
letterSpacing: -0,
},
rowView: {
width: width,
height: 86,
flexDirection: 'row',
padding: 10,
},
picImage: {
width: 50,
height: 66,
marginLeft: 5,
},
titleText: {
flex:1,
marginLeft: 10,
fontSize: 14,
color: '#444444',
letterSpacing: -0,
lineHeight: 18,
fontFamily: 'PingFang-SC-Regular',
},
priceText: {
fontFamily: 'PingFang-SC-Regular',
fontSize: 14,
color: '#D0021B',
textAlign: 'right',
letterSpacing: -0.4,
},
numText: {
marginTop: 5,
fontSize: 12,
color: '#B0B0B0',
letterSpacing: -0.34,
textAlign: 'right',
fontFamily: 'PingFang-SC-Medium',
},
lineView: {
width: width,
height: 0.5,
backgroundColor: '#e0e0e0'
},
rightView: {
width: 95,
}
});