|
@@ -9,64 +9,58 @@ import { Table, Select, Row, Col, Menu, Dropdown, Button, Icon, message } from '
|
9
|
9
|
|
10
|
10
|
import styles from '../styles.less'
|
11
|
11
|
|
12
|
|
-const UserSource = (props) => {
|
13
|
12
|
|
14
|
|
- const [data, setData] = useState({ records: [] })
|
15
|
|
- const [theStatis, settheStatis] = useState({ records: [] })
|
16
|
|
- const [Current, setTheCurrent] = useState({ records: [] })
|
|
13
|
+const UserSource = props => {
|
17
|
14
|
|
|
15
|
+ const [theCurrent, setTheCurrent] = useState({ records: [] })
|
18
|
16
|
|
19
|
17
|
useEffect(() => {
|
20
|
18
|
UserConversionRate({ conversion: 'authorization_phone' })
|
21
|
19
|
}, [])
|
22
|
20
|
|
23
|
|
- function UserConversionRate(params) {
|
24
|
|
- request({
|
25
|
|
- ...apis.indexEcharts.userConversion,
|
26
|
|
- params,
|
27
|
|
- }).then((data) => {
|
28
|
|
- console.log(data, "data")
|
29
|
|
- setData(data)
|
30
|
|
- })
|
|
21
|
+ function UserConversionRate(params) {
|
|
22
|
+ request({
|
|
23
|
+ ...apis.indexEcharts.userConversion,
|
|
24
|
+ params,
|
|
25
|
+ }).then(data => {
|
|
26
|
+ // console.log("data: ", data)
|
|
27
|
+ setDataset(data, params.conversion)
|
|
28
|
+ })
|
31
|
29
|
}
|
32
|
30
|
|
33
|
|
- function setDataset(data) {
|
34
|
|
-
|
35
|
|
- const { pvNum, ...other } = data['data_count']
|
|
31
|
+ function setDataset(data, theStatis) {
|
|
32
|
+ const { pvNum, ...other } = data.data_count
|
36
|
33
|
|
37
|
34
|
// 获取第一个值
|
38
|
35
|
let num = 0
|
39
|
|
- for (let v of Object.keys(other)) {
|
|
36
|
+ for (const v of Object.keys(other)) {
|
40
|
37
|
num = other[v]
|
41
|
38
|
break
|
42
|
39
|
}
|
43
|
40
|
|
44
|
41
|
if (pvNum < num) {
|
45
|
|
- Current = []
|
|
42
|
+ setTheCurrent([])
|
46
|
43
|
} else {
|
47
|
|
- Current = [
|
48
|
|
- { name: getStatisName(), value: num },
|
|
44
|
+ setTheCurrent([
|
|
45
|
+ { name: getStatisName(theStatis), value: num },
|
49
|
46
|
{ name: '其余', value: pvNum - num },
|
50
|
|
- ]
|
|
47
|
+ ])
|
51
|
48
|
}
|
52
|
|
- console.log(Current, "Current")
|
53
|
|
-
|
54
|
|
- // this.dataset[theStatis] = theCurrent
|
55
|
|
-
|
56
|
49
|
}
|
57
|
|
- function getStatisName() {
|
58
|
|
- const statisTypes = [
|
59
|
|
- { label: '授权手机', value: 'authorization_phone' },
|
60
|
|
- { label: '项目收藏', value: 'building_save' },
|
61
|
|
- { label: '项目转发', value: 'building_share' },
|
62
|
|
- { label: '活动收藏', value: 'activity_save' },
|
63
|
|
- { label: '活动转发', value: 'activity_share' },
|
64
|
|
- { label: '资讯收藏', value: 'news_save' },
|
65
|
|
- { label: '资讯转发', value: 'news_share' },
|
66
|
|
- { label: '活动报名', value: 'activity_sign' },
|
67
|
|
-
|
68
|
|
- ]
|
69
|
|
- return statisTypes.filter(x => x.value == theStatis)[0].label
|
|
50
|
+
|
|
51
|
+ function getStatisName(theStatis) {
|
|
52
|
+ const statisTypes = [
|
|
53
|
+ { label: '授权手机', value: 'authorization_phone' },
|
|
54
|
+ { label: '项目收藏', value: 'building_save' },
|
|
55
|
+ { label: '项目转发', value: 'building_share' },
|
|
56
|
+ { label: '活动收藏', value: 'activity_save' },
|
|
57
|
+ { label: '活动转发', value: 'activity_share' },
|
|
58
|
+ { label: '资讯收藏', value: 'news_save' },
|
|
59
|
+ { label: '资讯转发', value: 'news_share' },
|
|
60
|
+ { label: '活动报名', value: 'activity_sign' },
|
|
61
|
+
|
|
62
|
+ ]
|
|
63
|
+ return statisTypes.filter(x => x.value === theStatis)[0].label
|
70
|
64
|
}
|
71
|
65
|
|
72
|
66
|
const options = {
|
|
@@ -77,17 +71,14 @@ const UserSource = (props) => {
|
77
|
71
|
type: 'pie',
|
78
|
72
|
name: '转化率',
|
79
|
73
|
radius: ['34%', '52%'],
|
80
|
|
- data: Current,
|
81
|
|
-
|
82
|
|
- }
|
|
74
|
+ data: theCurrent,
|
|
75
|
+ // data:[ { name: '授权手机', value: 6 },
|
|
76
|
+ // { name: '其余', value: 5 },]
|
|
77
|
+ },
|
83
|
78
|
}
|
84
|
79
|
|
85
|
80
|
function onChange(e) {
|
86
|
|
- settheStatis(e)
|
87
|
|
- UserConversionRate({ conversion: e }).then(res => {
|
88
|
|
- console.log(data, "this")
|
89
|
|
- setDataset(res)
|
90
|
|
- })
|
|
81
|
+ UserConversionRate({ conversion: e })
|
91
|
82
|
}
|
92
|
83
|
const piestyles = {
|
93
|
84
|
width: '100%',
|
|
@@ -97,7 +88,7 @@ const UserSource = (props) => {
|
97
|
88
|
return (
|
98
|
89
|
<>
|
99
|
90
|
<div>
|
100
|
|
- <p style={{ fontSize: '0.12rem', fontWeight: '600' }}>转化率</p>
|
|
91
|
+ <p style={{ fontSize: '0.12rem', fontWeight: '600' }}>转化率</p>
|
101
|
92
|
|
102
|
93
|
<Select
|
103
|
94
|
style={{ width: 200 }}
|
|
@@ -121,6 +112,6 @@ const UserSource = (props) => {
|
121
|
112
|
|
122
|
113
|
</>
|
123
|
114
|
)
|
124
|
|
-}
|
|
115
|
+ }
|
125
|
116
|
|
126
|
|
-export default UserSource;
|
|
117
|
+export default UserSource
|