HomeContainer.js
3.76 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
'use strict';
import React from 'react-native';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Map} from 'immutable';
import Home from '../components/Home';
import * as homeActions from '../reducers/home/homeActions';
import CONFIG from '../constants/config';
let {
Component,
ScrollView,
View,
StyleSheet,
Dimensions
} = React;
/**
* ## Actions
* 3 of our actions will be available as ```actions```
*/
const actions = [
homeActions
];
/**
* Save that state
*/
function mapStateToProps(state) {
return {
...state
};
};
/**
* Bind all the functions from the ```actions``` and bind them with
* ```dispatch```
*/
function mapDispatchToProps(dispatch) {
const creators = Map()
.merge(...actions)
.filter(value => typeof value === 'function')
.toObject();
return {
actions: bindActionCreators(creators, dispatch),
dispatch
};
}
class HomeContainer extends Component {
constructor(props) {
super(props);
this._onPressCategory = this._onPressCategory.bind(this);
this.category = [
{
type: CONFIG.statsKey.saleStats,
thumb: require('../images/xiaoshou.png'),
title: '销售统计',
},
{
type: CONFIG.statsKey.returnStats,
thumb: require('../images/tuihuo.png'),
title: '退货统计',
},
{
type: CONFIG.statsKey.stockStats,
thumb: require('../images/kucun.png'),
title: '库存统计',
},
{
type: CONFIG.statsKey.deliveryStats,
thumb: require('../images/fahuo.png'),
title: '发货统计',
},
{
type: CONFIG.statsKey.requestStats,
thumb: require('../images/qingtui.png'),
title: '请退统计',
},
{
type: CONFIG.statsKey.accountSettlement,
thumb: require('../images/duizhang.png'),
title: '对账结算',
},
];
}
componentDidMount() {
console.log('shopId'+ this.props.home.shopId);
this.props.actions.overview(this.props.home.shopId);
}
_onPressCategory(id) {
let item = this.category[id];
this.props.actions.goToStatsPage(item.type);
}
render() {
let section1 = [
{
top: '同品类中品牌排名',
bottom: `${this.props.home.overview.rank}`,
},
{
top: '较上周同期',
arrowUp: this.props.home.overview.rise,
bottom: `${this.props.home.overview.riseCount}`,
small: '个名次',
}
];
let section2 = [
{
top: '今日有效订单的\n商品件数',
bottom: `${this.props.home.overview.goodsCount}`,
},
{
top: '今日有效订单的\n商品金额(元)',
bottom: `${this.props.home.overview.goodsCount}`,
}
];
return (
<View style={styles.container}>
<Home
section1={section1}
section2={section2}
section3={this.category}
onPressCategory={this._onPressCategory}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let styles = StyleSheet.create({
container: {
top: 64,
height: height - 64 - 49,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(HomeContainer);