周立森 5 yıl önce
ebeveyn
işleme
4ffcd489a3
2 değiştirilmiş dosya ile 61 ekleme ve 46 silme
  1. 56
    46
      src/pages/Welcome.jsx
  2. 5
    0
      src/services/apis.js

+ 56
- 46
src/pages/Welcome.jsx Dosyayı Görüntüle

1
-import React from 'react';
1
+import React, { Component, useState, useEffect } from 'react';
2
 import { Card, Typography, Alert, Row, Col } from 'antd';
2
 import { Card, Typography, Alert, Row, Col } from 'antd';
3
 import { FormattedMessage } from 'umi-plugin-react/locale';
3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4
 import EchartsTest from '../components/EchartsTest';
4
 import EchartsTest from '../components/EchartsTest';
5
 import IndexEcharts from './indexEcharts/index';
5
 import IndexEcharts from './indexEcharts/index';
6
 import router from 'umi/router';
6
 import router from 'umi/router';
7
+import request from '../utils/request';
8
+import apis from '../services/apis';
7
 
9
 
8
-const option = {
9
-  xAxis: {
10
-    type: 'category',
11
-    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
12
-  },
13
-  yAxis: {
14
-    type: 'value'
15
-  },
16
-  series: [{
17
-    data: [820, 932, 901, 934, 1290, 1330, 1320],
18
-    type: 'line'
19
-  }]
20
-};
10
+const header = props => {
21
 
11
 
22
-export default () => (
23
-  <>
24
-    <div style={{ display: 'flex',marginBottom:'28px' }}>
25
-      <div style={{
26
-        textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(241,43,62,1) 0%,rgba(254,144,155,1) 100%)', height: '100px',
27
-        boxShadow: '0px  0.11rem 14px -15px rgba(241,43,62,1)',
28
-        borderRadius: '12px', width: '32%', marginRight: '2%'
29
-      }}>
30
-        <span style={{ fontSize: '24px', color: '#fff' }}>总用户 </span>
31
-        <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>133</span>
32
-      </div>
33
-      <div style={{
34
-        textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(255,126,74,1) 0%,rgba(255,196,168,1) 100%)', height: '100px',
35
-        boxShadow: '0px  0.11rem 14px -15px rgba(255,126,74,1)',
36
-        borderRadius: '12px', width: '32%', marginRight: '2%'
37
-      }}>
38
-        <span style={{ fontSize: '24px', color: '#fff' }}>总注册用户 </span>
39
-        <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>12</span>
40
-      </div>
41
-      <div onClick={()=>router.push('/indexEcharts/newUsers')} style={{
42
-        textAlign: 'center', display: 'flex', justifyContent: 'center', background: 'linear-gradient(137deg,rgba(107,130,230,1) 0%,rgba(152,175,251,1) 100%)', height: '100px',
43
-        boxShadow: '0px  0.11rem 14px -15px rgba(107,130,230,1)',
44
-        borderRadius: '12px', width: '32%',
45
-      }}>
46
-        <span style={{ fontSize: '24px', color: '#fff',borderBottom:'1px solid #fff',margin:'30px 0' }}>最近7天新增 </span>
47
-        <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>91</span>
48
-      </div>
49
-    </div>
50
-    <IndexEcharts style={{ width: '100%'}}></IndexEcharts>
12
+ const [data, setData] = useState([])
51
 
13
 
52
-    {/* <EchartsTest style={{ width: 500, height: 500 }}></EchartsTest> */}
14
+useEffect(() => {
15
+  getIndexEcharts()
16
+}, [])
53
 
17
 
54
-  </>
55
-);
18
+function getIndexEcharts (params) {
19
+  request({
20
+    ...apis.indexEcharts.list,
21
+    params
22
+  }).then((data) => {
23
+   setData(data)
24
+    console.log(data, '11111')
25
+  })
26
+}
27
+  
56
 
28
 
29
+  return (
30
+    <>
31
+       <div style={{ display: 'flex',marginBottom:'28px' }}>
32
+           <div style={{
33
+            textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(241,43,62,1) 0%,rgba(254,144,155,1) 100%)', height: '100px',
34
+            boxShadow: '0px  0.11rem 14px -15px rgba(241,43,62,1)',
35
+            borderRadius: '12px', width: '32%', marginRight: '2%'
36
+          }}>
37
+            <span style={{ fontSize: '24px', color: '#fff' }}>总用户 </span>
38
+            <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectUserCount}</span>
39
+          </div>
40
+          <div style={{
41
+            textAlign: 'center', display: 'flex', justifyContent: 'center', lineHeight: '100px', background: 'linear-gradient(144deg,rgba(255,126,74,1) 0%,rgba(255,196,168,1) 100%)', height: '100px',
42
+            boxShadow: '0px  0.11rem 14px -15px rgba(255,126,74,1)',
43
+            borderRadius: '12px', width: '32%', marginRight: '2%'
44
+          }}>
45
+            <span style={{ fontSize: '24px', color: '#fff' }}>总注册用户 </span>
46
+            <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectRegisteredCount}</span>
47
+          </div>
48
+          <div onClick={()=>router.push('/indexEcharts/newUsers')} style={{
49
+            textAlign: 'center', display: 'flex', justifyContent: 'center', background: 'linear-gradient(137deg,rgba(107,130,230,1) 0%,rgba(152,175,251,1) 100%)', height: '100px',
50
+            boxShadow: '0px  0.11rem 14px -15px rgba(107,130,230,1)',
51
+            borderRadius: '12px', width: '32%',
52
+          }}>
53
+            <span style={{ fontSize: '24px', color: '#fff',borderBottom:'1px solid #fff',margin:'30px 0' }}>最近7天新增 </span>
54
+            <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>{data.selectRecentlyCount}</span>
55
+          </div>
56
+        </div>
57
+        <IndexEcharts style={{ width: '100%'}} onReData={(e) => redata(e)} ></IndexEcharts>
58
+    
59
+        {/* <EchartsTest style={{ width: 500, height: 500 }}></EchartsTest> */}
60
+    
61
+      </>
62
+  )
63
+
64
+}
65
+
66
+export default  header

+ 5
- 0
src/services/apis.js Dosyayı Görüntüle

263
     },
263
     },
264
   },
264
   },
265
   indexEcharts: {
265
   indexEcharts: {
266
+    list:{
267
+      method:'GET',
268
+      url: `${prefix}/indexStatistical`,
269
+      action: 'userStatistics',
270
+    },
266
     userResource: {
271
     userResource: {
267
       method: 'GET',
272
       method: 'GET',
268
       url: `${prefix}/selectUserResource`,
273
       url: `${prefix}/selectUserResource`,