CouponListContainer.js
2.89 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
import React, { Component } from 'react';
import {
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import ScrollableTabView from 'react-native-scrollable-tab-view';
import {Map} from 'immutable';
import * as couponActions from '../reducers/coupon/couponActions';
import CouponList from '../components/coupon/CouponList';
import CouponTabs from '../components/coupon/CouponTabs';
const actions = [
couponActions,
];
function mapStateToProps(state) {
return {
...state
};
}
function mapDispatchToProps(dispatch) {
const creators = Map()
.merge(...actions)
.filter(value => typeof value === 'function')
.toObject();
return {
actions: bindActionCreators(creators, dispatch),
dispatch
};
}
class CouponListContainer extends Component {
constructor(props) {
super(props);
props.actions.getCouponNums();
props.actions.getCouponList('notuse', true);
props.actions.getCouponList('use', true);
props.actions.getCouponList('overtime', true);
}
state = {couponCode: ''}
render() {
const { couponNums } = this.props.coupon;
return (
<ScrollableTabView
renderTabBar={() => <CouponTabs couponNums={couponNums} />}
>
<View style={styles.container} tabLabel="未使用">
<View style={styles.bindCouponContainer}>
<TextInput
style={styles.textInput}
onChangeText={text => this.setState({couponCode: text})}
placeholder="请输入优惠券码"
underlineColorAndroid="transparent"
/>
<TouchableOpacity
onPress={() => null}
style={[styles.bindCouponBtn, this.state.couponCode.length > 0 && styles.blackBack]}
>
<Text style={styles.bindCouponText}>兑换</Text>
</TouchableOpacity>
</View>
<CouponList />
</View>
<View style={{flex: 1, backgroundColor: 'yellow'}} tabLabel="已使用"/>
<View style={{flex: 1, backgroundColor: 'green'}} tabLabel="已失效"/>
</ScrollableTabView>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
bindCouponContainer: {
height: 45,
paddingHorizontal: 10,
paddingVertical: 8,
flexDirection: 'row',
},
textInput: {
flex: 1,
height: 30,
marginRight: 10,
fontSize: 12,
padding: 0,
paddingLeft: 10,
backgroundColor: '#f0f0f0',
borderRadius: 2,
},
bindCouponBtn: {
width: 60,
height: 30,
backgroundColor: '#b0b0b0',
borderRadius: 2,
justifyContent: 'center',
alignItems: 'center',
},
blackBack: {
backgroundColor: '#444444',
},
bindCouponText: {
fontSize: 14,
color: '#ffffff',
}
})
export default connect(mapStateToProps, mapDispatchToProps)(CouponListContainer);