diff --git a/src/subpackage/device/js/device_fun.js b/src/subpackage/device/js/device_fun.js new file mode 100644 index 0000000..27a8fdc --- /dev/null +++ b/src/subpackage/device/js/device_fun.js @@ -0,0 +1,26 @@ + +/* +硬件处理函数 +*/ +var DEVICE_FUN = { + + /* + @data:过滤数据 + @switchInfo:操作的设备信息 + 使用: _data = DEVICE_FUN.AC_filterCloudACData(data,switchInfo); + 场景: 目前需求只要求照明(中控状态更新,灯操控) 其它需要再对接 + 注意: 涉及deviceApi.ouxuanac 接口的,理论上来说都需要做兼容去在逻辑中传入硬件信息判断是否是云中控 + */ + AC_filterCloudACData(data,switchInfo){ + console.log("云中控参数检测 AC_filterCloudACData",data,switchInfo); + //处理云中控专用参数 + // 这里device是设备名 一旦出现云中控 设备id被 (OUXUANAC_CLOUD_+hardware_net_addr) 串起来的字符串覆盖 + if(!!switchInfo&&switchInfo.hardware_connect_method=="YZK"){ + data.device = "OUXUANAC_CLOUD_"+switchInfo.hardware_net_addr; + } + + return data + }, +} + +export default DEVICE_FUN; diff --git a/src/subpackage/device/pages/air_conditioner/detail/detail.vue b/src/subpackage/device/pages/air_conditioner/detail/detail.vue index a9d0c9d..c740500 100644 --- a/src/subpackage/device/pages/air_conditioner/detail/detail.vue +++ b/src/subpackage/device/pages/air_conditioner/detail/detail.vue @@ -226,6 +226,7 @@ export default { console.warn('_qyObj', _qyObj); _qyObj = this.setExt({ query: _qyObj, value: '', }); this.subpackInfo = _qyObj; + console.log(11111,_qyObj); this.operateReq({ data: _qyObj, isTip: false }); }, methods: { diff --git a/src/subpackage/device/pages/audio_manage/audio_manage.vue b/src/subpackage/device/pages/audio_manage/audio_manage.vue index 9e8e7bd..f40bdc5 100644 --- a/src/subpackage/device/pages/audio_manage/audio_manage.vue +++ b/src/subpackage/device/pages/audio_manage/audio_manage.vue @@ -117,7 +117,8 @@ mapState } from 'vuex'; import util from '../../../../utils/util'; - + + import DEVICE_FUN from '../../js/device_fun.js'; export default { components: { @@ -404,7 +405,10 @@ let _data = this.getOperateReqData({ switchInfo, status - }) + }) + + _data = DEVICE_FUN.AC_filterCloudACData(data,switchInfo); + //针对门禁没有关按钮发两条命令->开&关 20201224 后端: 直接发两条 关的那条这里填5 然后你那边不用管返回 if (switchInfo.hardware_type === 'AccessControl' && status == 1) { this.operateReq({ @@ -460,7 +464,7 @@ }) { let that = this if (isLoad) util.showLoad(); - console.log("123",data); + deviceServer.post({ url: deviceApi.ouxuanac, data: data, @@ -514,6 +518,8 @@ // index, // }) //TODO 等待后续音响设备调试后,再开放更新设备状态功能 + // _data = DEVICE_FUN.AC_filterCloudACData(data,switchInfo); + util.showLoad(); setTimeout(()=>util.hideLoad(),1000) }, 300, 300), @@ -668,7 +674,8 @@ let _obj = { 'Gpio': 'get-rpio', // 全设备 'SerialPort485': 'zzio404d-gpio-status', - 'Tcp': 'zzio404d-gpio-status-tcp', + 'Tcp': 'zzio404d-gpio-status-tcp', + 'YZK':'zzio404d-gpio-status' }; return _obj[hardware_connect_method] || '' @@ -682,7 +689,8 @@ let _obj = { 'Gpio': 'set-rpio', // 全设备 'SerialPort485': 'zzio404d-gpio', - 'Tcp': 'zzio404d-gpio-tcp', + 'Tcp': 'zzio404d-gpio-tcp', + 'YZK':'zzio404d-gpio' }; return _obj[hardware_connect_method] || '' diff --git a/src/subpackage/device/pages/order_details/order_details.vue b/src/subpackage/device/pages/order_details/order_details.vue index 64d52a9..d1a3325 100644 --- a/src/subpackage/device/pages/order_details/order_details.vue +++ b/src/subpackage/device/pages/order_details/order_details.vue @@ -20,7 +20,7 @@ *退款金额 - + 最多可退{{ (pageInfo.extension&&pageInfo.extension.refundable_amount) || 0 }}元 diff --git a/src/subpackage/device/pages/switch_manage/switch_manage.vue b/src/subpackage/device/pages/switch_manage/switch_manage.vue index 5c0e8e2..4ee252e 100644 --- a/src/subpackage/device/pages/switch_manage/switch_manage.vue +++ b/src/subpackage/device/pages/switch_manage/switch_manage.vue @@ -65,6 +65,7 @@ import deviceApi from '../../js/device_api'; import { mapState } from 'vuex'; import util from '../../../../utils/util'; +import DEVICE_FUN from '../../js/device_fun.js'; export default { components: { @@ -174,10 +175,13 @@ export default { console.log("icon tap status: ",status,switchInfo) let _data = this.getOperateReqData({ switchInfo, status }) + + _data = DEVICE_FUN.AC_filterCloudACData(_data,switchInfo); + //针对门禁没有关按钮发两条命令->开&关 20201224 后端: 直接发两条 关的那条这里填5 然后你那边不用管返回 //新增定时/长按拦截判断 - if(status == 2) return util.showNone("该功能暂未开放") + // if(status == 2) return util.showNone("该功能暂未开放") if(status == 4){ @@ -213,7 +217,11 @@ export default { device: curStoreInfo.device_name, // 中控名, data: _query, // 后端数据结构, 参考src\subpackage\device\js\ouxuanac.md }; - + + //2021-12-17 群里说的那个锁的 需要全部关闭灯的按钮从 set-rpio 变成 set-rpio-lock 普通开灯保持不变 加锁开灯(长开) set-rpio-lock + if(switchInfo.hardware_type=="Light"&&_data.data.value.status=="high")_data.data.name = "set-rpio-lock" + if(switchInfo.hardware_type=="Light"&&status==2)_data.data.name = "set-rpio-lock" + //针对门禁没有关按钮发两条命令->开&关 20201224 后端: 直接发两条 关的那条这里填5 然后你那边不用管返回 if(switchInfo.hardware_type === 'AccessControl'&&status == 0)_data['delay'] = '5'; @@ -263,8 +271,11 @@ export default { }) } + let _data = this.getSwitchStatusQuery(switchInfo); + _data = DEVICE_FUN.AC_filterCloudACData(data,switchInfo); + this.getStatusReq({ - data: this.getSwitchStatusQuery(switchInfo), + data: _data, index, }) },300,300), @@ -347,6 +358,7 @@ export default { // 数据结构参考 src\subpackage\device\js\ouxuanac.md // 空调开关数据结构独立判断处理 hardware_type === 'Air' getSwitchQuery({ switchInfo, status = '' }){ + let { hardware_connect_method, hardware_type, @@ -354,17 +366,19 @@ export default { node_id, hardware_net_addr } = switchInfo; - + const _hardware_connect_method = this.changeLowerCase(hardware_connect_method) + const postData = { name: this.getQueryName(switchInfo), value: { id: hardware_id + '', } // value 内值全为String }; - if (this.changeLowerCase(hardware_connect_method) === 'gpio') postData.value['status'] = this.getRelayStatus(status); + if (_hardware_connect_method === 'gpio') postData.value['status'] = this.getRelayStatus(status); // tcp 连接需要 hardware_net_addr - if (this.changeLowerCase(hardware_connect_method) === 'tcp') postData.value['tcp'] = hardware_net_addr + ''; - let _flag = this.changeLowerCase(hardware_connect_method) === 'serialport485' || this.changeLowerCase(hardware_connect_method) === 'tcp'; + if (_hardware_connect_method === 'tcp') postData.value['tcp'] = hardware_net_addr + ''; + // let _flag = _hardware_connect_method === 'serialport485' || _hardware_connect_method === 'tcp'||_hardware_connect_method==='yzk'; + let _flag = ['serialport485','tcp','yzk'].some(e=> e===_hardware_connect_method); if (_flag){ if(hardware_type === 'Air'){ // 空调开关状态 key为 op postData.value['op'] = this.getAirRelayStatus(status); @@ -375,17 +389,18 @@ export default { postData.value['o'] = this.getRelayStatus(status); // 开关状态 } } + return postData; }, changeLowerCase(str){ - return str.toString().toLocaleLowerCase(); + return str.toString().toLocaleLowerCase(); }, // 常规开关状态 // Low = "low", // 低电位,为开启 // High = "high", // 高电位, 为关闭 // status 0 -> 关(左), 1 -> 开(右) ,2 -> 长开 ,3 -> 定时, 4 ->详情(自定义) getRelayStatus(status){ - return [ 'high', 'low', '', 'high', ''][status] || '' + return [ 'high', 'low', 'low', 'high', ''][status] || '' }, // 空调状态 @@ -403,6 +418,7 @@ export default { 'Gpio': 'get-rpio', // 全设备 'SerialPort485': 'zzio404d-gpio-status', 'Tcp': 'zzio404d-gpio-status-tcp', + 'YZK':'zzio404d-gpio-status' }; return _obj[hardware_connect_method] || '' @@ -415,6 +431,7 @@ export default { 'Gpio': 'set-rpio', // 全设备 'SerialPort485': 'zzio404d-gpio', 'Tcp': 'zzio404d-gpio-tcp', + 'YZK':'zzio404d-gpio' }; return _obj[hardware_connect_method] || ''