知与行后台管理端

NewUsers.jsx 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import React, { Component, useState, useEffect } from 'react';
  2. import echarts from 'echarts/lib/echarts';
  3. import EChart from '../../../components/EchartsTest/EChart';
  4. import request from '../../../utils/request';
  5. import apis from '../../../services/apis';
  6. import moment from 'moment';
  7. import router from 'umi/router';
  8. import { Table, Select, Row, Col, Menu, Dropdown, Button, Icon, message } from 'antd';
  9. // import UserSource from './mmm';
  10. import styles from '../styles.less'
  11. const formatDate = (start, end) => {
  12. const startDate = moment(start).format('YYYY-MM-DDT00:00:00.000') + 'Z'
  13. const endDate = moment(end).format('YYYY-MM-DDT23:59:59.999') + 'Z'
  14. return { startDate, endDate }
  15. }
  16. const NewUsers = (props) => {
  17. // console.log(props,'999999999999')
  18. const [data, setData] = useState({ records: [] })
  19. useEffect(() => {
  20. NewsUserCount(formatDate(props.startDate, props.endDate))
  21. }, [props.startDate, props.endDate])
  22. // getNewsUserCount ({ commit }, payload) {
  23. // return new Promise((resolve, reject) => {
  24. // request({
  25. // ...apis.indexEcharts.newUser,
  26. // params: payload,
  27. // }).then((data) => {
  28. // resolve(data.selectNewsUserCount)
  29. // }).catch((err) => {
  30. // const message = err.message || err.msg
  31. // if (typeof message === 'string') {
  32. // reject(message)
  33. // }
  34. // })
  35. // })
  36. // },
  37. function NewsUserCount (params) {
  38. request({
  39. ...apis.indexEcharts.newUser,
  40. params,
  41. }).then((data) => {
  42. console.log(data, '3333')
  43. setData(data)
  44. })
  45. }
  46. const dataZoom=props.dataZoom?[
  47. {
  48. type: 'inside',
  49. start: 0,
  50. end: 100
  51. },
  52. {
  53. type: 'slider',
  54. start: 0,
  55. end: 100
  56. },
  57. ] : undefined
  58. // // show: false
  59. const dataset = (data.selectNewsUserCount) || []
  60. const options = {
  61. color: ["#FF814C", "#F02B3E"],
  62. tooltip: {
  63. trigger: "axis"
  64. },
  65. icon: "rect",
  66. legend: {
  67. data: ["新用户数", "授权注册"]
  68. },
  69. toolbox: {},
  70. xAxis: {
  71. type: "category",
  72. },
  73. yAxis: {},
  74. dataZoom,
  75. series: [
  76. {
  77. name: "新用户数",
  78. type: "line",
  79. },
  80. {
  81. name: "授权注册",
  82. type: "line",
  83. }
  84. ],
  85. dataset: {
  86. dimensions: ['date', 'userCount', 'authorizationCount'],
  87. source: dataset
  88. }
  89. }
  90. // function onChange (value) {
  91. // UserActive({ dateType: value })
  92. // }
  93. const piestyles = {
  94. width: '100%',
  95. height: '400px',
  96. }
  97. return (
  98. <>
  99. <div>
  100. <div >
  101. <h3>新增用户</h3>
  102. {/* <Select
  103. showSearch
  104. style={{ width: 100 }}
  105. placeholder="日活跃"
  106. optionFilterProp="children"
  107. onChange={onChange}
  108. >
  109. <Option value="day">日活跃</Option>
  110. <Option value="month">月活跃</Option>
  111. </Select>
  112. */}
  113. </div>
  114. <EChart options={options} style={piestyles} />
  115. </div>
  116. </>
  117. )
  118. }
  119. export default NewUsers;