|
|
@@ -821,7 +821,7 @@ Page({
|
|
|
});
|
|
|
|
|
|
},
|
|
|
-// switch
|
|
|
+ // switch
|
|
|
onSelect_All(e) {
|
|
|
var that = this;
|
|
|
const tempListSwitch = that.data.listSwitch;
|
|
|
@@ -874,6 +874,60 @@ Page({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+ },
|
|
|
+ // 香薰机开关
|
|
|
+ onSelect_All_AromatherapyMachine(e) {
|
|
|
+ var that = this;
|
|
|
+ const tempListSwitch = that.data.listAromatherapyMachine;
|
|
|
+ // 获取绑定的参数
|
|
|
+ var param0 = e.currentTarget.dataset.param0;
|
|
|
+ var param1 = e.currentTarget.dataset.param1;
|
|
|
+ var param2 = e.currentTarget.dataset.param2;
|
|
|
+ // var param3 = e.currentTarget.dataset.param3;
|
|
|
+ var param4 = e.currentTarget.dataset.param4 // 0 || 1;
|
|
|
+ var param5 = e.currentTarget.dataset.param5;
|
|
|
+ console.log('param1=' + param1);
|
|
|
+ console.log('param2=' + param2);
|
|
|
+ // console.log('param3='+param3);
|
|
|
+ // console.log('param4='+param4);
|
|
|
+ console.log('param5=' + param5);
|
|
|
+ if (param4 == '1') {
|
|
|
+ tempListSwitch[param0].state = "on"
|
|
|
+ } else {
|
|
|
+ tempListSwitch[param0].state = "off"
|
|
|
+ }
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ listAromatherapyMachine: tempListSwitch
|
|
|
+ })
|
|
|
+ // this.setData({
|
|
|
+ // status_beep: Number(param4)
|
|
|
+ // })
|
|
|
+ // if(param3 == "/turn_on"){
|
|
|
+ // that.data.listSwitch[param0].state = "off";
|
|
|
+ // that.data.listSwitch[param0].service = "turn_off";
|
|
|
+ // }else if(param3 == "/turn_off"){
|
|
|
+ // that.data.listSwitch[param0].state = "on";
|
|
|
+ // that.data.listSwitch[param0].service = "turn_on";
|
|
|
+ // }
|
|
|
+ console.log('switch 发生 change 事件,携带值为', e.detail)
|
|
|
+ wx.request({
|
|
|
+ url: `${homeApi_https}` + param1 + param2 + (e.detail ? '/turn_on' : '/turn_off'),
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ "entity_id": param5
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json', // 默认值
|
|
|
+ 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ // if(res.data){
|
|
|
+ // that.getSwitch(res.data,that)
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
onTap_All(e) {
|
|
|
var that = this;
|
|
|
@@ -1521,7 +1575,7 @@ Page({
|
|
|
//是否 是香薰机灯光
|
|
|
obj.isAromlight = obj.friendly_name.includes('香薰机灯光')
|
|
|
obj.isAromAtomization = obj.friendly_name.includes('香薰机雾化')
|
|
|
- obj.isAromatherapy = obj.friendly_name.endsWith('香薰机')
|
|
|
+ obj.isAromatherapy = obj.friendly_name.endsWith('香薰机') || obj.friendly_name.endsWith('香薰机开关')
|
|
|
if (obj.entity_id && obj.state && checkState(obj.state) && obj.friendly_name && obj.domain && !obj.isAromlight && !obj.isAromAtomization && !obj.isAromatherapy) {
|
|
|
listSwitchTemp.push(obj)
|
|
|
} else if ((obj.isAromlight || obj.isAromAtomization || obj.isAromatherapy) && checkState(obj.state)) {
|
|
|
@@ -2737,7 +2791,7 @@ Page({
|
|
|
obj.imgSrc = '/static/icons/ic_xxjwh.svg';
|
|
|
obj.selectedImgSrc = '/static/icons/ic_xxjwh.svg';
|
|
|
|
|
|
- } else if (obj.friendly_name.endsWith('香薰机')) {
|
|
|
+ } else if (obj.friendly_name.endsWith('香薰机') || obj.friendly_name.endsWith('香薰机开关')) {
|
|
|
obj.imgSrc = '/static/icons/ic_xxj.svg';
|
|
|
obj.selectedImgSrc = '/static/icons/ic_xxj.svg';
|
|
|
} else if (obj.friendly_name.includes("灯")) {
|
|
|
@@ -2767,7 +2821,7 @@ Page({
|
|
|
//是否 是香薰机灯光
|
|
|
obj.isAromlight = obj.friendly_name.includes('香薰机灯光')
|
|
|
obj.isAromAtomization = obj.friendly_name.includes('香薰机雾化')
|
|
|
- obj.isAromatherapy = obj.friendly_name.endsWith('香薰机')
|
|
|
+ obj.isAromatherapy = obj.friendly_name.endsWith('香薰机') || obj.friendly_name.endsWith('香薰机开关')
|
|
|
if (obj.entity_id && obj.state && checkState(obj.state) && obj.friendly_name && obj.domain && obj.domain != 'automation' && !obj.isAromlight && !obj.isAromAtomization && !obj.isAromatherapy) {
|
|
|
listSwitchTemp.push(obj)
|
|
|
} else if ((obj.isAromlight || obj.isAromAtomization || obj.isAromatherapy) && checkState(obj.state)) {
|
|
|
@@ -3283,7 +3337,7 @@ Page({
|
|
|
obj.imgSrc = '/static/icons/ic_xxjwh.svg';
|
|
|
obj.selectedImgSrc = '/static/icons/ic_xxjwh.svg';
|
|
|
|
|
|
- } else if (obj.friendly_name.endsWith('香薰机')) {
|
|
|
+ } else if (obj.friendly_name.endsWith('香薰机') || obj.friendly_name.endsWith('香薰机开关')) {
|
|
|
obj.imgSrc = '/static/icons/ic_xxj.svg';
|
|
|
obj.selectedImgSrc = '/static/icons/ic_xxj.svg';
|
|
|
}
|
|
|
@@ -3315,7 +3369,7 @@ Page({
|
|
|
//是否 是香薰机灯光
|
|
|
obj.isAromlight = obj.friendly_name.includes('香薰机灯光')
|
|
|
obj.isAromAtomization = obj.friendly_name.includes('香薰机雾化')
|
|
|
- obj.isAromatherapy = obj.friendly_name.endsWith('香薰机')
|
|
|
+ obj.isAromatherapy = obj.friendly_name.endsWith('香薰机') || obj.friendly_name.endsWith('香薰机开关')
|
|
|
if (obj.entity_id && obj.state && checkState(obj.state) && obj.friendly_name && obj.domain && obj.domain != 'automation' && obj.domain != 'automation' && !obj.isAromlight && !obj.isAromAtomization && !obj.isAromatherapy) {
|
|
|
listSwitchTemp.push(obj)
|
|
|
} else if ((obj.isAromlight || obj.isAromAtomization || obj.isAromatherapy) && checkState(obj.state)) {
|