Commit b97a02d4 by zhangzhen

硬件操作优化

parent ead25fbb
......@@ -51,7 +51,7 @@
<text class="text-title">门禁控制</text>
<view v-if="val.deviceList.door.status ==1" class="">
<text>电量:{{val.deviceList.door.voltage}}</text>
<button @tap="onDeviceRun(10,val.deviceList.door.roomId)" class="cu-btn bg-blue margin-left-sm">开启</button>
<button @tap="onDeviceRun(10,val.deviceList.door)" class="cu-btn bg-blue margin-left-sm">开启</button>
</view>
<view v-else-if="val.deviceList.door.status =='0'" class="">
<text>离线</text>
......@@ -60,8 +60,11 @@
<view class="part" v-if="val.deviceList.el">
<text class="text-title">取电开关</text>
<view class="">
<button @tap="onDeviceRun(20,val.deviceList.el.roomId)" class="cu-btn bg-blue margin-right-sm">开启</button>
<button @tap="onDeviceRun(40,val.deviceList.el.roomId)" class="cu-btn bg-blue">关闭</button>
<text class="margin-right-sm" :class="val.deviceList.el.status==3?'text-red':'text-green'">{{deviceStatusEnum[val.deviceList.el.status]}}</text>
<button @tap="onDeviceRun(20,val.deviceList.el)" class="cu-btn margin-right-sm" :class="val.deviceList.el.status==2?'bg-blue':'bg-gray'">开启</button>
<button @tap="onDeviceRun(40,val.deviceList.el)" class="cu-btn" :class="val.deviceList.el.status==3?'bg-blue':'bg-gray'">关闭</button>
<!-- <switch data-type="door" :data-index="index" :data-k="k" :data-id="val.deviceList.el.roomId" @change="onSwitchDoor" :class="val.deviceList.el.status==3?'checked':''" :checked="val.deviceList.el.status==3?true:false" color="#e54d42"></switch> -->
</view>
</view>
......@@ -101,6 +104,7 @@ import moment from "@/common/moment";
3:"#ff494e",
4:"#ff49ef"
},
deviceStatusEnum:{},
colorList:[
{
label:"空闲中",
......@@ -137,7 +141,8 @@ import moment from "@/common/moment";
20:'取电',
30:'锁门',
40:'断电'
}
},
timer:null
};
},
filters:{
......@@ -154,12 +159,14 @@ import moment from "@/common/moment";
if (uni.getStorageSync('dicts')) {
dicts = JSON.parse(uni.getStorageSync('dicts'))
this.cleanStatusEnum = getDictItem(dicts, "clean_records_status");
this.deviceStatusEnum = getDictItem(dicts,"device_status");
this.onLoading()
} else {
dictList().then(res => {
dicts = res.data.data;
uni.setStorageSync('dicts', JSON.stringify(res.data.data))
this.cleanStatusEnum = getDictItem(dicts, "clean_records_status");
this.deviceStatusEnum = getDictItem(dicts,"device_status");
this.onLoading()
})
}
......@@ -168,10 +175,10 @@ import moment from "@/common/moment";
getList().then(res=>{
if(res.data.code ===200){
let list =res.data.data&&res.data.data.length? res.data.data:[];
this.list = list.map(item=>{
this.list = list.map((item,index)=>{
return {
...item,
show:false,
show: this.list.length? this.list[index].show: false,
roomVoList: item.roomVoList && item.roomVoList.length ? item.roomVoList.map(val=>{
let deviceList = {}
if(val.deviceList && val.deviceList.length){
......@@ -199,7 +206,7 @@ import moment from "@/common/moment";
}
return {
...val,
colorStatus: val.recordsStatus>=0&& val.recordsStatus=== 0? 3: val.recordsStatus >= 0&& val.recordsStatus=== 1? 4: val.status,
colorStatus: val.recordsStatus >=0 && val.recordsStatus=== 0? 3: val.recordsStatus >= 0&& val.recordsStatus=== 1? 4: val.status,
images:val.images? val.images.split(","):[],
deviceList
}
......@@ -236,7 +243,9 @@ import moment from "@/common/moment";
// let t = e.target.value? 20: 40
// this.onDeviceRun(t,e.target.dataset.id)
// },
onDeviceRun(opType,roomId){
onDeviceRun(opType,device){
if(opType == 20 && device.status != 2) return;
if(opType == 40 && device.status != 3) return;
let that = this;
if(this.deviceTime){
uni.showToast({
......@@ -251,7 +260,7 @@ import moment from "@/common/moment";
})
deviceRun({
opType,
roomId
roomId:device.roomId
}).then(res =>{
uni.hideLoading()
if(res.data.code ===200){
......@@ -259,6 +268,19 @@ import moment from "@/common/moment";
icon:"success",
title:this.optionStatus[opType]+"成功"
})
let i = 5;
if(that.timer){
clearInterval(that.timer)
}
that.timer = setInterval(()=>{
if(i<=0){
clearInterval(that.timer)
return
}
i-=1;
that.onLoading();
},7000)
}else{
uni.showToast({
icon:"none",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment