Monitor.jsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React, { Component, useState, useEffect } from 'react';
  2. import { Card, Typography, Alert, Row, Col } from 'antd';
  3. import { FormattedMessage } from 'umi-plugin-react/locale';
  4. import EchartsTest from '../components/EchartsTest';
  5. import IndexEcharts from './indexEcharts/index';
  6. // import Swiper from './swiper/index';
  7. import router from 'umi/router';
  8. import request from '../utils/request';
  9. import apis from '../services/apis';
  10. const Monitor = props => {
  11. const [data, setData] = useState([])
  12. const [checkData, setCheckData] = useState([])
  13. useEffect(() => {
  14. getIndexEcharts()
  15. getBuildingReports()
  16. }, [])
  17. function getIndexEcharts(params) {
  18. request({
  19. ...apis.indexEcharts.list,
  20. params
  21. }).then((data) => {
  22. setData(data)
  23. console.log(data, '11111')
  24. })
  25. }
  26. function getBuildingReports() {
  27. request({ ...apis.system.taBuildingReports, }).then((data) => {
  28. console.log(data,"22222222222222222")
  29. setCheckData((data.records || []).map((x) => x.reportCode))
  30. })
  31. }
  32. return (
  33. <>
  34. <div style={{ display: 'flex', marginBottom: '33px' }}>
  35. {checkData.includes('total_number_of_users') &&
  36. <div style={{
  37. 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',
  38. boxShadow: '0px 0.106rem 14px -15px rgba(241,43,62,1)',
  39. borderRadius: '12px', width: '32%', marginRight: '2%'
  40. }}>
  41. <span style={{ fontSize: '24px', color: '#fff' }}>总用户 </span>
  42. <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectUserCount || '0'}</span>
  43. </div>
  44. }
  45. {checkData.includes('total_number_of_registered_users') &&
  46. <div style={{
  47. 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',
  48. boxShadow: '0px 0.106rem 14px -15px rgba(255,126,74,1)',
  49. borderRadius: '12px', width: '32%', marginRight: '2%'
  50. }}>
  51. <span style={{ fontSize: '24px', color: '#fff' }}>总注册用户 </span>
  52. <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectRegisteredCount || '0'}</span>
  53. </div>
  54. }
  55. {checkData.includes('total_number_of_visit_users') &&
  56. <div style={{
  57. 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',
  58. boxShadow: '0px 0.106rem 14px -15px rgba(255,126,74,1)',
  59. borderRadius: '12px', width: '32%', marginRight: '2%'
  60. }}>
  61. <span style={{ fontSize: '24px', color: '#fff' }}>今日访问次数 </span>
  62. <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy' }}>{data.selectVisitCount || '0'}</span>
  63. </div>
  64. }
  65. {checkData.includes('number_of_new_users') &&
  66. <div onClick={() => router.push('/statistical/newUsers')} style={{
  67. textAlign: 'center', display: 'flex', justifyContent: 'center', background: 'linear-gradient(137deg,rgba(107,130,230,1) 0%,rgba(152,175,251,1) 100%)', height: '100px',
  68. boxShadow: '0px 0.106rem 14px -15px rgba(107,130,230,1)',
  69. borderRadius: '12px', width: '32%',
  70. }}>
  71. <span style={{ fontSize: '24px', color: '#fff', borderBottom: '1px solid #fff', margin: '30px 0', cursor: 'pointer' }}>今日新增用户 </span>
  72. <span style={{ fontSize: '52px', color: '#fff', marginLeft: '26px', fontFamily: 'fantasy', lineHeight: '100px' }}>{data.selectRecentlyCount || '0'}</span>
  73. </div>
  74. }
  75. </div>
  76. {/* <Swiper /> */}
  77. <IndexEcharts style={{ width: '100%' }} onReData={(e) => redata(e)} checkData={checkData}></IndexEcharts>
  78. </>
  79. )
  80. }
  81. export default Monitor