Bläddra i källkod

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

guhongwei 4 år sedan
förälder
incheckning
c8faa66e08
1 ändrade filer med 45 tillägg och 45 borttagningar
  1. 45 45
      src/views/dynamic/parts/thr.vue

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

@@ -14,6 +14,7 @@
 <script>
 <script>
 import * as echarts from 'echarts';
 import * as echarts from 'echarts';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: statistics } = createNamespacedHelpers('statistics');
 export default {
 export default {
   name: 'thr',
   name: 'thr',
   props: {},
   props: {},
@@ -26,55 +27,54 @@ export default {
     this.init();
     this.init();
   },
   },
   methods: {
   methods: {
-    init() {
+    ...statistics(['query']),
-      var chartDom = document.getElementById('thrChart');
+    async init() {
-      var myChart = echarts.init(chartDom);
+      let res = await this.query({ type: 'users' });
-      var option;
+      if (this.$checkRes(res)) {
-      option = {
+        const { data } = res;
-        tooltip: {
+        var chartDom = document.getElementById('thrChart');
-          trigger: 'item',
+        var myChart = echarts.init(chartDom);
-        },
+        var option;
-        legend: {
+        option = {
-          top: '5%',
+          tooltip: {
-          left: 'center',
+            trigger: 'item',
-        },
+          },
-        series: [
+          legend: {
-          {
+            top: '5%',
-            name: '访问来源',
+            left: 'center',
-            type: 'pie',
+          },
-            radius: ['40%', '70%'],
+          series: [
-            avoidLabelOverlap: false,
+            {
-            itemStyle: {
+              name: '访问来源',
-              borderRadius: 10,
+              type: 'pie',
-              borderColor: '#fff',
+              radius: ['40%', '70%'],
-              borderWidth: 2,
+              avoidLabelOverlap: false,
-            },
+              itemStyle: {
-            label: {
+                borderRadius: 10,
-              show: false,
+                borderColor: '#fff',
-              position: 'center',
+                borderWidth: 2,
-            },
+              },
-            emphasis: {
               label: {
               label: {
-                show: true,
+                show: false,
-                fontSize: '40',
+                position: 'center',
-                fontWeight: 'bold',
               },
               },
+              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: {
   computed: {