1
0
forked from dyf/APP

4877保存已选的配组

This commit is contained in:
liub
2025-12-03 11:42:05 +08:00
parent e2d07e984f
commit 6414bf3d7a
3 changed files with 218 additions and 2 deletions

View File

@ -255,7 +255,8 @@
import {
colors as groupColors
} from '@/api/4877/BJQ4877.js';
import MqTool from '@/utils/MqHelper.js'
const pagePath = "/pages/4877/BJQ4877";
@ -264,6 +265,7 @@
var recei = null;
var interval = null;
var slidTime = null;
var mq=null;
export default {
data() {
return {
@ -389,12 +391,19 @@
onUnload() {
console.log("页面卸载,释放资源");
ble.removeAllCallback(pagePath);
if(mq){
mq.unSubscribes();
mq.disconnect();
}
ble=null;
mq=null;
clearInterval(interval);
},
onLoad: function() {
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
mq=MqTool.getMqTool();
this.dic.gropus = [];
@ -429,6 +438,14 @@
}
var device = data.data;
these.device = device;
let arr=[{topic:'C/4877_Groups_'+these.device.id,callback:these.getCheckedColors}];
mq.init().then(res=>{
mq.subscribes(arr).catch(ex=>{
console.error("ex=",ex);
});
})
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
@ -477,6 +494,30 @@
},
methods: {
getCheckedColors(rec){
console.error("收到MQ消息:",rec);
try{
let str=rec.receive.payloadString;
let arr=JSON.parse(str);
let groups = groupColors.filter((v,index) => {
if(arr[index]===1){
return true;
}
return false;
});
these.dic.groups = groups;
}catch(err){
}
},
ShowChannelEdit() {
this.Status.ShowEditChannel = true;
this.showPop({
@ -596,7 +637,11 @@
return;
}
mq.sendData('C/4877_Groups_'+these.device.id,JSON.stringify(arr),true).then(res=>{
console.log("发送成功,",res)
}).catch(err=>{
console.error("err=",err);
});
var json = {
ins_GroupType: arr
}