|
@@ -2,7 +2,7 @@
|
2
|
2
|
<div class="dashboard-container">
|
3
|
3
|
<div class="dashboard-text">欢迎使用{{ name }}</div>
|
4
|
4
|
|
5
|
|
- <el-row type="flex" class="row-bg" justify="space-between">
|
|
5
|
+ <el-row class="sec" type="flex" justify="space-between">
|
6
|
6
|
<el-col :span="6">
|
7
|
7
|
<statistic title="报名总数" :value="total.reg" />
|
8
|
8
|
</el-col>
|
|
@@ -13,34 +13,98 @@
|
13
|
13
|
<statistic title="UV 总数" :value="total.uv" />
|
14
|
14
|
</el-col>
|
15
|
15
|
</el-row>
|
|
16
|
+
|
|
17
|
+ <el-row class="sec" type="flex" justify="space-between" gutter="24">
|
|
18
|
+ <el-col :span="12">
|
|
19
|
+ <el-card>
|
|
20
|
+ <div slot="header">
|
|
21
|
+ <span>PV访问</span>
|
|
22
|
+ </div>
|
|
23
|
+ <line-chart :value="pv" />
|
|
24
|
+ </el-card>
|
|
25
|
+ </el-col>
|
|
26
|
+ <el-col :span="12">
|
|
27
|
+ <el-card>
|
|
28
|
+ <div slot="header">
|
|
29
|
+ <span>UV访问</span>
|
|
30
|
+ </div>
|
|
31
|
+ <line-chart :value="uv" />
|
|
32
|
+ </el-card>
|
|
33
|
+ </el-col>
|
|
34
|
+ </el-row>
|
|
35
|
+
|
16
|
36
|
</div>
|
17
|
37
|
</template>
|
18
|
38
|
|
19
|
39
|
<script>
|
20
|
40
|
import { mapGetters } from 'vuex'
|
21
|
|
-import { getStatTotal } from '@/api/stat'
|
|
41
|
+import { getStatTotal, getStatPV, getStatUV } from '@/api/stat'
|
|
42
|
+
|
|
43
|
+const formateNum = n => n > 9 ? `${n}` : `0${n}`
|
22
|
44
|
|
23
|
45
|
export default {
|
24
|
46
|
name: 'Dashboard',
|
25
|
47
|
components: {
|
26
|
|
- Statistic: () => import('./components/Statistic.vue')
|
|
48
|
+ Statistic: () => import('./components/Statistic.vue'),
|
|
49
|
+ LineChart: () => import('@/components/ECharts/Line.vue'),
|
27
|
50
|
},
|
28
|
51
|
computed: {
|
29
|
|
- ...mapGetters(['name'])
|
|
52
|
+ ...mapGetters(['name']),
|
|
53
|
+ lineParam() {
|
|
54
|
+ // 为了包含今天, 需要少计算1天
|
|
55
|
+ const mills = (this.days - 1) * 24 * 60 * 60 * 1000
|
|
56
|
+ const start = new Date(this.today - mills)
|
|
57
|
+ const year = start.getFullYear()
|
|
58
|
+ const mon = start.getMonth() + 1
|
|
59
|
+ const dt = start.getDate()
|
|
60
|
+
|
|
61
|
+ return {
|
|
62
|
+ startDate: `${year}-${formateNum(mon)}-${formateNum(dt)}`,
|
|
63
|
+ days: this.days,
|
|
64
|
+ }
|
|
65
|
+ }
|
30
|
66
|
},
|
31
|
67
|
data() {
|
32
|
68
|
return {
|
33
|
|
- total: {}
|
|
69
|
+ total: {},
|
|
70
|
+ today: new Date(),
|
|
71
|
+ days: 15, // 默认统计 15 天的
|
|
72
|
+ pv: [],
|
|
73
|
+ uv: [],
|
|
74
|
+ loading: {
|
|
75
|
+ pv: false,
|
|
76
|
+ uv: false,
|
|
77
|
+ }
|
34
|
78
|
}
|
35
|
79
|
},
|
36
|
80
|
mounted() {
|
37
|
81
|
this.statTotal()
|
|
82
|
+ this.statPV()
|
|
83
|
+ this.statUV()
|
38
|
84
|
},
|
39
|
85
|
methods: {
|
40
|
86
|
statTotal() {
|
41
|
87
|
getStatTotal().then(res => {
|
42
|
88
|
this.total = res
|
43
|
89
|
})
|
|
90
|
+ },
|
|
91
|
+ statPV() {
|
|
92
|
+ this.loading.pv = true
|
|
93
|
+ getStatPV(this.lineParam).then(res => {
|
|
94
|
+ this.pv = res
|
|
95
|
+ this.loading.pv = false
|
|
96
|
+ }).catch(() => {
|
|
97
|
+ this.loading.pv = false
|
|
98
|
+ })
|
|
99
|
+ },
|
|
100
|
+ statUV() {
|
|
101
|
+ this.loading.uv = true
|
|
102
|
+ getStatUV(this.lineParam).then(res => {
|
|
103
|
+ this.uv = res
|
|
104
|
+ this.loading.uv = false
|
|
105
|
+ }).catch(() => {
|
|
106
|
+ this.loading.uv = false
|
|
107
|
+ })
|
44
|
108
|
}
|
45
|
109
|
}
|
46
|
110
|
}
|
|
@@ -56,4 +120,8 @@ export default {
|
56
|
120
|
line-height: 46px;
|
57
|
121
|
}
|
58
|
122
|
}
|
|
123
|
+
|
|
124
|
+.sec {
|
|
125
|
+ margin: 24px 0;
|
|
126
|
+}
|
59
|
127
|
</style>
|