ListFooter.js
3.82 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
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Image,
Dimensions,
} from 'react-native';
import Immutable,{List} from 'immutable';
import ActionView from './ActionView'
export default class ListFooter extends Component {
constructor(props) {
super(props);
this.goodsCount = this.goodsCount.bind(this);
}
goodsCount(){
let orderData = this.props.data;
let goodsCount = orderData.get('goods_quantity',0);
if (goodsCount > 0) {
return goodsCount;
}else {
let orderGoodsList = orderData.get('order_goods',List()).toJS();
let count = 0;
for (var i = 0; i < orderGoodsList.length; i++) {
let goods = orderGoodsList[i];
count += goods.buy_number;
}
return count;
}
}
render(){
let orderData = this.props.data;
let goodsCountString = '共' + this.goodsCount() + '件商品 '; //共n件商品
let payInfoString = '实付';
let orderAmout = orderData.get('amount',0);
let orderPaymentStage = orderData.get('payment_stage');
if (orderPaymentStage == '1') {
payInfoString = '需支付定金';
orderAmout = orderData.get('order_deposit_amount',0);
}
if (orderPaymentStage == '2') {
payInfoString = '已支付定金';
orderAmout = orderData.get('order_deposit_amount',0);
}
if (orderPaymentStage == '3') {
payInfoString = '待支付尾款';
orderAmout = orderData.get('order_tail_pay_amount',0);
}
let shipCost = orderData.get('shipping_cost',0);
let shipCostString = '';
if (shipCost > 0 && orderPaymentStage != '1' && orderPaymentStage != '2') {
shipCostString = '(含运费¥' + shipCost + ')';
}
let buttonArray = orderData ? orderData.get('links').toJS() : [];
return(
<View style={styles.container}>
<View style={styles.price}>
<Text style={styles.count} numberOfLines={1}>
{goodsCountString}
<Text style={styles.payInfo}>
{payInfoString}
</Text>
<Text style={styles.amount}>
{' ¥'+(orderAmout)}
</Text>
<Text style={styles.shippingCost}>
{shipCostString}
</Text>
</Text>
</View>
{buttonArray.length > 0?
<ActionView data={orderData} buttonLiks={buttonArray} orderAction={this.props.orderAction}/>
:null}
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
flexDirection: 'column',
alignItems: 'center',
backgroundColor: 'white',
justifyContent: 'flex-end',
},
price: {
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
height: 46,
width,
borderColor:'#f0f0f0',
borderTopWidth:1,
borderBottomWidth:1,
},
count: {
marginRight: 15,
backgroundColor: 'transparent',
maxWidth: width-30,
color: '#444444',
fontSize: 16,
fontWeight: '100'
},
payInfo: {
fontSize: 16,
color:'#444444',
fontWeight: '100'
},
amount: {
fontSize: 16,
color:'#d0021b',
fontWeight:'normal'
},
shippingCost: {
fontSize: 12,
color: '#444444',
fontWeight: '100',
},
line: {
backgroundColor: '#e5e5e5',
height: 1,
}
});