Sfoglia il codice sorgente

获取所有机器开关机状态

李天标 5 anni fa
parent
commit
17a83263c0
2 ha cambiato i file con 40 aggiunte e 13 eliminazioni
  1. 27 0
      pages/Charts/mainStatistics.vue
  2. 13 13
      pages/User/equipmentStatusList.vue

+ 27 - 0
pages/Charts/mainStatistics.vue

@@ -236,6 +236,14 @@
 				index: 0,
 				text: this.$t('tabs.tab1')
 			});
+			var token = uni.getStorageSync("token");
+			if (token.toString().length > 1) {
+				this.init();
+			}else{
+				uni.reLaunch({
+					url: '../Login/Login',
+				});
+			}
 			// console.log("onShow");
 			var test = uni.getStorageSync('test');
 			var globalUser = uni.getStorageSync("globalUser");
@@ -248,6 +256,7 @@
 			var id = this.adminId;
 
 			this.day();
+			this.equipmentStatus();
 		},
 		mounted() {
 			var token = uni.getStorageSync("token");
@@ -259,6 +268,7 @@
 				});
 			}
 			this.day();
+			
 		},
 		methods: {
 			...mapActions('chart', ['getStatistics', 'getMainStatistics', 'getMachineNum']),
@@ -291,6 +301,23 @@
 				this.week = this.$t('mainStatistics.week' + date.getDay());
 				
 			},
+			equipmentStatus(){
+				var id = uni.getStorageSync("globalUser").id;
+				var token = uni.getStorageSync("token");
+				uni.request({
+					url: this.serverurl + '/TEquipment/equipmentStatus',
+					data: {
+						"adminId": id
+					},
+					header:{
+						'token':token
+					},
+					method: "POST",
+					success: (res) => {
+				
+					},
+				});
+			},
 			initDateRang(day, chartType) {
 				const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
 				if (chartType === 'day') {

+ 13 - 13
pages/User/equipmentStatusList.vue

@@ -241,20 +241,20 @@
 			},
 			OnOff(id, code) {
 				var that = this;
-				var token = uni.getStorageSync("token");
-				uni.request({
-					url: that.serverurl + '/TEquipment/onoffStatus',
-					data: {
-						"equipmentId": id
-					},
-					header:{
-						'token':token
-					},
-					method: "POST",
-					success: (res) => {
+				// var token = uni.getStorageSync("token");
+				// uni.request({
+				// 	url: that.serverurl + '/TEquipment/onoffStatus',
+				// 	data: {
+				// 		"equipmentId": id
+				// 	},
+				// 	header:{
+				// 		'token':token
+				// 	},
+				// 	method: "POST",
+				// 	success: (res) => {
 
-					},
-				});
+				// 	},
+				// });
 				var ddd = this.timeAll.get(id);
 				if (that.timeAll.get(id) != null) {
 					var stamp = Date.parse(new Date());