From fc74998431982dc1385d2930adcf339cbf15ffd6 Mon Sep 17 00:00:00 2001
From: whyczyk <525500596@qq.com>
Date: 星期一, 22 三月 2021 13:40:47 +0800
Subject: [PATCH] 模块定时请求提交

---
 src/components/charts/abeamProChart.vue |   56 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/src/components/charts/abeamProChart.vue b/src/components/charts/abeamProChart.vue
index d578a5d..c0b8592 100644
--- a/src/components/charts/abeamProChart.vue
+++ b/src/components/charts/abeamProChart.vue
@@ -43,7 +43,7 @@
         let dataColor = posData.color;
         let bgColor = posData.bgColor;
         let yData = posData.yData;
-        let radius = (this.$refs.chart.clientHeight / 3 - 7) > 0 ? this.$refs.chart.clientHeight / 3 - 7 : 0;
+        let radius = (this.$refs.chart.clientHeight / 4 - 7) > 0 ? this.$refs.chart.clientHeight / 4 - 7 : 0;
         let data = posData.data;
         let max = posData[0];
         data.map(item => {
@@ -173,30 +173,36 @@
           this.$options.chartData = sendData;
           this.organizeData(sendData)
         } else {
-          let userId = localStorage.getItem('userId');
-          let params = {
-            userId: userId
-          }
-          batteryStatus(params).then((res) => {
-            if (res.data.code == 1) {
-              let optionData = {
-                yData: [],
-                color: ['#f58881', '#b4d465', '#ffcb29'],
-                bgColor: ['rgba(245,136,129,0.35)', 'rgba(255,255,255,0.35)', 'rgba(255,203,41,0.35)'],
-                data: []
-              }
-              let resData = res.data.data;
-              for (let key in resData) {
-                optionData.yData.push(key);
-                optionData.data.push(resData[key]);
-              }
-              this.$options.chartData = optionData;
-              this.organizeData(optionData)
-            }
-          }).catch((err) => {
-            console.log(err)
-          });
+          this.postData()
+          setInterval(() => {
+            this.postData()
+          }, 3000)
         }
+      },
+      postData() {
+        let userId = localStorage.getItem('userId');
+        let params = {
+          userId: userId
+        }
+        batteryStatus(params).then((res) => {
+          if (res.data.code == 1) {
+            let optionData = {
+              yData: [],
+              color: ['#f58881', '#b4d465', '#ffcb29'],
+              bgColor: ['rgba(245,136,129,0.35)', 'rgba(255,255,255,0.35)', 'rgba(255,203,41,0.35)'],
+              data: []
+            }
+            let resData = res.data.data;
+            for (let key in resData) {
+              optionData.yData.push(key);
+              optionData.data.push(resData[key]);
+            }
+            this.$options.chartData = optionData;
+            this.organizeData(optionData)
+          }
+        }).catch((err) => {
+          console.log(err)
+        });
       },
       resize() {
         setTimeout(() => {
@@ -230,6 +236,6 @@
 
   .flexCon .con {
     width: 100%;
-    height: 70%;
+    height: 80%;
   }
 </style>
\ No newline at end of file

--
Gitblit v1.9.1