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