Browse Source

add resart btn

privacy
刘嘉炜 1 year ago
parent
commit
73fa2c8319
  1. 4
      src/subpackage/device/js/device_api.js
  2. 97
      src/subpackage/device/pages/index/index.vue
  3. 10
      src/subpackage/device/pages/switch_manage/switch_manage.vue

4
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;

97
src/subpackage/device/pages/index/index.vue

@ -30,7 +30,12 @@
</view>
</view>
</view>
<!-- <view class="ic-btn" hover-class="hover-active" @click="restartBtn">重启</view> -->
<view
v-if="oxAcInfo.extension&&oxAcInfo.extension.switch_device_name"
class="ic-btn"
hover-class="hover-active"
@click="restartBtn"
>重启</view>
</view>
</view>
@ -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);
})
},
}
}
</script>

10
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()})

Loading…
Cancel
Save