diff --git a/api/driverapi.js b/api/driverapi.js index a076be61..b21d727c 100644 --- a/api/driverapi.js +++ b/api/driverapi.js @@ -30,8 +30,9 @@ let api = { writeJinHuaControl_write: "/writeJinHuaControl/write", //控制器写入数据(金华) getcontrol_rtdata: "/getcontrol/rtdata", //主页查看控制器实时数据 getcontrol_fsdata: "/getcontrol/fsdata", //控制器实时数据折线图 - - getcontrol_cpermission: '/dcpermission/get', //根据设备id查询控制器权限 + + dcpermission_get:'/dcpermission/get',//控制器权限 + getcontrol_cpermission: '/getcontrol/cpermission', //根据设备id查询控制器权限 getControl_getState: '/readControl/getState', //控制器 设备运行状态 getReadControlliShuiControl: '/readControl/liShuiControl', //控制器 顶模和风机 diff --git a/pages/controller/controller.vue b/pages/controller/controller.vue index f1527ac2..5c42235f 100644 --- a/pages/controller/controller.vue +++ b/pages/controller/controller.vue @@ -2,7 +2,61 @@ - + + +
+ + + + + + + 控制模式: + + + 打   开 + {{ item.type_2 ? '关   闭' : '停   止' }} + 关   闭 + + + + + + + + 通道打开; + + + + + + 通道关闭 + + + + + + + + 通道; + + + + + + +
+
+ @@ -1246,7 +1300,209 @@ statusList: [], wxgetpermission: [], //小程序手机控制权限数据 - + itemList: [{ + head: "1#顶卷膜", + type: 21680, + open_value: 0, + close_value: 0 + }, + { + head: "2#顶卷膜", + type: 21683, + open_value: 0, + close_value: 0 + }, + { + head: "3#顶卷膜", + type: 21686, + open_value: 0, + close_value: 0 + }, + { + head: "1#侧卷膜", + type: 21689, + open_value: 0, + close_value: 0 + }, + { + head: "2#侧卷膜", + type: 21692, + open_value: 0, + close_value: 0 + }, + { + head: "外遮阳1", + type: 21695, + open_value: 0, + close_value: 0 + }, + { + head: "外遮阳2", + type: 21698, + open_value: 0, + close_value: 0 + }, + { + head: "外遮阳3", + type: 21701, + open_value: 0, + close_value: 0 + }, + { + head: "外遮阳4", + type: 21704, + open_value: 0, + close_value: 0 + }, + { + head: "外遮阳5", + type: 21707, + open_value: 0, + close_value: 0 + }, + { + head: "风机1", + type: 21710, + value: 0, + type_2: 2 + }, + { + head: "风机2", + type: 21712, + value: 0, + type_2: 2 + }, + { + head: "风机3", + type: 21714, + value: 0, + type_2: 2 + }, + { + head: "风机4", + type: 21716, + value: 0, + type_2: 2 + }, + { + head: "风机5", + type: 21718, + value: 0, + type_2: 2 + }, + { + head: "风机6", + type: 21720, + value: 0, + type_2: 2 + }, + { + head: "风机7", + type: 21722, + value: 0, + type_2: 2 + }, + { + head: "风机8", + type: 21724, + value: 0, + type_2: 2 + }, + { + head: "风机9", + type: 21726, + value: 0, + type_2: 2 + }, + { + head: "风机10", + type: 21728, + value: 0, + type_2: 2 + }, + ], +txt_act_list: [{ + txt_act21680: 0, + key: 21680 + }, + { + txt_act21683: 0, + key: 21683 + }, + { + txt_act21686: 0, + key: 21686 + }, + { + txt_act21689: 0, + key: 21689 + }, + { + txt_act21692: 0, + key: 21692 + }, + { + txt_act21695: 0, + key: 21695 + }, + { + txt_act21698: 0, + key: 21698 + }, + { + txt_act21701: 0, + key: 21701 + }, + { + txt_act21704: 0, + key: 21704 + }, + { + txt_act21707: 0, + key: 21707 + }, + { + txt_act21710: 0, + key: 21710 + }, + { + txt_act21712: 0, + key: 21712 + }, + { + txt_act21714: 0, + key: 21714 + }, + { + txt_act21716: 0, + key: 21716 + }, + { + txt_act21718: 0, + key: 21718 + }, + { + txt_act21720: 0, + key: 21720 + }, + { + txt_act21722: 0, + key: 21722 + }, + { + txt_act21724: 0, + key: 21724 + }, + { + txt_act21726: 0, + key: 21726 + }, + { + txt_act21728: 0, + key: 21728 + }, + ], + itemStyle: { width: "690rpx", background: " #FFFFFF", @@ -2079,47 +2335,61 @@ this.statusInterval = setInterval(() => { this.getControl_getState() }, this.statusTime * 1000); + + var deviceId = this.deviceId + this.$http({ + url: this.api.getcontrol_cpermission + '?deviceId=' + deviceId, + method: 'POST', + }).then(res=>{ + uni.stopPullDownRefresh(); +res.data.forEach((el, index) =>{ + this.purviewList.push({id:el.id.toString(),state:el.state}) + +}) +console.log(); + if (this.purviewList.findIndex(item => item.id =='10') != -1) { + // 小程序手机控制权限数据 + this.getcontrol_wxgetpermission(); + this.$http({ + url: this.api.readJinHuaControl_reg + '?deviceId=' + deviceId, + method: 'POST', + }).then(res => { + // console.log(res, 'deviceId读取所有寄存器的状态值'); + if (res.code == 200) { + uni.hideLoading() + uni.stopPullDownRefresh(); + this.inputData = res.data + for (let i = 0; i < this.itemList.length; i++) { + if (!this.itemList[i].type_2) { + this.itemList[i].open_value = this.inputData[Number( + '21681') + + i * + 3] + this.itemList[i].close_value = this.inputData[Number( + '21682') + + i * + 3] + this.getType((21680 + i * 3), 1) + } else { + this.itemList[i].value = this.inputData[21711 + (i - 10) * + 2] + this.getType((21710 + (i - 10) * 2), 2) + } + + } + + this.getType('21680') + this.getType('21683') + this.getType('21686') + this.getType('21689') + this.getType('21692') + + } + }) + } + }) // //查看金华权限 - // if (this.purviewList.indexOf('10') != -1) { - // // 小程序手机控制权限数据 - // this.getcontrol_wxgetpermission(); - // this.$http({ - // url: this.api.readJinHuaControl_reg + '?deviceId=' + deviceId, - // method: 'POST', - // }).then(res => { - // // console.log(res, 'deviceId读取所有寄存器的状态值'); - // if (res.code == 200) { - // uni.hideLoading() - // uni.stopPullDownRefresh(); - // this.inputData = res.data - // for (let i = 0; i < this.itemList.length; i++) { - // if (!this.itemList[i].type_2) { - // this.itemList[i].open_value = this.inputData[Number( - // '21681') + - // i * - // 3] - // this.itemList[i].close_value = this.inputData[Number( - // '21682') + - // i * - // 3] - // this.getType((21680 + i * 3), 1) - // } else { - // this.itemList[i].value = this.inputData[21711 + (i - 10) * - // 2] - // this.getType((21710 + (i - 10) * 2), 2) - // } - - // } - - // // this.getType('21680') - // // this.getType('21683') - // // this.getType('21686') - // // this.getType('21689') - // // this.getType('21692') - - // } - // }) - // } + //查看丽水权限 // if (this.purviewList.indexOf('9') != -1) { // // this.getControl_getState() @@ -2954,7 +3224,104 @@ } }); }, - + change00(type, index) { + uni.showLoading({ + title: '加载中...' + }) + let arr = this.txt_act_list.filter(el => el.key == type) + let key1 = Object.keys(arr[0])[0]; + this.txt_act_list.forEach(el => { + if (el.key == type) { + el[key1] = index + } + }) + + if (type > 21679 && type < 21708) { + var list = ["0", "0", "0"]; + if (index == 1) { + list[2] = "1"; + } else { + list[2] = "0"; + } + if (index == 2) { + list[1] = "1"; + } else { + list[1] = "0"; + } + if (index == 3) { + list[0] = "1"; + } else { + list[0] = "0"; + } + } else if (type > 21709 && type < 21729) { + var list = ["0", "0"]; + if (index == 1) { + list[1] = "1"; + } else { + list[1] = "0"; + }; + if (index == 2) { + list[0] = "1"; + } else { + list[0] = "0"; + }; + } + + var num = list.join(""); + var dataNum = { + target: { + value: parseInt(num, 2), + }, + }; + this.change(type, dataNum); + }, + getType(type, flag) { + if (flag == 1) { + var number = this.padString(Number(this.inputData[type]).toString(2), 3) + // console.log(number); //001 + // console.log(number[0]); //0 bit2 关闭 + // console.log(number[1]); //0 bit1 停止 + // console.log(number[2]); //1 bit0 打开 + let arr = this.txt_act_list.filter(el => el.key == type) + let key1 = Object.keys(arr[0])[0]; + this.txt_act_list.forEach(el => { + if (el.key == type) { + if (Number(number[0])) { + el[key1] = 3 + } else if (Number(number[1])) { + el[key1] = 2 + } else if (Number(number[2])) { + el[key1] = 1 + } else { + el[key1] = 0 + } + } + }) + } else if (flag == 2) { + var number = this.padString(Number(this.inputData[type]).toString(2), 2) + // console.log(number); //01 + // console.log(number[0]); //1 bit1 关闭 + // console.log(number[1]); //1 bit0 打开 + let arr = this.txt_act_list.filter(el => el.key == type) + let key1 = Object.keys(arr[0])[0]; + this.txt_act_list.forEach(el => { + if (el.key == type) { + if (Number(number[0])) { + el[key1] = 2 + } else if (Number(number[1])) { + el[key1] = 1 + } else { + el[key1] = 0 + } + } + }) + } + }, +// 根据type参数返回对应的txt_act21680 + getTypeRoll(i) { + let arr = this.txt_act_list.filter(el => el.key == i) + return arr[0][Object.keys(arr[0])[0]] + }, // x#顶卷膜输入框 blurChangeData00_1(code, el) { uni.showLoading({