Browse Source

Merge branch 'master' of http://git.cc-lotus.info/Free-cysci/cysci-website

guhongwei 4 years ago
parent
commit
c8faa66e08
1 changed files with 45 additions and 45 deletions
  1. 45 45
      src/views/dynamic/parts/thr.vue

+ 45 - 45
src/views/dynamic/parts/thr.vue

@@ -14,6 +14,7 @@
 <script>
 import * as echarts from 'echarts';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: statistics } = createNamespacedHelpers('statistics');
 export default {
   name: 'thr',
   props: {},
@@ -26,55 +27,54 @@ export default {
     this.init();
   },
   methods: {
-    init() {
-      var chartDom = document.getElementById('thrChart');
-      var myChart = echarts.init(chartDom);
-      var option;
-      option = {
-        tooltip: {
-          trigger: 'item',
-        },
-        legend: {
-          top: '5%',
-          left: 'center',
-        },
-        series: [
-          {
-            name: '访问来源',
-            type: 'pie',
-            radius: ['40%', '70%'],
-            avoidLabelOverlap: false,
-            itemStyle: {
-              borderRadius: 10,
-              borderColor: '#fff',
-              borderWidth: 2,
-            },
-            label: {
-              show: false,
-              position: 'center',
-            },
-            emphasis: {
+    ...statistics(['query']),
+    async init() {
+      let res = await this.query({ type: 'users' });
+      if (this.$checkRes(res)) {
+        const { data } = res;
+        var chartDom = document.getElementById('thrChart');
+        var myChart = echarts.init(chartDom);
+        var option;
+        option = {
+          tooltip: {
+            trigger: 'item',
+          },
+          legend: {
+            top: '5%',
+            left: 'center',
+          },
+          series: [
+            {
+              name: '访问来源',
+              type: 'pie',
+              radius: ['40%', '70%'],
+              avoidLabelOverlap: false,
+              itemStyle: {
+                borderRadius: 10,
+                borderColor: '#fff',
+                borderWidth: 2,
+              },
               label: {
-                show: true,
-                fontSize: '40',
-                fontWeight: 'bold',
+                show: false,
+                position: 'center',
               },
+              emphasis: {
+                label: {
+                  show: true,
+                  fontSize: '40',
+                  fontWeight: 'bold',
+                },
+              },
+              labelLine: {
+                show: false,
+              },
+              data: data,
             },
-            labelLine: {
-              show: false,
-            },
-            data: [
-              { value: 1048, name: '搜索引擎' },
-              { value: 735, name: '直接访问' },
-              { value: 580, name: '邮件营销' },
-              { value: 484, name: '联盟广告' },
-              { value: 300, name: '视频广告' },
-            ],
-          },
-        ],
-      };
+          ],
+        };
 
-      option && myChart.setOption(option);
+        option && myChart.setOption(option);
+      }
     },
   },
   computed: {