|
@@ -1,20 +1,37 @@
|
|
|
import React from 'react';
|
|
|
-import { Button, PageHeader } from 'antd';
|
|
|
+import { Button, PageHeader, Icon, Row, Col } from 'antd';
|
|
|
import PageTitle from 'component/page-title/index.jsx';
|
|
|
import './index.scss';
|
|
|
-
|
|
|
+import Statistic from 'api/statistic.jsx';
|
|
|
+import MUtil from 'util/mutil.jsx';
|
|
|
+// import axios from 'axios';
|
|
|
+const _statistic = new Statistic();
|
|
|
+const _mutil = new MUtil();
|
|
|
export default class Home extends React.Component {
|
|
|
+ constructor(props) {
|
|
|
+ super(props);
|
|
|
+ this.state = {
|
|
|
+ userCount: '_',
|
|
|
+ productCount: '_',
|
|
|
+ orderCount: '_'
|
|
|
+ };
|
|
|
+ }
|
|
|
+ componentDidMount() {
|
|
|
+ _statistic.getHomeCount().then(
|
|
|
+ res => {
|
|
|
+ this.setState({
|
|
|
+ userCount: res.data.userCount,
|
|
|
+ productCount: res.data.productCount,
|
|
|
+ orderCount: res.data.orderCount
|
|
|
+ });
|
|
|
+ },
|
|
|
+ errMsg => {
|
|
|
+ _mutil.errorTips(errMsg);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
getUser() {
|
|
|
console.log(7);
|
|
|
- fetch('/api/statistic', {
|
|
|
- method: 'GET'
|
|
|
- })
|
|
|
- .then(function(response) {
|
|
|
- return response.json();
|
|
|
- })
|
|
|
- .then(function(myJson) {
|
|
|
- console.log(myJson);
|
|
|
- });
|
|
|
}
|
|
|
render() {
|
|
|
return (
|
|
@@ -24,14 +41,35 @@ export default class Home extends React.Component {
|
|
|
<PageHeader title="首页"/>
|
|
|
*/}
|
|
|
<PageTitle title="首页" />
|
|
|
- <Button
|
|
|
- onClick={e => {
|
|
|
- this.getUser(e);
|
|
|
- }}
|
|
|
- type="primary"
|
|
|
- >
|
|
|
- get
|
|
|
- </Button>
|
|
|
+ <Row gutter={48}>
|
|
|
+ <Col span={8}>
|
|
|
+ <div className="color-box brown">
|
|
|
+ <div className="number">{this.state.userCount}</div>
|
|
|
+ <div className="desc">
|
|
|
+ <Icon type="user" />
|
|
|
+ 用户总数
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ <Col span={8}>
|
|
|
+ <div className="color-box green">
|
|
|
+ <div className="number">{this.state.productCount}</div>
|
|
|
+ <div className="desc">
|
|
|
+ <Icon type="unordered-list" />
|
|
|
+ 商品总数
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ <Col span={8}>
|
|
|
+ <div className="color-box blue">
|
|
|
+ <div className="number">{this.state.orderCount}</div>
|
|
|
+ <div className="desc">
|
|
|
+ <Icon type="appstore" />
|
|
|
+ 订单总数
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
</div>
|
|
|
);
|
|
|
}
|