MyOrderList.js
3.85 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
'use strict';
import React from 'react';
import ReactNative, {
View,
Text,
Image,
StyleSheet,
Dimensions,
PixelRatio,
TouchableOpacity,
ListView,
LayoutAnimation,
} from 'react-native';
import Immutable, {Map} from 'immutable';
import LoadingIndicator from '../../../common/components/LoadingIndicator';
import MyOrderListCell from './MyOrderListCell';
import OrderTypeSelector from './OrderTypeSelector';
export default class MyOrderList extends React.Component {
constructor(props) {
super(props);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
this.renderRow = this.renderRow.bind(this);
}
renderRow(rowData, sectionID, rowID, highlightRow) {
return (
<MyOrderListCell
orderData={rowData}
onPressOrder={this.props.onPressOrder}
/>
);
}
render() {
let {isFetching, orderList} = this.props;
let array = orderList ? orderList.toArray() : [];
return (
<View style={styles.container}>
<OrderTypeSelector selectedTypeId={this.props.orderType} onSelectType={this.props.onSelectType} />
<View style={styles.splitLine}></View>
{
isFetching ? null
:
(array.length == 0) ?
<View style={styles.emptyContainer}>
<Image style={styles.emptyIcon} source={require('../../image/review-img-3.png')} resizeMode={'contain'}/>
<Text>暂无订单</Text>
<TouchableOpacity onPress={() => {this.props.onPressGoNew && this.props.onPressGoNew()}} >
<View style={styles.buttonContainer}>
<Text style={styles.button}>去逛逛</Text>
</View>
</TouchableOpacity>
</View>
:
<ListView
style={styles.listContainer}
dataSource={this.dataSource.cloneWithRows(array)}
enableEmptySections={true}
renderRow={this.renderRow}
onEndReached={this.props.onEndReached}
onEndReachedThreshold = {500}
/>
}
<LoadingIndicator isVisible={isFetching}/>
</View>
);
}
};
let {width, height} = Dimensions.get('window');
const DEVICE_WIDTH_RATIO = width / 320;
let styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
},
splitLine: {
width: width,
height: 15 * DEVICE_WIDTH_RATIO,
borderBottomColor: '#e0e0e0',
borderBottomWidth: 0.5,
backgroundColor:'#f0f0f0',
},
listContainer: {
flex: 1,
backgroundColor:'#ffffff',
},
emptyContainer: {
flex: 1,
backgroundColor:'#ffffff',
alignItems: 'center',
},
emptyIcon: {
width: 110 * DEVICE_WIDTH_RATIO,
height: 110 * DEVICE_WIDTH_RATIO,
marginTop: 100 * DEVICE_WIDTH_RATIO,
marginBottom: 25 * DEVICE_WIDTH_RATIO,
},
buttonContainer: {
marginTop: 35 * DEVICE_WIDTH_RATIO,
width: 235 * DEVICE_WIDTH_RATIO,
height: 44 * DEVICE_WIDTH_RATIO,
backgroundColor: '#222222',
borderRadius: 5 * DEVICE_WIDTH_RATIO,
},
button: {
color: 'white',
textAlign: 'center',
fontSize: 14 * DEVICE_WIDTH_RATIO,
backgroundColor: 'transparent',
lineHeight: Math.ceil(29 * DEVICE_WIDTH_RATIO),
},
});