柒零 hai 1 ano
pai
achega
7a67927b41
Modificáronse 1 ficheiros con 29 adicións e 3 borrados
  1. 29 3
      pages/index/index.js

+ 29 - 3
pages/index/index.js

@@ -493,7 +493,7 @@ Page({
 			method: 'POST',
 			data: {
 				"entity_id": item.entity_id,
-				"skip_condition":true,
+				"skip_condition": true,
 			},
 			header: {
 				'content-type': 'application/json', // 默认值
@@ -1585,6 +1585,7 @@ Page({
 				}
 			}
 			console.log('listSwitchTemp=' + JSON.stringify(listSwitchTemp));
+			listSwitchTemp = that.checkTVList(listSwitchTemp);
 			that.setData({
 				listSwitch: listSwitchTemp,
 				listAromatherapyMachine: listAromatherapyMachineTemp,
@@ -2252,7 +2253,7 @@ Page({
 		let entity_id = e.currentTarget.dataset.id;
 		let list = this.data.listClimate;//这里是将需要循环的数组赋值给list
 		let indexS = Number(e.currentTarget.dataset.index);
-		
+
 		// 将本地缓存数据渲染到对应修改的案例
 		list.forEach(function (value, index, array) {
 			if (index == indexS) {
@@ -2931,7 +2932,7 @@ Page({
 									// obj.microphone.mute = resData[i].attributes.microphone.mute;
 									// obj.speaker.mute = resData[i].attributes.speaker.mute;
 									// console.log('media-player-miot-obj=='+obj);
-									if (obj.entity_id && obj.state && checkState(obj.state) && obj.friendly_name && obj.domain ) {
+									if (obj.entity_id && obj.state && checkState(obj.state) && obj.friendly_name && obj.domain) {
 										listMiotMediaPlayerTemp.push(obj);
 									}
 								}
@@ -3069,6 +3070,7 @@ Page({
 								// }
 								// }
 							}
+							listSwitchTemp = that.checkTVList(listSwitchTemp);
 							that.setData({
 								// status_beep: that.getEntityState(res.data,'switch.xiaomi_pro3_02bd_left_switch_service'), //实验室主灯
 								// status_led: that.getEntityState(res.data,'light.deerma_jsq2g_392f_indicator_light'), //加湿器 Indicator Light
@@ -3615,6 +3617,7 @@ Page({
 								// }
 								// }
 							}
+							listSwitchTemp = that.checkTVList(listSwitchTemp);
 
 							that.setData({
 								// status_beep: that.getEntityState(res.data,'switch.xiaomi_pro3_02bd_left_switch_service'), //实验室主灯
@@ -3714,6 +3717,29 @@ Page({
 		console.log(`myFunctionToTest 执行时间为: ${executionTime} 毫秒`);
 		return true;
 	},
+	checkTVList(items = []) {
+		// 创建一个新数组来存放不包含"电视"的对象  
+		let newItems = [];
+		// 存放包含"电视"的对象  
+		let tvItems = [];
+
+		// 遍历原数组  
+		items.forEach(item => {
+			// 检查name是否包含"电视"  
+			if (item.friendly_name.includes("电视")) {
+				tvItems.push(item);
+			} else {
+				newItems.push(item);
+			}
+		});
+
+		// 将包含"电视"的对象添加到新数组的末尾  
+		newItems.push(...tvItems);
+
+		// 如果需要,用新数组替换原数组  
+		items = newItems;
+		return items;
+	},
 	imageLoad: function () {
 		this.setData({
 			isLoading: false,