|
@@ -2,9 +2,8 @@ import { useState, useEffect } from 'react'
|
2
|
2
|
import withLayout from '@/layout'
|
3
|
3
|
import '@/assets/css/iconfont.css'
|
4
|
4
|
import { ScrollView } from '@tarojs/components'
|
5
|
|
-import { useSelector } from 'react-redux'
|
6
|
5
|
import { fetch } from '@/utils/request'
|
7
|
|
-import { API_SEX_INFO, API_ECHERTS_DAILY } from '@/constants/api'
|
|
6
|
+import { API_SEX_INFO, API_ECHERTS_DAILY, API_ECHERTS_MONTH } from '@/constants/api'
|
8
|
7
|
import LineChart from './components/LineChart'
|
9
|
8
|
// import dayjs from 'dayjs'
|
10
|
9
|
import './index.scss'
|
|
@@ -33,13 +32,15 @@ export default withLayout((props) => {
|
33
|
32
|
const [source, setSource] = useState([])
|
34
|
33
|
|
35
|
34
|
useEffect(() => {
|
36
|
|
- setChartList([])
|
37
|
|
- GetSexInfo()
|
38
|
|
- GetChartInfo()
|
39
|
|
- }, [CurrentMenuId])
|
|
35
|
+ if (CurrentChartMenuId && CurrentMenuId) {
|
|
36
|
+ setChartList([])
|
|
37
|
+ GetSexInfo()
|
|
38
|
+ GetChartInfo()
|
|
39
|
+ }
|
|
40
|
+ }, [CurrentChartMenuId, CurrentMenuId])
|
40
|
41
|
|
41
|
42
|
useEffect(() => {
|
42
|
|
- if(!ChartList.length) {
|
|
43
|
+ if (!ChartList.length) {
|
43
|
44
|
GetChartInfo()
|
44
|
45
|
} else {
|
45
|
46
|
// const chart = echarts.init(canvas, null, { width: '100%', height: '100%' })
|
|
@@ -61,7 +62,7 @@ export default withLayout((props) => {
|
61
|
62
|
}
|
62
|
63
|
|
63
|
64
|
const GetChartInfo = () => {
|
64
|
|
- fetch({ url: `${API_ECHERTS_DAILY}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`, method: 'get' }).then((res) => {
|
|
65
|
+ fetch({ url: `${CurrentChartMenuId === 1 ? API_ECHERTS_DAILY : API_ECHERTS_MONTH}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`, method: 'get' }).then((res) => {
|
65
|
66
|
const Arr = (res || []).reverse()
|
66
|
67
|
setChartList(Arr.map(x => ({ name: x.day, value: x.customerNum })))
|
67
|
68
|
setSource(Arr)
|