柒零 1 jaar geleden
bovenliggende
commit
b1e4d31078
1 gewijzigde bestanden met toevoegingen van 10 en 156 verwijderingen
  1. 10 156
      pages/index/index.js

+ 10 - 156
pages/index/index.js

@@ -3956,8 +3956,18 @@ Page({
 				// this.startInterval();
 			}
 
+			setTimeout(() => {
+				that.showOther();
+			}, 500);
+
+
 		}
 	},
+	showOther() { 
+		const that = this;
+		that.startInterval();
+		
+	},
 	onLoad(option) {
 
 	},
@@ -4010,155 +4020,6 @@ Page({
 		that.setData({
 			currentMenuTabIndex: -1
 		})
-		that.startInterval();
-		// that.setData({
-		// 	ecHumidifier: {
-		// 		onInit: initChartHumidifier
-		// 	},
-		// })
-		//mqtt程序,保留
-		/* wx.showToast({
-		  title: "连接服务器....",
-		  icon: "loading",
-		  duration: 10000,
-		  mask: true,
-		});
-		let second = 10;
-		var toastTimer = setInterval(() => {
-		  second--;
-		  if (second) {
-			wx.showToast({
-			  title: `连接服务器...${second}`,
-			  icon: "loading",
-			  duration: 1000,
-			  mask: true,
-			});
-		  } else {
-			clearInterval(toastTimer);
-			wx.showToast({
-			  title: "连接失败",
-			  icon: "error",
-			  mask: true,
-			});
-		  }
-		}, 1000);
-		that.setData({
-		  client: connect(mqttUrl,options)
-		})
-	
-		that.data.client.on("connect", function () {
-		  console.log("成功连接mqtt服务器!");
-		  clearInterval(toastTimer);
-		  wx.showToast({
-			title: "连接成功",
-			icon: "success",
-			mask: true,
-		  });
-		  // 一秒后订阅主题
-		  setTimeout(() => {
-			that.data.client.subscribe(mpSubTopic_env, function (err) {
-			  if (!err) {
-				console.log("成功订阅设备上行数据环境Topic!");
-				wx.showToast({
-				  title: "订阅成功",
-				  icon: "success",
-				  mask: true,
-				});
-			  }
-			});
-		  }, 500);
-		});
-		setTimeout(() => {
-		  that.data.client.subscribe(mpSubTopic_con, function (err) {
-			if (!err) {
-			  console.log("成功订阅设备上行数据控制Topic!");
-			  wx.showToast({
-				title: "订阅成功",
-				icon: "success",
-				mask: true,
-			  });
-			 
-			}
-		  });
-		}, 200);
-	    
-		that.data.client.on("message", function (topic, message) {
-		  console.log(topic);
-		  // message是16进制的Buffer字节流
-		  let dataFromDev = {};
-		  console.log('message='+message);
-		  // 尝试进行JSON解析
-		  try {
-			dataFromDev = JSON.parse(message);
-			console.log(dataFromDev);
-			that.setData({
-			  //环境状态
-			  Temp: dataFromDev.Temp,
-			  Humi: dataFromDev.Humi,
-			  Voltage1: dataFromDev.Voltage1,
-			  Voltage2: dataFromDev.Voltage2,
-	
-			  //设备状态
-			  status_beep: dataFromDev.Beep_Flag,
-			  status_led: dataFromDev.Led_Flag,
-			  status_curtain: dataFromDev.Angle1,
-			  status_san: dataFromDev.San_Flag,
-			  status_door: dataFromDev.Angle2,
-			  status_fire: dataFromDev.Fire_Flag,
-			  status_light: dataFromDev.Light_Flag,
-			  status_mode: dataFromDev.Mode_Flag
-			})
-		  } catch (error) {
-			// 解析失败错误捕获并打印(错误捕获之后不会影响程序继续运行)
-			console.log(error);
-		  }
-		}) */
-		// if(this.tcp){
-		// 	this.tcp.onClose(() => {
-		//   // this.infoList.push('关闭')
-		//   console.log('tcp关闭');
-		//   this.tcp.close()
-		//   this.tcp = '';
-		// })
-		// }
-		// // 初始化TCP实例
-		// this.tcp = wx.createTCPSocket()
-		// // tcp实例向服务端发起连接
-		// this.tcp.connect({ address: '192.168.3.65', port: '81231' })
-		// // this.infoList.push(`向${this.ip}:${~~this.port}建立链接`)
-
-
-		// this.tcp.offClose(() => {
-		// })
-		// this.tcp.onConnect(() => {
-		//   // this.infoList.push('连接成功')
-		//   console.log('tcp连接成功');
-		// })
-		// this.tcp.offConnect(() => {
-		//   // this.infoList.push('offConnect')
-		//   console.log('tcp-offConnect');
-		// })
-		// this.tcp.onError(error => {
-		//   // this.infoList.push('异常:' + error)
-		//   console.log('tcp异常:' + error);
-
-		//   wx.showModal({
-		// 	title: '提示',
-		// 	content: '请先连接房间wi-fi,再次扫描',
-		// 	showCancel: false
-		//   });
-
-		//  setTimeout(function() {
-		//    wx.reLaunch({
-		// 		url: '/pages/scan/scan',
-		// 	   })
-		// 	 }, 2000) // 设置延时时间,单位为毫秒
-		//  })
-		// this.tcp.onMessage(data => {
-		//   // this.infoList.push('tcp接收到数据: ' + transitionArrayBufferToString(data.message))
-		//   console.log('tcp接收到数据: ' + JSON.stringify(data.message));
-		// })
-
 		wx.getLocation({
 			type: "wgs84",
 			success(res) {
@@ -4249,12 +4110,5 @@ Page({
 				});
 			},
 		});
-		// 获取天气相关数据
-
-		// wx.scanCode({
-		//   success: (res) => {
-		//     console.log('扫描结果:'+res.result) // 扫描结果
-		//   }
-		// });
 	}
 })