Merge branch 'develop' of http://git.dev.yoho.cn/mobile/yh_vendor into develop
# Conflicts: # js/Vendor.js # js/constants/actionTypes.js # js/reducers/index.js # js/services/HomeService.js
Showing
17 changed files
with
433 additions
and
49 deletions
@@ -40,6 +40,7 @@ import homeInitialState from './reducers/home/homeInitialState'; | @@ -40,6 +40,7 @@ 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 accountSettlementInitialState from './reducers/accountSettlement/accountSettlementInitialState'; | 42 | import accountSettlementInitialState from './reducers/accountSettlement/accountSettlementInitialState'; |
43 | +import saleStatisticsInitialState from './reducers/saleStatistics/saleStatisticsInitialState'; | ||
43 | 44 | ||
44 | 45 | ||
45 | import App from './containers/App'; | 46 | import App from './containers/App'; |
@@ -54,6 +55,7 @@ import ModifyPasswordContainer from './containers/ModifyPasswordContainer' | @@ -54,6 +55,7 @@ import ModifyPasswordContainer from './containers/ModifyPasswordContainer' | ||
54 | import AccountSettlementContainer from './containers/AccountSettlementContainer' | 55 | import AccountSettlementContainer from './containers/AccountSettlementContainer' |
55 | import AboutUsContainer from './containers/AboutUsContainer' | 56 | import AboutUsContainer from './containers/AboutUsContainer' |
56 | import StockStatsContainer from './containers/StockStatsContainer' | 57 | import StockStatsContainer from './containers/StockStatsContainer' |
58 | +import SaleStatisticsContainer from './containers/SaleStatisticsContainer' | ||
57 | 59 | ||
58 | import NavBar from './components/NavBar'; | 60 | import NavBar from './components/NavBar'; |
59 | import TabIcon from './containers/TabIcon'; | 61 | import TabIcon from './containers/TabIcon'; |
@@ -75,6 +77,8 @@ function getInitialState() { | @@ -75,6 +77,8 @@ function getInitialState() { | ||
75 | message: (new messageInitialState), | 77 | message: (new messageInitialState), |
76 | user: (new userInitialState), | 78 | user: (new userInitialState), |
77 | actStmt: (new accountSettlementInitialState), | 79 | actStmt: (new accountSettlementInitialState), |
80 | + saleStats: (new saleStatisticsInitialState()), | ||
81 | + stockStats: (new stockStatsInitialState()), | ||
78 | }; | 82 | }; |
79 | return _initState; | 83 | return _initState; |
80 | } | 84 | } |
@@ -100,7 +104,7 @@ export default function native(platform) { | @@ -100,7 +104,7 @@ export default function native(platform) { | ||
100 | // setup the router table with App selected as the initial component | 104 | // setup the router table with App selected as the initial component |
101 | return ( | 105 | return ( |
102 | <Provider store={store}> | 106 | <Provider store={store}> |
103 | - <NewRouter hideNavBar={false}> | 107 | + <NewRouter hideNavBar={false} sceneStyle={styles.scene}> |
104 | <Scene key="root" > | 108 | <Scene key="root" > |
105 | <Scene | 109 | <Scene |
106 | key="App" | 110 | key="App" |
@@ -145,12 +149,13 @@ export default function native(platform) { | @@ -145,12 +149,13 @@ export default function native(platform) { | ||
145 | type="push" | 149 | type="push" |
146 | /> | 150 | /> |
147 | <Scene | 151 | <Scene |
148 | - key="Test" | ||
149 | - component={GuideContainer} | ||
150 | - title='Test' | 152 | + key="SaleStats" |
153 | + component={SaleStatisticsContainer} | ||
154 | + title='销售统计' | ||
151 | hideNavBar={false} | 155 | hideNavBar={false} |
152 | initial={false} | 156 | initial={false} |
153 | navBar={NavBar} | 157 | navBar={NavBar} |
158 | + titleStyle={styles.navTitle} | ||
154 | type='push' | 159 | type='push' |
155 | /> | 160 | /> |
156 | 161 | ||
@@ -188,7 +193,7 @@ export default function native(platform) { | @@ -188,7 +193,7 @@ export default function native(platform) { | ||
188 | /> | 193 | /> |
189 | 194 | ||
190 | <Scene key="Drawer" component={DrawerContainer} type="replace" hideNavBar={true} > | 195 | <Scene key="Drawer" component={DrawerContainer} type="replace" hideNavBar={true} > |
191 | - <Scene key="Tabbar" tabs={true} initial={false} type="replace" component={TabBar} > | 196 | + <Scene key="Tabbar" tabs={true} initial={false} type="replace" component={TabBar}> |
192 | <Scene | 197 | <Scene |
193 | key="Home" | 198 | key="Home" |
194 | title="首页" | 199 | title="首页" |
@@ -239,6 +244,9 @@ export default function native(platform) { | @@ -239,6 +244,9 @@ export default function native(platform) { | ||
239 | } | 244 | } |
240 | 245 | ||
241 | let styles = StyleSheet.create({ | 246 | let styles = StyleSheet.create({ |
247 | + scene: { | ||
248 | + backgroundColor:'#F0F0F0', | ||
249 | + }, | ||
242 | navTitle: { | 250 | navTitle: { |
243 | color: 'white', | 251 | color: 'white', |
244 | }, | 252 | }, |
@@ -19,7 +19,7 @@ export default class Placeholder extends Component { | @@ -19,7 +19,7 @@ export default class Placeholder extends Component { | ||
19 | }; | 19 | }; |
20 | 20 | ||
21 | render() { | 21 | render() { |
22 | - | 22 | + |
23 | return ( | 23 | return ( |
24 | <View style={[styles.container, this.props.containerStyle]} /> | 24 | <View style={[styles.container, this.props.containerStyle]} /> |
25 | ); | 25 | ); |
@@ -32,7 +32,8 @@ let styles = StyleSheet.create({ | @@ -32,7 +32,8 @@ let styles = StyleSheet.create({ | ||
32 | container: { | 32 | container: { |
33 | width, | 33 | width, |
34 | height: 15, | 34 | height: 15, |
35 | - backgroundColor: '#F0F0F0', | 35 | + backgroundColor: 'transparent', |
36 | + // backgroundColor: '#F0F0F0', | ||
36 | }, | 37 | }, |
37 | 38 | ||
38 | -}); | ||
39 | +}); |
js/components/SaleStatistics.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react-native'; | ||
4 | +import TrendTextSection from './TrendTextSection'; | ||
5 | +import Placeholder from './Placeholder'; | ||
6 | + | ||
7 | +let { | ||
8 | + Component, | ||
9 | + View, | ||
10 | + Text, | ||
11 | + ScrollView, | ||
12 | + Platform | ||
13 | +} = React; | ||
14 | + | ||
15 | +export default class SaleStatistics extends Component { | ||
16 | + | ||
17 | + static propTypes = { | ||
18 | + section1: React.PropTypes.arrayOf( | ||
19 | + React.PropTypes.shape({ | ||
20 | + top: React.PropTypes.string, | ||
21 | + bottom: React.PropTypes.string, | ||
22 | + style: View.propTypes.style, | ||
23 | + arrowUp: React.PropTypes.bool, | ||
24 | + }) | ||
25 | + ), | ||
26 | + section2: React.PropTypes.arrayOf( | ||
27 | + React.PropTypes.shape({ | ||
28 | + top: React.PropTypes.string, | ||
29 | + bottom: React.PropTypes.string, | ||
30 | + style: View.propTypes.style, | ||
31 | + arrowUp: React.PropTypes.bool, | ||
32 | + }) | ||
33 | + ), | ||
34 | + }; | ||
35 | + | ||
36 | + render() { | ||
37 | + | ||
38 | + return ( | ||
39 | + <ScrollView> | ||
40 | + | ||
41 | + <TrendTextSection content={this.props.section1} /> | ||
42 | + <Placeholder /> | ||
43 | + <TrendTextSection content={this.props.section2} /> | ||
44 | + <Placeholder /> | ||
45 | + | ||
46 | + | ||
47 | + </ScrollView> | ||
48 | + ); | ||
49 | + | ||
50 | + } | ||
51 | +} |
@@ -28,18 +28,19 @@ export default class TrendText extends Component { | @@ -28,18 +28,19 @@ export default class TrendText extends Component { | ||
28 | }; | 28 | }; |
29 | 29 | ||
30 | render() { | 30 | render() { |
31 | - | 31 | + |
32 | let arrow = this.props.arrowUp ? require('../images/arrow_up.png') : require('../images/arrow_down.png'); | 32 | let arrow = this.props.arrowUp ? require('../images/arrow_up.png') : require('../images/arrow_down.png'); |
33 | + let bottomTextColor = this.props.arrowUp ? styles.bottomTextUp : styles.bottomTextDown; | ||
33 | 34 | ||
34 | return ( | 35 | return ( |
35 | <View style={[styles.container, this.props.containerStyle]}> | 36 | <View style={[styles.container, this.props.containerStyle]}> |
36 | <Text style={[styles.topText, this.props.topTextStyle]}>{this.props.topText}</Text> | 37 | <Text style={[styles.topText, this.props.topTextStyle]}>{this.props.topText}</Text> |
37 | <View style={styles.richContainer}> | 38 | <View style={styles.richContainer}> |
38 | <Image source={arrow} style={[styles.image, this.props.imageStyle]} /> | 39 | <Image source={arrow} style={[styles.image, this.props.imageStyle]} /> |
39 | - <Text style={[styles.bottomText, this.props.bottomTextStyle]}>{this.props.bottomText}</Text> | 40 | + <Text style={[styles.bottomText, bottomTextColor, this.props.bottomTextStyle]}>{this.props.bottomText}</Text> |
40 | <Text style={[styles.smallText, this.props.smallTextStyle]}>{this.props.smallText}</Text> | 41 | <Text style={[styles.smallText, this.props.smallTextStyle]}>{this.props.smallText}</Text> |
41 | </View> | 42 | </View> |
42 | - | 43 | + |
43 | </View> | 44 | </View> |
44 | ); | 45 | ); |
45 | } | 46 | } |
@@ -72,14 +73,19 @@ let styles = StyleSheet.create({ | @@ -72,14 +73,19 @@ let styles = StyleSheet.create({ | ||
72 | }, | 73 | }, |
73 | bottomText: { | 74 | bottomText: { |
74 | fontSize: 17, | 75 | fontSize: 17, |
75 | - color: '#D0021B', | ||
76 | fontWeight: 'bold', | 76 | fontWeight: 'bold', |
77 | textAlign: 'center', | 77 | textAlign: 'center', |
78 | }, | 78 | }, |
79 | + bottomTextUp: { | ||
80 | + color: '#D0021B', | ||
81 | + }, | ||
82 | + bottomTextDown: { | ||
83 | + color: '#86BF4A', | ||
84 | + }, | ||
79 | smallText: { | 85 | smallText: { |
80 | fontSize: 12, | 86 | fontSize: 12, |
81 | textAlign: 'center', | 87 | textAlign: 'center', |
82 | color: '#444444', | 88 | color: '#444444', |
83 | }, | 89 | }, |
84 | 90 | ||
85 | -}); | ||
91 | +}); |
@@ -24,7 +24,7 @@ export default class User extends Component { | @@ -24,7 +24,7 @@ export default class User extends Component { | ||
24 | } | 24 | } |
25 | 25 | ||
26 | render() { | 26 | render() { |
27 | - var items = this.props.items; | 27 | + let items = this.props.items; |
28 | 28 | ||
29 | return ( | 29 | return ( |
30 | <ListView | 30 | <ListView |
@@ -36,7 +36,7 @@ export default class User extends Component { | @@ -36,7 +36,7 @@ export default class User extends Component { | ||
36 | } | 36 | } |
37 | 37 | ||
38 | _renderItem(item) { | 38 | _renderItem(item) { |
39 | - var icon = item.icon; | 39 | + let icon = item.icon; |
40 | return ( | 40 | return ( |
41 | <TouchableOpacity activeOpacity={0.5} onPress={() => this.props.onItemPressed(item)}> | 41 | <TouchableOpacity activeOpacity={0.5} onPress={() => this.props.onItemPressed(item)}> |
42 | <View style={styles.row}> | 42 | <View style={styles.row}> |
@@ -75,7 +75,7 @@ const styles = StyleSheet.create({ | @@ -75,7 +75,7 @@ const styles = StyleSheet.create({ | ||
75 | padding: 10, | 75 | padding: 10, |
76 | }, | 76 | }, |
77 | listView: { | 77 | listView: { |
78 | - marginTop: 120, | 78 | + marginTop: 56, |
79 | 79 | ||
80 | }, | 80 | }, |
81 | separator: { | 81 | separator: { |
@@ -61,6 +61,9 @@ export default keyMirror({ | @@ -61,6 +61,9 @@ export default keyMirror({ | ||
61 | STOCK_STATS_REQUEST: null, | 61 | STOCK_STATS_REQUEST: null, |
62 | STOCK_STATS_SUCCESS: null, | 62 | STOCK_STATS_SUCCESS: null, |
63 | STOCK_STATS_FAILURE: null, | 63 | STOCK_STATS_FAILURE: null, |
64 | + SALE_STATS_REQUEST: null, | ||
65 | + SALE_STATS_SUCCESS: null, | ||
66 | + SALE_STATS_FAILURE: null, | ||
64 | 67 | ||
65 | /* | 68 | /* |
66 | GET_PROFILE_REQUEST: null, | 69 | GET_PROFILE_REQUEST: null, |
1 | 'use strict'; | 1 | 'use strict'; |
2 | /* | 2 | /* |
3 | * ## Imports | 3 | * ## Imports |
4 | - * | 4 | + * |
5 | * Imports from redux | 5 | * Imports from redux |
6 | */ | 6 | */ |
7 | import { bindActionCreators } from 'redux'; | 7 | import { bindActionCreators } from 'redux'; |
@@ -22,7 +22,7 @@ import * as userActions from '../reducers/user/userActions'; | @@ -22,7 +22,7 @@ import * as userActions from '../reducers/user/userActions'; | ||
22 | * The components we need from ReactNative | 22 | * The components we need from ReactNative |
23 | */ | 23 | */ |
24 | import React, | 24 | import React, |
25 | -{ | 25 | +{ |
26 | StatusBar, | 26 | StatusBar, |
27 | StyleSheet, | 27 | StyleSheet, |
28 | View, | 28 | View, |
@@ -65,27 +65,11 @@ function mapDispatchToProps(dispatch) { | @@ -65,27 +65,11 @@ function mapDispatchToProps(dispatch) { | ||
65 | dispatch | 65 | dispatch |
66 | }; | 66 | }; |
67 | } | 67 | } |
68 | - | ||
69 | - | ||
70 | -let styles = StyleSheet.create({ | ||
71 | - container: { | ||
72 | - borderTopWidth: 2, | ||
73 | - borderBottomWidth:2, | ||
74 | - marginTop: 80, | ||
75 | - padding: 10 | ||
76 | - }, | ||
77 | - summary: { | ||
78 | - fontFamily: 'BodoniSvtyTwoITCTT-Book', | ||
79 | - fontSize: 18, | ||
80 | - fontWeight: 'bold' | ||
81 | - } | ||
82 | -}); | ||
83 | - | ||
84 | /** | 68 | /** |
85 | * ## App class | 69 | * ## App class |
86 | */ | 70 | */ |
87 | class App extends Component { | 71 | class App extends Component { |
88 | - | 72 | + |
89 | componentDidMount() { | 73 | componentDidMount() { |
90 | this.props.actions.getDisplayState(); | 74 | this.props.actions.getDisplayState(); |
91 | 75 | ||
@@ -94,7 +78,7 @@ class App extends Component { | @@ -94,7 +78,7 @@ class App extends Component { | ||
94 | render() { | 78 | render() { |
95 | return ( | 79 | return ( |
96 | <StatusBar | 80 | <StatusBar |
97 | - hidden={false} | 81 | + hidden={false} |
98 | barStyle={'light-content'} | 82 | barStyle={'light-content'} |
99 | /> | 83 | /> |
100 | ); | 84 | ); |
@@ -104,4 +88,4 @@ class App extends Component { | @@ -104,4 +88,4 @@ class App extends Component { | ||
104 | /** | 88 | /** |
105 | * Connect the properties | 89 | * Connect the properties |
106 | */ | 90 | */ |
107 | -export default connect(mapStateToProps, mapDispatchToProps)(App); | ||
91 | +export default connect(mapStateToProps, mapDispatchToProps)(App); |
@@ -14,6 +14,7 @@ import CONFIG from '../constants/config'; | @@ -14,6 +14,7 @@ import CONFIG from '../constants/config'; | ||
14 | 14 | ||
15 | let { | 15 | let { |
16 | Component, | 16 | Component, |
17 | + StatusBar, | ||
17 | ScrollView, | 18 | ScrollView, |
18 | View, | 19 | View, |
19 | StyleSheet, | 20 | StyleSheet, |
@@ -58,7 +59,7 @@ class HomeContainer extends Component { | @@ -58,7 +59,7 @@ class HomeContainer extends Component { | ||
58 | 59 | ||
59 | constructor(props) { | 60 | constructor(props) { |
60 | super(props); | 61 | super(props); |
61 | - | 62 | + |
62 | this._onPressCategory = this._onPressCategory.bind(this); | 63 | this._onPressCategory = this._onPressCategory.bind(this); |
63 | 64 | ||
64 | this.category = [ | 65 | this.category = [ |
@@ -133,7 +134,11 @@ class HomeContainer extends Component { | @@ -133,7 +134,11 @@ class HomeContainer extends Component { | ||
133 | 134 | ||
134 | return ( | 135 | return ( |
135 | <View style={styles.container}> | 136 | <View style={styles.container}> |
136 | - <Home | 137 | + <StatusBar |
138 | + hidden={false} | ||
139 | + barStyle={'light-content'} | ||
140 | + /> | ||
141 | + <Home | ||
137 | section1={section1} | 142 | section1={section1} |
138 | section2={section2} | 143 | section2={section2} |
139 | section3={this.category} | 144 | section3={this.category} |
@@ -151,7 +156,7 @@ let styles = StyleSheet.create({ | @@ -151,7 +156,7 @@ let styles = StyleSheet.create({ | ||
151 | top: 64, | 156 | top: 64, |
152 | height: height - 64 - 49, | 157 | height: height - 64 - 49, |
153 | }, | 158 | }, |
154 | - | 159 | + |
155 | }); | 160 | }); |
156 | 161 | ||
157 | export default connect(mapStateToProps, mapDispatchToProps)(HomeContainer); | 162 | export default connect(mapStateToProps, mapDispatchToProps)(HomeContainer); |
@@ -13,8 +13,11 @@ import * as messageActions from '../reducers/message/messageActions'; | @@ -13,8 +13,11 @@ import * as messageActions from '../reducers/message/messageActions'; | ||
13 | 13 | ||
14 | let { | 14 | let { |
15 | Component, | 15 | Component, |
16 | + StatusBar, | ||
16 | View, | 17 | View, |
17 | - Text | 18 | + Text, |
19 | + StyleSheet, | ||
20 | + Dimensions | ||
18 | } = React; | 21 | } = React; |
19 | 22 | ||
20 | const actions = [ | 23 | const actions = [ |
@@ -42,11 +45,27 @@ function mapDispatchToProps(dispatch) { | @@ -42,11 +45,27 @@ function mapDispatchToProps(dispatch) { | ||
42 | 45 | ||
43 | class MessageContainer extends Component { | 46 | class MessageContainer extends Component { |
44 | render() { | 47 | render() { |
45 | - | 48 | + |
46 | return ( | 49 | return ( |
47 | - <Message/> | 50 | + <View style={styles.container}> |
51 | + <StatusBar | ||
52 | + hidden={false} | ||
53 | + barStyle={'light-content'} | ||
54 | + /> | ||
55 | + <Message/> | ||
56 | + </View> | ||
48 | ); | 57 | ); |
49 | } | 58 | } |
50 | } | 59 | } |
51 | 60 | ||
52 | -export default connect(mapStateToProps, mapDispatchToProps)(MessageContainer); | ||
61 | +let {width, height} = Dimensions.get('window'); | ||
62 | + | ||
63 | +let styles = StyleSheet.create({ | ||
64 | + container: { | ||
65 | + top: 64, | ||
66 | + height: height - 64 - 49, | ||
67 | + }, | ||
68 | + | ||
69 | +}); | ||
70 | + | ||
71 | +export default connect(mapStateToProps, mapDispatchToProps)(MessageContainer); |
js/containers/SaleStatisticsContainer.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +/** | ||
4 | + * 销售统计 | ||
5 | + */ | ||
6 | + | ||
7 | +import React from 'react-native'; | ||
8 | + | ||
9 | +import {bindActionCreators} from 'redux'; | ||
10 | +import {connect} from 'react-redux'; | ||
11 | + | ||
12 | +import {Map} from 'immutable'; | ||
13 | + | ||
14 | +import SaleStatistics from '../components/SaleStatistics'; | ||
15 | + | ||
16 | +import * as saleStatisticsActions from '../reducers/saleStatistics/saleStatisticsActions'; | ||
17 | + | ||
18 | +let { | ||
19 | + Component, | ||
20 | + ScrollView, | ||
21 | + View, | ||
22 | + StyleSheet, | ||
23 | + Dimensions | ||
24 | +} = React; | ||
25 | + | ||
26 | +const actions = [ | ||
27 | + saleStatisticsActions | ||
28 | +]; | ||
29 | + | ||
30 | +function mapStateToProps(state) { | ||
31 | + return { | ||
32 | + ...state | ||
33 | + }; | ||
34 | +}; | ||
35 | + | ||
36 | +function mapDispatchToProps(dispatch) { | ||
37 | + | ||
38 | + const creators = Map() | ||
39 | + .merge(...actions) | ||
40 | + .filter(value => typeof value === 'function') | ||
41 | + .toObject(); | ||
42 | + | ||
43 | + return { | ||
44 | + actions: bindActionCreators(creators, dispatch), | ||
45 | + dispatch | ||
46 | + }; | ||
47 | +} | ||
48 | + | ||
49 | +class SalestisticsContainer extends Component { | ||
50 | + | ||
51 | + constructor(props) { | ||
52 | + super(props); | ||
53 | + | ||
54 | + | ||
55 | + | ||
56 | + } | ||
57 | + | ||
58 | + componentDidMount() { | ||
59 | + | ||
60 | + } | ||
61 | + | ||
62 | + | ||
63 | + render() { | ||
64 | + | ||
65 | + let section1 = [ | ||
66 | + { | ||
67 | + top: '有效订单的商品金额(元)', | ||
68 | + bottom: `${this.props.saleStats.goodsAmount}`, | ||
69 | + }, | ||
70 | + { | ||
71 | + top: '环比', | ||
72 | + arrowUp: this.props.saleStats.amountRise, | ||
73 | + bottom: `${this.props.saleStats.amountRisePercent}`, | ||
74 | + bottom: '1.8%', | ||
75 | + } | ||
76 | + ]; | ||
77 | + | ||
78 | + let section2 = [ | ||
79 | + { | ||
80 | + top: '有效订单的商品件数', | ||
81 | + bottom: `${this.props.saleStats.goodsCount}`, | ||
82 | + }, | ||
83 | + { | ||
84 | + top: '环比', | ||
85 | + arrowUp: this.props.saleStats.countRise, | ||
86 | + arrowUp: false, | ||
87 | + bottom: `${this.props.saleStats.countRisePercent}`, | ||
88 | + bottom: '10.8%', | ||
89 | + } | ||
90 | + ]; | ||
91 | + | ||
92 | + return ( | ||
93 | + <View style={styles.container}> | ||
94 | + <SaleStatistics | ||
95 | + section1={section1} | ||
96 | + section2={section2} | ||
97 | + /> | ||
98 | + </View> | ||
99 | + ); | ||
100 | + } | ||
101 | +} | ||
102 | + | ||
103 | +let {width, height} = Dimensions.get('window'); | ||
104 | + | ||
105 | +let styles = StyleSheet.create({ | ||
106 | + container: { | ||
107 | + top: 64, | ||
108 | + height: height - 64 - 49, | ||
109 | + }, | ||
110 | + | ||
111 | +}); | ||
112 | + | ||
113 | +export default connect(mapStateToProps, mapDispatchToProps)(SalestisticsContainer); |
@@ -13,8 +13,11 @@ import * as userActions from '../reducers/user/userActions'; | @@ -13,8 +13,11 @@ import * as userActions from '../reducers/user/userActions'; | ||
13 | 13 | ||
14 | let { | 14 | let { |
15 | Component, | 15 | Component, |
16 | + StatusBar, | ||
16 | View, | 17 | View, |
17 | - Text | 18 | + Text, |
19 | + StyleSheet, | ||
20 | + Dimensions | ||
18 | } = React; | 21 | } = React; |
19 | 22 | ||
20 | const actions = [ | 23 | const actions = [ |
@@ -44,9 +47,28 @@ class UserContainer extends Component { | @@ -44,9 +47,28 @@ class UserContainer extends Component { | ||
44 | 47 | ||
45 | render() { | 48 | render() { |
46 | return ( | 49 | return ( |
47 | - <User items={this.props.user.listItems.toArray()} onItemPressed={(item) => this.props.actions.userItemsPressed(item)}/> | 50 | + <View style={styles.container}> |
51 | + <StatusBar | ||
52 | + hidden={false} | ||
53 | + barStyle={'light-content'} | ||
54 | + /> | ||
55 | + <User | ||
56 | + items={this.props.user.listItems.toArray()} | ||
57 | + onItemPressed={(item) => this.props.actions.userItemsPressed(item)} | ||
58 | + /> | ||
59 | + </View> | ||
48 | ); | 60 | ); |
49 | } | 61 | } |
50 | } | 62 | } |
51 | 63 | ||
64 | +let {width, height} = Dimensions.get('window'); | ||
65 | + | ||
66 | +let styles = StyleSheet.create({ | ||
67 | + container: { | ||
68 | + top: 64, | ||
69 | + height: height - 64 - 49, | ||
70 | + }, | ||
71 | + | ||
72 | +}); | ||
73 | + | ||
52 | export default connect(mapStateToProps, mapDispatchToProps)(UserContainer); | 74 | export default connect(mapStateToProps, mapDispatchToProps)(UserContainer); |
@@ -43,7 +43,7 @@ export default function userReducer(state = initialState, action) { | @@ -43,7 +43,7 @@ export default function userReducer(state = initialState, action) { | ||
43 | case HOME_OVERVIEW_REQUEST: { | 43 | case HOME_OVERVIEW_REQUEST: { |
44 | let nextState = state.set('isFetching', true) | 44 | let nextState = state.set('isFetching', true) |
45 | .set('error', null) | 45 | .set('error', null) |
46 | - .set('shopId', action.payload.shopId); | 46 | + .set('shopId', action.payload); |
47 | return nextState; | 47 | return nextState; |
48 | } | 48 | } |
49 | 49 |
@@ -15,8 +15,9 @@ import guide from './guide/guideReducer'; | @@ -15,8 +15,9 @@ import guide from './guide/guideReducer'; | ||
15 | import home from './home/homeReducer'; | 15 | import home from './home/homeReducer'; |
16 | import message from './message/messageReducer'; | 16 | import message from './message/messageReducer'; |
17 | import user from './user/userReducer'; | 17 | import user from './user/userReducer'; |
18 | -import actStmt from './accountSettlement/accountSettlementReducer' | ||
19 | -import stockStats from './stockStats/stockStatsReducer' | 18 | +import stockStats from './stockStats/stockStatsReducer'; |
19 | +import actStmt from './accountSettlement/accountSettlementReducer'; | ||
20 | +import saleStats from './saleStatistics/saleStatisticsReducer'; | ||
20 | 21 | ||
21 | import { combineReducers } from 'redux'; | 22 | import { combineReducers } from 'redux'; |
22 | 23 | ||
@@ -34,6 +35,7 @@ const rootReducer = combineReducers({ | @@ -34,6 +35,7 @@ const rootReducer = combineReducers({ | ||
34 | user, | 35 | user, |
35 | actStmt, | 36 | actStmt, |
36 | stockStats, | 37 | stockStats, |
38 | + saleStats | ||
37 | }); | 39 | }); |
38 | 40 | ||
39 | export default rootReducer; | 41 | export default rootReducer; |
1 | +/** | ||
2 | + * # guideActions.js | ||
3 | + * | ||
4 | + * App user guide | ||
5 | + * | ||
6 | + */ | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +import {Actions} from 'react-native-router-flux'; | ||
10 | +import CONFIG from '../../constants/config'; | ||
11 | +import HomeService from '../../services/HomeService'; | ||
12 | + | ||
13 | +const { | ||
14 | + | ||
15 | + SALE_STATS_REQUEST, | ||
16 | + SALE_STATS_SUCCESS, | ||
17 | + SALE_STATS_FAILURE, | ||
18 | + | ||
19 | +} = require('../../constants/actionTypes').default; | ||
20 | + | ||
21 | +export function saleStatsRequest(shopId) { | ||
22 | + return { | ||
23 | + type: SALE_STATS_REQUEST, | ||
24 | + payload: shopId | ||
25 | + }; | ||
26 | +} | ||
27 | + | ||
28 | +export function saleStatsSuccess(json) { | ||
29 | + return { | ||
30 | + type: SALE_STATS_SUCCESS, | ||
31 | + payload: json | ||
32 | + }; | ||
33 | +} | ||
34 | + | ||
35 | +export function saleStatsFailure(error) { | ||
36 | + return { | ||
37 | + type: SALE_STATS_FAILURE, | ||
38 | + payload: error | ||
39 | + }; | ||
40 | +} | ||
41 | + | ||
42 | +export function saleStats(shopId) { | ||
43 | + | ||
44 | + return dispatch => { | ||
45 | + dispatch(saleStatsRequest(shopId)); | ||
46 | + return new HomeService().saleStats(shopId) | ||
47 | + .then(json => { | ||
48 | + dispatch(saleStatsSuccess({ | ||
49 | + rank: 76, | ||
50 | + rise: true, | ||
51 | + riseCount: 28, | ||
52 | + goodsCount: 7600, | ||
53 | + goodsAmount: 19800.00, | ||
54 | + })); | ||
55 | + }) | ||
56 | + .catch(error => { | ||
57 | + dispatch(saleStatsFailure(error)); | ||
58 | + }); | ||
59 | + }; | ||
60 | + | ||
61 | +} |
1 | +/** | ||
2 | + * # guideInitialState.js | ||
3 | + * | ||
4 | + * | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | +/** | ||
8 | + * ## Import immutable record | ||
9 | + */ | ||
10 | +import {List, Record} from 'immutable'; | ||
11 | + | ||
12 | +/** | ||
13 | + * ## InitialState | ||
14 | + * | ||
15 | + * The fields we're concerned with | ||
16 | + */ | ||
17 | +let InitialState = Record({ | ||
18 | + isFetching: false, | ||
19 | + error: null, | ||
20 | + | ||
21 | + type: 0, | ||
22 | + day: '', | ||
23 | + startDay: '', | ||
24 | + endDay: '', | ||
25 | + month: '', | ||
26 | + | ||
27 | + goodsAmount: 0, | ||
28 | + amountRise: true, | ||
29 | + amountRisePercent: '', | ||
30 | + goodsCount: 0, | ||
31 | + countRise: true, | ||
32 | + countRisePercent: '', | ||
33 | + trendInSevenDays: List(), | ||
34 | +}); | ||
35 | + | ||
36 | +export default InitialState; |
1 | +/** | ||
2 | + * # guideReducer.js | ||
3 | + * | ||
4 | + * The reducer for all the actions from the various log states | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | +/** | ||
8 | + * ## Imports | ||
9 | + * | ||
10 | + * InitialState | ||
11 | + */ | ||
12 | +import InitialState from './saleStatisticsInitialState'; | ||
13 | + | ||
14 | +import Immutable, {List, Record} from 'immutable'; | ||
15 | + | ||
16 | +const { | ||
17 | + | ||
18 | + SALE_STATS_REQUEST, | ||
19 | + SALE_STATS_SUCCESS, | ||
20 | + SALE_STATS_FAILURE, | ||
21 | + | ||
22 | +} = require('../../constants/actionTypes').default; | ||
23 | + | ||
24 | +const initialState = new InitialState; | ||
25 | + | ||
26 | +/** | ||
27 | + * ## guideReducer function | ||
28 | + * @param {Object} state - initialState | ||
29 | + * @param {Object} action - type and payload | ||
30 | + */ | ||
31 | +export default function saleStatisticsReducer(state = initialState, action) { | ||
32 | + if (!(state instanceof InitialState)) return initialState.merge(state); | ||
33 | + | ||
34 | + switch (action.type) { | ||
35 | + | ||
36 | + case SALE_STATS_REQUEST: { | ||
37 | + let nextState = state.set('isFetching', true) | ||
38 | + .set('error', null) | ||
39 | + return nextState; | ||
40 | + } | ||
41 | + | ||
42 | + case SALE_STATS_SUCCESS: { | ||
43 | + let nextState = state.set('isFetching', false) | ||
44 | + .set('error', null) | ||
45 | + .set('goodsAmount', action.payload.goodsAmount) | ||
46 | + .set('amountRise', action.payload.amountRise) | ||
47 | + .set('goodsCount', action.payload.goodsCount) | ||
48 | + .set('countRise', action.payload.countRise) | ||
49 | + .setIn('trendInSevenDays', Immutable.fromJS(action.payload.trendInSevenDays)); | ||
50 | + return nextState; | ||
51 | + } | ||
52 | + | ||
53 | + case SALE_STATS_FAILURE: | ||
54 | + return state.set('isFetching', false) | ||
55 | + .set('error', action.payload); | ||
56 | + | ||
57 | + } | ||
58 | + | ||
59 | + return state; | ||
60 | +} |
@@ -37,6 +37,19 @@ export default class UserService { | @@ -37,6 +37,19 @@ export default class UserService { | ||
37 | }) | 37 | }) |
38 | } | 38 | } |
39 | 39 | ||
40 | + async saleStats() { | ||
41 | + return await this.api.get({ | ||
42 | + url:'/operations/api/v6/category/getCategory' | ||
43 | + }) | ||
44 | + .then((json) => { | ||
45 | + return json; | ||
46 | + }) | ||
47 | + .catch((error) => { | ||
48 | + throw(error); | ||
49 | + }) | ||
50 | + } | ||
51 | +} | ||
52 | + | ||
40 | async stockStatsData() { | 53 | async stockStatsData() { |
41 | return await this.api.get({ | 54 | return await this.api.get({ |
42 | url: '/' | 55 | url: '/' |
-
Please register or login to post a comment