diff --git a/src/subpackage/device/js/device_api.js b/src/subpackage/device/js/device_api.js index ff6be99..047c958 100644 --- a/src/subpackage/device/js/device_api.js +++ b/src/subpackage/device/js/device_api.js @@ -62,8 +62,8 @@ export const DEVICE_API = { // 【ID1000841】 20220516 小程序-商家助手菜单入口权限优化 hardwareTypeList:`${ORIGIN}/admin/stadium/hardwareType/list`, // 设备权限列表 - - + // 【ID1001350】 20230815 小程序-商家助手小程序设备管理优化 + ouxuanacList:`${ORIGIN}/admin/ouxuanac/list`, // 获取中控信息 } export default DEVICE_API; \ No newline at end of file diff --git a/src/subpackage/device/pages/index/index.vue b/src/subpackage/device/pages/index/index.vue index abf1e57..9eabbbb 100644 --- a/src/subpackage/device/pages/index/index.vue +++ b/src/subpackage/device/pages/index/index.vue @@ -30,7 +30,12 @@ - + 重启 @@ -104,7 +109,7 @@ export default { }, watch: { curStoreInfo(nw, od){ - console.warn(od.id, nw.id); + this.getOuxuanacInfo(nw.device_name); this.getHardwareTypeList(); } }, @@ -117,6 +122,7 @@ export default { statusBarHeight: 0, titleBarHeight: 0 }, + oxAcInfo: {}, } }, async onLoad(options){ @@ -124,10 +130,13 @@ export default { util.showLoad(); let _brandInfo = await this.$store.dispatch('getBrandInfo'); await this.$store.dispatch('getStoreList', { stadium_id: +options.stadium_id || '' }); + let { curStoreInfo } = this; this.updateAC(); await this.getHardwareTypeList(); + await this.getOuxuanacInfo(curStoreInfo.device_name); util.hideLoad(); }catch(err){ + console.warn('onLoad err--->', err) util.hideLoad(); } @@ -139,9 +148,7 @@ export default { this.initSysBarInfo(); }, methods: { - restartBtn(){ - util.showNone('调试开发中!'); - }, + initSysBarInfo(){ let wxBtn = uni.getMenuButtonBoundingClientRect(); let sysInfo = uni.getSystemInfoSync(); @@ -213,7 +220,85 @@ export default { let { curStoreInfo } = this; if(e.path == '')return util.showNone('开发中!'); util.routeTo(`${rootPage}${e.path}?sid=${e?.id || ''}&stadium_id=${curStoreInfo?.id || ''}`, 'nT'); - } + }, + // 获取中控重启参数 + getOuxuanacInfo(id_ouxuanac){ + if(!id_ouxuanac){ + console.log('中控id不存在 id_ouxuanac ->', id_ouxuanac); + return Promise.resolve([]); + } + return deviceServer.get({ + url: deviceApi.ouxuanacList, + data: { id_ouxuanac }, + failMsg: '加载中控信息失败!' + }) + .then(res=>{ + console.log('id_ouxuanac', res); + this.initOuxuancInfo({ oxacLs: res?.list || [], id_ouxuanac }); + return res + }) + }, + // 初始化中控信息 + initOuxuancInfo({ oxacLs, id_ouxuanac }){ + this.oxAcInfo = oxacLs.find(e=>e.id_ouxuanac == id_ouxuanac) || {}; + }, + restartBtn(){ + let { curStoreInfo, oxAcInfo } = this; + let _dvName = oxAcInfo?.extension?.switch_device_name; + this.operateReq({ deviceName: _dvName, op: 'off', }) + .then(code=>{ + if(code === 0){ + setTimeout(_=>{ this.operateReq({ deviceName: _dvName, op: 'on', }) }, 1000) + } + }) + + // util.showNone('调试开发中!'); + }, + // 操作接口请求 + operateReq({deviceName, op, isTip=true}){ + // let _query = { + // is_delay: true, + // name: "gate-switch", + // queue_group: "gate", + // value: { tcp: "", cid: "", op}, + // device: deviceName, + // hardware_id: "", + // } + let _query = { + "data": { + "name": "gate-switch", + "value":{ + "op": op + }, + "is_async":true + }, + "device": deviceName + } + util.showLoad(); + return deviceServer.post({ + url: deviceApi.ouxuanac, + data: _query, + isDefaultGet: false, + }) + .then(res=>{ + util.hideLoad(); + if(res.data.code == 0){ + if(isTip)util.showNone(res.data.message || '操作成功!'); + return 0 + }else{ + util.showModal({ + title: '提示', + content: res.data.message || '操作失败!', + showCancel: false, + }) + return 1 + } + }) + .catch(err=>{ + util.hideLoad(); + return Promise.reject(err); + }) + }, } } diff --git a/src/subpackage/device/pages/switch_manage/switch_manage.vue b/src/subpackage/device/pages/switch_manage/switch_manage.vue index c780df1..be92de2 100644 --- a/src/subpackage/device/pages/switch_manage/switch_manage.vue +++ b/src/subpackage/device/pages/switch_manage/switch_manage.vue @@ -249,7 +249,9 @@ export default { // 20220507 门闸 GateControl 要是 hardware_mac_addr 不为空 device_name 替换成 hardware_mac_addr // 另外多做一步 传多一个 "hardware_id":id 给我 if(switchInfo.hardware_type === 'GateControl'&&!!switchInfo.hardware_mac_addr)_data['device'] = switchInfo.hardware_mac_addr; - // if(switchInfo.hardware_type === 'GateControl')_data['hardware_id'] = switchInfo.id; + + // 20230815 id1001355 后端: 门闸仅限于gate-switch + if(switchInfo.hardware_type === 'GateControl'&&_data?.data?.name === 'gate-switch')_data['device'] = switchInfo?.extension?.switch_device_name || ''; return _data; }, @@ -266,7 +268,11 @@ export default { if(res.data.code == 0){ if(isTip)util.showNone(res.data.message || '操作成功!'); }else{ - if(isTip)util.showNone(res.data.message || '操作失败!'); + if(isTip)util.showModal({ + title: '提示', + content: res.data.message || '操作失败!', + showCancel: false + }) } }) .catch(err=>{if(isLoad)util.hideLoad()})