修改设备控制界面
This commit is contained in:
parent
e9154239e4
commit
3ffd4c9ed1
|
|
@ -19,12 +19,18 @@
|
|||
type="text"
|
||||
/>
|
||||
</view>
|
||||
<view class="machao"> MAC号:{{ obj.mac == undefined ? '--' : obj.mac }}</view>
|
||||
<view class="machao"> 电压:{{ obj.voltage == undefined ? '--' : obj.voltage }}V</view>
|
||||
<view class="machao">
|
||||
功率:{{ obj.realTimePower == undefined ? '--' : obj.realTimePower }}W
|
||||
MAC号:{{ obj.mac == undefined ? "--" : obj.mac }}
|
||||
</view>
|
||||
<view class="machao">
|
||||
电压:{{ obj.voltage == undefined ? "--" : obj.voltage }}V
|
||||
</view>
|
||||
<view class="machao">
|
||||
功率:{{ obj.realTimePower == undefined ? "--" : obj.realTimePower }}W
|
||||
</view>
|
||||
<view class="machao">
|
||||
电流:{{ obj.electricity == undefined ? "--" : obj.electricity }}A
|
||||
</view>
|
||||
<view class="machao"> 电流:{{ obj.electricity == undefined ? '--' : obj.electricity }}A</view>
|
||||
<view class="machao">
|
||||
网络:
|
||||
<text v-if="onlineStatus == '离线'" style="color: red">离线</text>
|
||||
|
|
@ -35,12 +41,18 @@
|
|||
<text v-if="powerStatus == '关闭'" style="color: red">关闭</text>
|
||||
<text v-if="powerStatus == '开启'" style="color: green">开启</text>
|
||||
</view>
|
||||
<view class="machao"> 版本号:{{ obj.version == undefined ? '--' : obj.version }}</view>
|
||||
<view class="machao">
|
||||
最后更新时间:{{ obj.lastPullTime == undefined ? '--' : obj.lastPullTime }}
|
||||
版本号:{{ obj.version == undefined ? "--" : obj.version }}
|
||||
</view>
|
||||
<view class="machao">
|
||||
最后在线时间:{{ obj.lastOnlineTime == undefined ? '--' : obj.lastOnlineTime }}
|
||||
最后更新时间:{{
|
||||
obj.lastPullTime == undefined ? "--" : obj.lastPullTime
|
||||
}}
|
||||
</view>
|
||||
<view class="machao">
|
||||
最后在线时间:{{
|
||||
obj.lastOnlineTime == undefined ? "--" : obj.lastOnlineTime
|
||||
}}
|
||||
</view>
|
||||
|
||||
<view class="jiaozhun">
|
||||
|
|
@ -68,190 +80,199 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { sendCommand } from "../../api/device/device";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
bgc: {
|
||||
backgroundColor: '#F7FAFE',
|
||||
backgroundColor: "#F7FAFE",
|
||||
},
|
||||
storeId: '',
|
||||
storeId: "",
|
||||
obj: {},
|
||||
id: '',
|
||||
onlineStatus: '--',
|
||||
powerStatus: '--',
|
||||
id: "",
|
||||
onlineStatus: "--",
|
||||
powerStatus: "--",
|
||||
valuedian: 220,
|
||||
xshu: '1',
|
||||
x: '',
|
||||
}
|
||||
xshu: "1",
|
||||
x: "",
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.sn) {
|
||||
this.storeId = options.sn
|
||||
this.getsn()
|
||||
this.storeId = options.sn;
|
||||
this.getsn();
|
||||
}
|
||||
},
|
||||
// 分享到好友(会话)
|
||||
onShareAppMessage: function () {
|
||||
return {
|
||||
title: '创想物联',
|
||||
path: '/pages/shouye/index',
|
||||
}
|
||||
title: "创想物联",
|
||||
path: "/pages/shouye/index",
|
||||
};
|
||||
},
|
||||
|
||||
// 分享到朋友圈
|
||||
onShareTimeline: function () {
|
||||
return {
|
||||
title: '创想物联',
|
||||
query: '',
|
||||
path: '/pages/shouye/index',
|
||||
}
|
||||
title: "创想物联",
|
||||
query: "",
|
||||
path: "/pages/shouye/index",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
sendCommand,
|
||||
btncq() {
|
||||
this.$u.put(`/app/device/admin/reboot?sn=${this.storeId}`).then(res => {
|
||||
this.$u.put(`/app/device/admin/reboot?sn=${this.storeId}`).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: '重启成功',
|
||||
icon: 'success',
|
||||
title: "重启成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
})
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
btnsxs() {
|
||||
this.$u.put(`/app/device/admin/uploadData?sn=${this.storeId}`).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.obj = res.data
|
||||
this.id = res.data.deviceId
|
||||
if (res.data.vxs == null) {
|
||||
this.xshu = 1
|
||||
this.$u
|
||||
.put(`/app/device/admin/uploadData?sn=${this.storeId}`)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.obj = res.data;
|
||||
this.id = res.data.deviceId;
|
||||
if (res.data.vxs == null) {
|
||||
this.xshu = 1;
|
||||
} else {
|
||||
this.xshu = res.data.vxs;
|
||||
}
|
||||
if (res.data.onlineStatus == 0) {
|
||||
this.onlineStatus = "离线";
|
||||
} else if (res.data.onlineStatus == 1) {
|
||||
this.onlineStatus = "在线";
|
||||
}
|
||||
if (res.data.powerStatus == 0) {
|
||||
this.powerStatus = "关闭";
|
||||
} else if (res.data.powerStatus == 1) {
|
||||
this.powerStatus = "开启";
|
||||
}
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
uni.hideLoading();
|
||||
} else {
|
||||
this.xshu = res.data.vxs
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
if (res.data.onlineStatus == 0) {
|
||||
this.onlineStatus = '离线'
|
||||
} else if (res.data.onlineStatus == 1) {
|
||||
this.onlineStatus = '在线'
|
||||
}
|
||||
if (res.data.powerStatus == 0) {
|
||||
this.powerStatus = '关闭'
|
||||
} else if (res.data.powerStatus == 1) {
|
||||
this.powerStatus = '开启'
|
||||
}
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
})
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
btnjian() {
|
||||
this.valuedian = Number(this.valuedian) - 1
|
||||
this.valuedian = Number(this.valuedian) - 1;
|
||||
},
|
||||
btnadd() {
|
||||
this.valuedian = Number(this.valuedian) + 1
|
||||
this.valuedian = Number(this.valuedian) + 1;
|
||||
},
|
||||
btnjiaozhun() {
|
||||
this.x = (this.valuedian / this.obj.voltage) * this.xshu
|
||||
this.x = this.x.toFixed(3)
|
||||
console.log(this.x)
|
||||
this.$u.put(`/app/device/admin/${this.obj.deviceId}/vxs?vxs=${this.x}`).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: '校准成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
})
|
||||
this.getsn()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
this.x = (this.valuedian / this.obj.voltage) * this.xshu;
|
||||
this.x = this.x.toFixed(3);
|
||||
console.log(this.x);
|
||||
this.$u
|
||||
.put(`/app/device/admin/${this.obj.deviceId}/vxs?vxs=${this.x}`)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
title: "校准成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
this.getsn();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
btnmy() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/my',
|
||||
})
|
||||
url: "/pages/my",
|
||||
});
|
||||
},
|
||||
qrcode() {
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode'],
|
||||
success: res => {
|
||||
scanType: ["qrCode"],
|
||||
success: (res) => {
|
||||
function getQueryParam(url, paramName) {
|
||||
let regex = new RegExp(`[?&]${paramName}=([^&]*)`)
|
||||
let results = regex.exec(url)
|
||||
return results ? decodeURIComponent(results[1].replace(/\+/g, ' ')) : null
|
||||
let regex = new RegExp(`[?&]${paramName}=([^&]*)`);
|
||||
let results = regex.exec(url);
|
||||
return results
|
||||
? decodeURIComponent(results[1].replace(/\+/g, " "))
|
||||
: null;
|
||||
}
|
||||
|
||||
let sceneValue = res.result
|
||||
let decodedValue = decodeURIComponent(sceneValue)
|
||||
let id = getQueryParam(decodedValue, 's')
|
||||
this.storeId = id
|
||||
this.getsn()
|
||||
let sceneValue = res.result;
|
||||
let decodedValue = decodeURIComponent(sceneValue);
|
||||
let id = getQueryParam(decodedValue, "s");
|
||||
this.storeId = id;
|
||||
this.getsn();
|
||||
},
|
||||
fail: err => {
|
||||
console.error('扫描失败:', err)
|
||||
fail: (err) => {
|
||||
console.error("扫描失败:", err);
|
||||
uni.showToast({
|
||||
title: '扫描失败',
|
||||
icon: 'none',
|
||||
})
|
||||
title: "扫描失败",
|
||||
icon: "none",
|
||||
});
|
||||
},
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
getsn() {
|
||||
this.$u.get(`/app/device/admin/get?sn=${this.storeId}`).then(res => {
|
||||
this.$u.get(`/app/device/admin/get?sn=${this.storeId}`).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.obj = res.data
|
||||
this.id = res.data.deviceId
|
||||
this.obj = res.data;
|
||||
this.id = res.data.deviceId;
|
||||
if (res.data.vxs == null) {
|
||||
this.xshu = 1
|
||||
this.xshu = 1;
|
||||
} else {
|
||||
this.xshu = res.data.vxs
|
||||
this.xshu = res.data.vxs;
|
||||
}
|
||||
if (res.data.onlineStatus == 0) {
|
||||
this.onlineStatus = '离线'
|
||||
this.onlineStatus = "离线";
|
||||
} else if (res.data.onlineStatus == 1) {
|
||||
this.onlineStatus = '在线'
|
||||
this.onlineStatus = "在线";
|
||||
}
|
||||
if (res.data.powerStatus == 0) {
|
||||
this.powerStatus = '关闭'
|
||||
this.powerStatus = "关闭";
|
||||
} else if (res.data.powerStatus == 1) {
|
||||
this.powerStatus = '开启'
|
||||
this.powerStatus = "开启";
|
||||
}
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'success',
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
})
|
||||
uni.hideLoading()
|
||||
});
|
||||
uni.hideLoading();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
// 返回录入
|
||||
|
|
@ -259,82 +280,106 @@ export default {
|
|||
uni.navigateBack({
|
||||
delta: 1, // 返回的页面数,默认1
|
||||
success: () => {
|
||||
console.log('返回上一页成功')
|
||||
console.log("返回上一页成功");
|
||||
},
|
||||
fail: err => {
|
||||
console.error('返回上一页失败:', err)
|
||||
fail: (err) => {
|
||||
console.error("返回上一页失败:", err);
|
||||
},
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
// 开启
|
||||
btnkq() {
|
||||
async btnkq() {
|
||||
uni.showLoading({
|
||||
title: '设备开启中...',
|
||||
})
|
||||
this.$u.put(`/app/device/admin/${this.id}/switch?open=true`).then(res => {
|
||||
if (res.code == 200) {
|
||||
title: "设备开启中...",
|
||||
});
|
||||
|
||||
try {
|
||||
const res = await sendCommand({
|
||||
command: "11open",
|
||||
mac: "44D6DA263B38",
|
||||
tryCount: "2",
|
||||
timeout: "10",
|
||||
reason: "测试",
|
||||
});
|
||||
|
||||
console.log("open-res", res);
|
||||
uni.hideLoading();
|
||||
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: '开启成功',
|
||||
icon: 'success',
|
||||
title: "开启成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
})
|
||||
this.powerStatus = '开启'
|
||||
});
|
||||
this.powerStatus = "开启";
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '开启失败',
|
||||
icon: 'none',
|
||||
title: res.msg || "开启失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("开启设备失败:", error);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: "开启失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
},
|
||||
// 关闭
|
||||
btngb() {
|
||||
uni.showLoading({
|
||||
title: '设备关闭中...',
|
||||
})
|
||||
this.$u.put(`/app/device/admin/${this.id}/switch?open=false`).then(res => {
|
||||
if (res.code == 200) {
|
||||
// setTimeout(()=>{
|
||||
// this.btnsx()
|
||||
// },1000)
|
||||
uni.showToast({
|
||||
title: '关闭成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
})
|
||||
this.powerStatus = '关闭'
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '关闭失败',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
})
|
||||
title: "设备关闭中...",
|
||||
});
|
||||
this.$u
|
||||
.put(`/app/device/admin/${this.id}/switch?open=false`)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
// setTimeout(()=>{
|
||||
// this.btnsx()
|
||||
// },1000)
|
||||
uni.showToast({
|
||||
title: "关闭成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
this.powerStatus = "关闭";
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "关闭失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 刷新
|
||||
btnsx() {
|
||||
this.$u.get(`/app/device/v2/refreshIot?deviceNo=${this.storeId}`).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.getsn()
|
||||
uni.showToast({
|
||||
title: '同步成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '同步失败',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
})
|
||||
this.$u
|
||||
.get(`/app/device/v2/refreshIot?deviceNo=${this.storeId}`)
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.getsn();
|
||||
uni.showToast({
|
||||
title: "同步成功",
|
||||
icon: "success",
|
||||
duration: 2000,
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "同步失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user