Account settlement component, reviewer:yu liang.
Showing
7 changed files
with
217 additions
and
66 deletions
@@ -39,6 +39,8 @@ import guideInitialState from './reducers/guide/guideInitialState'; | @@ -39,6 +39,8 @@ import guideInitialState from './reducers/guide/guideInitialState'; | ||
39 | import homeInitialState from './reducers/home/homeInitialState'; | 39 | import homeInitialState from './reducers/home/homeInitialState'; |
40 | import messageInitialState from './reducers/message/messageInitialState'; | 40 | import messageInitialState from './reducers/message/messageInitialState'; |
41 | import userInitialState from './reducers/user/userInitialState'; | 41 | import userInitialState from './reducers/user/userInitialState'; |
42 | +import accountSettlementaInitialState from './reducers/accountSettlement/accountSettlementInitialState'; | ||
43 | + | ||
42 | 44 | ||
43 | import App from './containers/App'; | 45 | import App from './containers/App'; |
44 | import GuideContainer from './containers/GuideContainer'; | 46 | import GuideContainer from './containers/GuideContainer'; |
@@ -69,6 +71,7 @@ function getInitialState() { | @@ -69,6 +71,7 @@ function getInitialState() { | ||
69 | home: (new homeInitialState), | 71 | home: (new homeInitialState), |
70 | message: (new messageInitialState), | 72 | message: (new messageInitialState), |
71 | user: (new userInitialState), | 73 | user: (new userInitialState), |
74 | + // accountSettlement: (new accountSettlementaInitialState), | ||
72 | }; | 75 | }; |
73 | return _initState; | 76 | return _initState; |
74 | } | 77 | } |
js/components/AccountSettlement.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React, {Component} from 'react'; | ||
4 | + | ||
5 | +import { | ||
6 | + StyleSheet, | ||
7 | + View, | ||
8 | + Text, | ||
9 | + ListView, | ||
10 | +} from 'react-native'; | ||
11 | + | ||
12 | + | ||
13 | +let seporatorColor = '#e5e5e5' | ||
14 | + | ||
15 | + | ||
16 | +export default class AccountSettlement extends Component { | ||
17 | + | ||
18 | + constructor(props) { | ||
19 | + super (props); | ||
20 | + | ||
21 | + this.dataSource = new ListView.DataSource({ | ||
22 | + rowHasChanged:(r1,r2)=>r1!==r2, | ||
23 | + sectionHeaderHasChanged: (s1, s2) => s1 !== s2 | ||
24 | + }); | ||
25 | + | ||
26 | + this.renderRow = this.renderRow.bind(this); | ||
27 | + } | ||
28 | + | ||
29 | + renderRow(Data,sectionId) { | ||
30 | + | ||
31 | + switch (sectionId) { | ||
32 | + | ||
33 | + case 'SECTION_HEADER': | ||
34 | + return ( | ||
35 | + <View style={styles.headerContainer}> | ||
36 | + <Text style={[styles.commonText, styles.headerText]}> | ||
37 | + {Data.title} | ||
38 | + </Text> | ||
39 | + <Text style={[styles.valueText, styles.headerText]}> | ||
40 | + {Data.content} | ||
41 | + </Text> | ||
42 | + </View> | ||
43 | + ); | ||
44 | + case 'SECTION_SEPORATOR': | ||
45 | + return( | ||
46 | + <View style={{ | ||
47 | + height:15, | ||
48 | + borderBottomWidth:0.5, | ||
49 | + borderColor:seporatorColor, | ||
50 | + }}/> | ||
51 | + ); | ||
52 | + case 'SECTION_TITLE': | ||
53 | + return( | ||
54 | + <View style={styles.cellContainer}> | ||
55 | + <Text style={[styles.inCellText,{flex:0.9}]}>品牌</Text> | ||
56 | + <View style={{width:1,height:14,backgroundColor:seporatorColor,marginTop:15}}/> | ||
57 | + <Text style={[styles.inCellText,{flex:1.0}]}>生成日期</Text> | ||
58 | + <View style={{width:1,height:14,backgroundColor:seporatorColor,marginTop:15}}/> | ||
59 | + <Text style={[styles.inCellText,{flex:0.8}]}>状态</Text> | ||
60 | + <View style={{width:1,height:14,backgroundColor:seporatorColor,marginTop:15}}/> | ||
61 | + <Text style={[styles.inCellText,{flex:1.3}]}>账单金额(元)</Text> | ||
62 | + | ||
63 | + </View> | ||
64 | + ); | ||
65 | + case 'SECTION_CONTENT': | ||
66 | + return ( | ||
67 | + <View style={styles.cellContainer}> | ||
68 | + <Text style={[styles.inCellText,{flex:0.9}]}>{Data.brand}</Text> | ||
69 | + <Text style={[styles.inCellText,{flex:1.0}]}>{Data.date}</Text> | ||
70 | + <Text style={[styles.inCellText,{flex:0.8}]}>{Data.status}</Text> | ||
71 | + <Text style={[styles.inCellText,{flex:1.3}]}>{Data.bill}</Text> | ||
72 | + </View> | ||
73 | + ); | ||
74 | + } | ||
75 | + | ||
76 | + return (<Text>Error data source</Text>); | ||
77 | + } | ||
78 | + render() { | ||
79 | + return ( | ||
80 | + <ListView | ||
81 | + style={styles.container} | ||
82 | + dataSource = {this.dataSource.cloneWithRowsAndSections(this.props.dataBlob)} | ||
83 | + renderRow = {this.renderRow} | ||
84 | + onEndReachedThreshold = {-200} | ||
85 | + onEndReached = {this.props.fetchNextPage} | ||
86 | + /> | ||
87 | + | ||
88 | + ); | ||
89 | + } | ||
90 | + | ||
91 | +} | ||
92 | + | ||
93 | +const styles = StyleSheet.create({ | ||
94 | + | ||
95 | + cellContainer: { | ||
96 | + backgroundColor:'white', | ||
97 | + borderColor:'red', | ||
98 | + flexDirection: 'row', | ||
99 | + height: 45, | ||
100 | + borderBottomWidth:0.5, | ||
101 | + borderColor:seporatorColor, | ||
102 | + }, | ||
103 | + | ||
104 | + inCellText:{ | ||
105 | + fontSize: 14, | ||
106 | + marginTop: 15, | ||
107 | + color: '#444444', | ||
108 | + flex:1, | ||
109 | + borderBottomWidth:0.5, | ||
110 | + borderColor:seporatorColor, | ||
111 | + textAlign: 'center', | ||
112 | + }, | ||
113 | + | ||
114 | + container: { | ||
115 | + top: 64, | ||
116 | + flex:1, | ||
117 | + | ||
118 | + }, | ||
119 | + | ||
120 | + headerContainer: { | ||
121 | + flex: 1, | ||
122 | + height: 80, | ||
123 | + backgroundColor:'white', | ||
124 | + flexDirection:'column', | ||
125 | + borderBottomWidth:0.5, | ||
126 | + borderColor:seporatorColor, | ||
127 | + }, | ||
128 | + | ||
129 | + commonText:{ | ||
130 | + fontSize: 14, | ||
131 | + marginTop: 20, | ||
132 | + fontWeight:"300", | ||
133 | + color: '#444444' | ||
134 | + }, | ||
135 | + | ||
136 | + valueText:{ | ||
137 | + fontSize: 21, | ||
138 | + marginTop: 10, | ||
139 | + fontWeight: 'bold', | ||
140 | + color: '#d0021b' | ||
141 | + }, | ||
142 | + | ||
143 | + headerText: { | ||
144 | + left:15, | ||
145 | + }, | ||
146 | +}); |
@@ -38,7 +38,9 @@ export default keyMirror({ | @@ -38,7 +38,9 @@ export default keyMirror({ | ||
38 | PHONE_CALL: null, | 38 | PHONE_CALL: null, |
39 | ABOUT_US: null, | 39 | ABOUT_US: null, |
40 | 40 | ||
41 | - | 41 | + ACCOUNT_LIST_REQUEST:null, |
42 | + ACCOUNT_LIST_SUCCESS:null, | ||
43 | + ACCOUNT_LIST_FAILURE:null, | ||
42 | /* | 44 | /* |
43 | GET_PROFILE_REQUEST: null, | 45 | GET_PROFILE_REQUEST: null, |
44 | GET_PROFILE_SUCCESS: null, | 46 | GET_PROFILE_SUCCESS: null, |
@@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
2 | 'use strict'; | 2 | 'use strict'; |
3 | 3 | ||
4 | import React, { Component } from 'react'; | 4 | import React, { Component } from 'react'; |
5 | + | ||
6 | +import AccountSettlement from '../components/AccountSettlement' | ||
7 | + | ||
5 | import { | 8 | import { |
6 | StyleSheet, | 9 | StyleSheet, |
7 | View, | 10 | View, |
@@ -12,7 +15,7 @@ from 'react-native'; | @@ -12,7 +15,7 @@ from 'react-native'; | ||
12 | 15 | ||
13 | export default class AccountSettlementContainer extends Component { | 16 | export default class AccountSettlementContainer extends Component { |
14 | 17 | ||
15 | - constructor(props){ | 18 | + constructor(props) { |
16 | super(props); | 19 | super(props); |
17 | this.dataSource = new ListView.DataSource({ | 20 | this.dataSource = new ListView.DataSource({ |
18 | rowHasChanged:(r1,r2)=>r1!==r2, | 21 | rowHasChanged:(r1,r2)=>r1!==r2, |
@@ -106,7 +109,6 @@ export default class AccountSettlementContainer extends Component { | @@ -106,7 +109,6 @@ export default class AccountSettlementContainer extends Component { | ||
106 | ], | 109 | ], |
107 | }; | 110 | }; |
108 | 111 | ||
109 | - this.renderRow = this.renderRow.bind(this); | ||
110 | this.fetchNextPage = this.fetchNextPage.bind(this); | 112 | this.fetchNextPage = this.fetchNextPage.bind(this); |
111 | this.state = {dataBlob:this.dataBlob}; | 113 | this.state = {dataBlob:this.dataBlob}; |
112 | } | 114 | } |
@@ -122,7 +124,8 @@ export default class AccountSettlementContainer extends Component { | @@ -122,7 +124,8 @@ export default class AccountSettlementContainer extends Component { | ||
122 | date: '2016-01-23', | 124 | date: '2016-01-23', |
123 | status: '已出账单', | 125 | status: '已出账单', |
124 | bill:'923.00' | 126 | bill:'923.00' |
125 | - },{ | 127 | + }, |
128 | + { | ||
126 | brand:'vans', | 129 | brand:'vans', |
127 | date: '2016-01-23', | 130 | date: '2016-01-23', |
128 | status: '已出账单', | 131 | status: '已出账单', |
@@ -132,71 +135,13 @@ export default class AccountSettlementContainer extends Component { | @@ -132,71 +135,13 @@ export default class AccountSettlementContainer extends Component { | ||
132 | console.log(this.dataBlob.SECTION_CONTENT); | 135 | console.log(this.dataBlob.SECTION_CONTENT); |
133 | this.setState({dataBlob:this.dataBlob}); | 136 | this.setState({dataBlob:this.dataBlob}); |
134 | } | 137 | } |
135 | - | ||
136 | - renderRow(Data,sectionId) { | ||
137 | - | ||
138 | - switch (sectionId) { | ||
139 | - | ||
140 | - case 'SECTION_HEADER': | ||
141 | - return ( | ||
142 | - <View style={styles.headerContainer}> | ||
143 | - <Text style={[styles.commonText, styles.headerText]}> | ||
144 | - {Data.title} | ||
145 | - </Text> | ||
146 | - <Text style={[styles.valueText, styles.headerText]}> | ||
147 | - {Data.content} | ||
148 | - </Text> | ||
149 | - </View> | ||
150 | - ); | ||
151 | - case 'SECTION_SEPORATOR': | ||
152 | - return( | ||
153 | - <View style= | ||
154 | - {{ | ||
155 | - height:15, | ||
156 | - borderBottomWidth:0.5, | ||
157 | - borderColor:seporatorColor, | ||
158 | - }}/> | ||
159 | - ); | ||
160 | - case 'SECTION_TITLE': | ||
161 | - return( | ||
162 | - <View style={styles.cellContainer}> | ||
163 | - <Text style={[styles.inCellText,{flex:0.9}]}>品牌</Text> | ||
164 | - <View style={{width:1,height:14,backgroundColor:seporatorColor,marginTop:15}}/> | ||
165 | - <Text style={[styles.inCellText,{flex:1.0}]}>生成日期</Text> | ||
166 | - <View style={{width:1,height:14,backgroundColor:seporatorColor,marginTop:15}}/> | ||
167 | - <Text style={[styles.inCellText,{flex:0.8}]}>状态</Text> | ||
168 | - <View style={{width:1,height:14,backgroundColor:seporatorColor,marginTop:15}}/> | ||
169 | - <Text style={[styles.inCellText,{flex:1.3}]}>账单金额(元)</Text> | ||
170 | - | ||
171 | - </View> | ||
172 | - ); | ||
173 | - case 'SECTION_CONTENT': | ||
174 | - return ( | ||
175 | - <View style={styles.cellContainer}> | ||
176 | - <Text style={[styles.inCellText,{flex:0.9}]}>{Data.brand}</Text> | ||
177 | - <Text style={[styles.inCellText,{flex:1.0}]}>{Data.date}</Text> | ||
178 | - <Text style={[styles.inCellText,{flex:0.8}]}>{Data.status}</Text> | ||
179 | - <Text style={[styles.inCellText,{flex:1.3}]}>{Data.bill}</Text> | ||
180 | - </View> | ||
181 | - ); | ||
182 | - } | ||
183 | - | ||
184 | - return (<Text>Error data source</Text>); | ||
185 | - } | ||
186 | render() { | 138 | render() { |
187 | return ( | 139 | return ( |
188 | - <View style={{flex:1}}> | ||
189 | - <ListView | ||
190 | - style={styles.container} | ||
191 | - dataSource = {this.dataSource.cloneWithRowsAndSections(this.state.dataBlob)} | ||
192 | - renderRow = {this.renderRow} | ||
193 | - onEndReachedThreshold = {100} | ||
194 | - onEndReached = {this.fetchNextPage} | ||
195 | - > | ||
196 | - | ||
197 | - </ListView> | 140 | + <AccountSettlement |
141 | + dataBlob={this.state.dataBlob} | ||
142 | + fetchNextPage={this.fetchNextPage} | ||
143 | + /> | ||
198 | 144 | ||
199 | - </View> | ||
200 | ); | 145 | ); |
201 | } | 146 | } |
202 | } | 147 | } |
1 | +'use strict'; | ||
2 | +import Request from '../services/Request'; | ||
3 | + | ||
4 | +const { | ||
5 | + ACCOUNT_LIST_REQUEST, | ||
6 | + ACCOUNT_LIST_SUCCESS, | ||
7 | + ACCOUNT_LIST_FAILURE, | ||
8 | + | ||
9 | +} = require('../../constants/actionTypes').default; | ||
10 | + | ||
11 | +/** | ||
12 | + * Request next page of account settlement data list... | ||
13 | + * @method nextPageOfDataRequest | ||
14 | + * @return {JS Objecrt} | ||
15 | + */ | ||
16 | +export function nextPageOfDataRequest() { | ||
17 | + | ||
18 | + | ||
19 | + return { | ||
20 | + type: ACCOUNT_LIST_REQUEST, | ||
21 | + } | ||
22 | +} | ||
23 | + | ||
24 | +/** | ||
25 | + * Success to fetch data.. | ||
26 | + * @method nextPageOfDataSuccess | ||
27 | + * @param {Maybe array} json remote data | ||
28 | + * @return {[type]} [description] | ||
29 | + */ | ||
30 | +export function nextPageOfDataSuccess(json) { | ||
31 | + return { | ||
32 | + type: ACCOUNT_LIST_SUCCESS, | ||
33 | + playload: json, | ||
34 | + } | ||
35 | +} | ||
36 | + | ||
37 | +export function nextPageOfDataFailure(error) { | ||
38 | + return { | ||
39 | + type: ACCOUNT_LIST_FAILURE, | ||
40 | + playload: error, | ||
41 | + } | ||
42 | +} |
1 | +'use strict'; |
-
Please register or login to post a comment