|
@@ -8,6 +8,8 @@ import LineChart from './components/LineChart'
|
8
|
8
|
// import dayjs from 'dayjs'
|
9
|
9
|
import './index.scss'
|
10
|
10
|
|
|
11
|
+const round100 = x => Number(x * 100).toFixed(2);
|
|
12
|
+
|
11
|
13
|
export default withLayout((props) => {
|
12
|
14
|
const { person } = props
|
13
|
15
|
const PersonId = person.personId
|
|
@@ -25,7 +27,6 @@ export default withLayout((props) => {
|
25
|
27
|
])
|
26
|
28
|
const [CurrentChartMenuId, setCurrentChartMenuId] = useState(1)
|
27
|
29
|
|
28
|
|
- const [ChartList, setChartList] = useState([])
|
29
|
30
|
const [SexList, setSexList] = useState([])
|
30
|
31
|
|
31
|
32
|
const [dimensions, setDimensions] = useState(['day', 'customerNum'])
|
|
@@ -33,21 +34,11 @@ export default withLayout((props) => {
|
33
|
34
|
|
34
|
35
|
useEffect(() => {
|
35
|
36
|
if (CurrentChartMenuId && CurrentMenuId) {
|
36
|
|
- setChartList([])
|
37
|
37
|
GetSexInfo()
|
38
|
38
|
GetChartInfo()
|
39
|
39
|
}
|
40
|
40
|
}, [CurrentChartMenuId, CurrentMenuId])
|
41
|
41
|
|
42
|
|
- useEffect(() => {
|
43
|
|
- if (!ChartList.length) {
|
44
|
|
- GetChartInfo()
|
45
|
|
- } else {
|
46
|
|
- // const chart = echarts.init(canvas, null, { width: '100%', height: '100%' })
|
47
|
|
- // canvas.setChart(chart)
|
48
|
|
- }
|
49
|
|
- }, [ChartList])
|
50
|
|
-
|
51
|
42
|
const GetSexInfo = () => {
|
52
|
43
|
fetch({ url: `${API_SEX_INFO}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`, method: 'get' }).then((res) => {
|
53
|
44
|
const SexRes = (res || []).map((item) => {
|
|
@@ -62,9 +53,9 @@ export default withLayout((props) => {
|
62
|
53
|
}
|
63
|
54
|
|
64
|
55
|
const GetChartInfo = () => {
|
65
|
|
- fetch({ url: `${CurrentChartMenuId === 1 ? API_ECHERTS_DAILY : API_ECHERTS_MONTH}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`, method: 'get' }).then((res) => {
|
|
56
|
+ const url = `${CurrentChartMenuId === 1 ? API_ECHERTS_DAILY : API_ECHERTS_MONTH}/${CurrentMenuId === 1 ? 'new' : CurrentMenuId === 2 ? 'follow' : 'visite'}`
|
|
57
|
+ fetch({ url, method: 'get' }).then((res) => {
|
66
|
58
|
const Arr = (res || []).reverse()
|
67
|
|
- setChartList(Arr.map(x => ({ name: x.day, value: x.customerNum })))
|
68
|
59
|
setSource(Arr)
|
69
|
60
|
})
|
70
|
61
|
}
|
|
@@ -78,85 +69,14 @@ export default withLayout((props) => {
|
78
|
69
|
const CutChartMenu = (item) => {
|
79
|
70
|
return () => {
|
80
|
71
|
setCurrentChartMenuId(item.id)
|
|
72
|
+ if (item.id === 1) {
|
|
73
|
+ setDimensions(['day', 'customerNum'])
|
|
74
|
+ } else {
|
|
75
|
+ setDimensions(['month', 'customerNum'])
|
|
76
|
+ }
|
81
|
77
|
}
|
82
|
78
|
}
|
83
|
79
|
|
84
|
|
- // const createLineOptions = (source = []) => {
|
85
|
|
- // const colorWithOpacity = op => `rgba(187,156,121, ${op})`
|
86
|
|
-
|
87
|
|
- // const defaultOpt = {
|
88
|
|
- // color: [colorWithOpacity(1)],
|
89
|
|
- // xAxis: {
|
90
|
|
- // type: 'category',
|
91
|
|
- // boundaryGap: false,
|
92
|
|
- // axisLabel: {
|
93
|
|
- // textStyle: {
|
94
|
|
- // color: '#666'
|
95
|
|
- // }
|
96
|
|
- // }
|
97
|
|
-
|
98
|
|
- // },
|
99
|
|
- // yAxis: {
|
100
|
|
- // type: 'value',
|
101
|
|
- // axisLabel: {
|
102
|
|
- // textStyle: {
|
103
|
|
- // color: '#666'
|
104
|
|
- // }
|
105
|
|
- // }
|
106
|
|
- // },
|
107
|
|
- // grid: {
|
108
|
|
- // left: '10%',
|
109
|
|
- // right: '8%',
|
110
|
|
- // bottom: '12%',
|
111
|
|
- // top: '15%',
|
112
|
|
- // },
|
113
|
|
- // series: [],
|
114
|
|
- // }
|
115
|
|
- // // 数据展示只展示 5 个
|
116
|
|
- // const endValue = source.length - 1 > 0 ? source.length - 1 : 0
|
117
|
|
- // const startValue = endValue - 5 > 0 ? endValue - 5 : 0
|
118
|
|
-
|
119
|
|
- // return {
|
120
|
|
- // ...defaultOpt,
|
121
|
|
- // dataset: { source },
|
122
|
|
- // dataZoom: [{
|
123
|
|
- // type: 'inside',
|
124
|
|
- // startValue, endValue,
|
125
|
|
- // show: true,
|
126
|
|
- // }],
|
127
|
|
- // series: [{
|
128
|
|
- // type: 'line',
|
129
|
|
- // dimensions: ['name', 'value'],
|
130
|
|
- // symbolSize: 6,
|
131
|
|
- // smooth: true,
|
132
|
|
- // label: {
|
133
|
|
- // show: true,
|
134
|
|
- // formatter: '{@value}人'
|
135
|
|
- // },
|
136
|
|
- // lineStyle: {
|
137
|
|
- // shadowColor: colorWithOpacity(0.5),
|
138
|
|
- // shadowBlur: 5,
|
139
|
|
- // shadowOffsetY: 7
|
140
|
|
- // },
|
141
|
|
- // areaStyle: {
|
142
|
|
- // color: {
|
143
|
|
- // type: 'linear',
|
144
|
|
- // x: 0,
|
145
|
|
- // y: 0,
|
146
|
|
- // x2: 0,
|
147
|
|
- // y2: 1,
|
148
|
|
- // colorStops: [{
|
149
|
|
- // offset: 0, color: colorWithOpacity(0.2) // 0% 处的颜色
|
150
|
|
- // }, {
|
151
|
|
- // offset: 1, color: colorWithOpacity(0) // 100% 处的颜色
|
152
|
|
- // }],
|
153
|
|
- // global: false,
|
154
|
|
- // }
|
155
|
|
- // },
|
156
|
|
- // }],
|
157
|
|
- // }
|
158
|
|
- // }
|
159
|
|
-
|
160
|
80
|
return (
|
161
|
81
|
<view className='Page customerAnalyse flex-v'>
|
162
|
82
|
|
|
@@ -197,9 +117,9 @@ export default withLayout((props) => {
|
197
|
117
|
<view className='flex-h' key={`SexItem-${index}`}>
|
198
|
118
|
<text>{item.name}</text>
|
199
|
119
|
<view className='flex-item'>
|
200
|
|
- <view style={{ width: `${Math.floor(item.per * 100)}%` }}></view>
|
|
120
|
+ <view style={{ width: `${round100(item.per)}%` }}></view>
|
201
|
121
|
</view>
|
202
|
|
- <text>{Math.floor(item.per * 100)}%</text>
|
|
122
|
+ <text>{round100(item.per)}%</text>
|
203
|
123
|
</view>
|
204
|
124
|
))
|
205
|
125
|
}
|