Browse Source

定时器60秒

zhengkaixin 1 year ago
parent
commit
cbcc2342d2
1 changed files with 20 additions and 10 deletions
  1. 20 10
      pages/mine/electronicMonitoring.vue

+ 20 - 10
pages/mine/electronicMonitoring.vue

@@ -298,8 +298,9 @@
 				  this.intervalId = setInterval(() => {  
 				         // 每隔5秒运行的代码  
 				         console.log('这段代码每隔5秒运行一次'); 
+						 this.getTimeSlotStatistics(true)
 						  this.getElectricityStatistics(true)
-				 }, 5000);  
+				 }, 60*1000);  
 			},
 			titleCk(){
 				if(this.electricityMeterList.length>1){
@@ -404,18 +405,24 @@
 					})
 				})
 			},
-			getTimeSlotStatistics(){
-				uni.showLoading({
-					title: "加载中",
-					mask: true,
-				})
+			getTimeSlotStatistics(interval){
+				
+				if(!interval){
+					uni.showLoading({
+						title: "加载中",
+						mask: true,
+					})
+				}
 				this.queryDay=parseUnixTime(new Date(this.FormData2.queryDate), '{y}年{m}月{d}日');
 							
 				API.timeSlotStatistics(this.FormData2).then((response) => {
-					uni.hideLoading();
+					
+					if(!interval){
+						uni.hideLoading();
+					}
 					this.hourMap=response.data.hourMap
 					this.sumQuantity=response.data.allKwh
-					this.getPle(this.hourMap)
+					this.getPle(this.hourMap,interval)
 				}).catch(error => {
 					uni.showToast({
 						title: error,
@@ -423,14 +430,17 @@
 					})
 				})
 			},
-			getPle(list){
+			getPle(list,interval){
 				 
 				if (!this.myChart) {
 					this.myChart = echarts.init(document.getElementById('pieEcharts'),null,{
 						width:uni.upx2px(700),height:uni.upx2px(480)
 					});
 				}
-				this.myChart.clear();
+				if(!interval){
+					this.myChart.clear();
+				}
+				
 				var data1=[];
 				var data2=[];
 				var sumQuantity=0