|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<view class="home-warp">
|
|
|
<view class="clientInfo">
|
|
|
- <view class="wifItem" @click="godeviceApparatus">
|
|
|
+ <view class="wifItem" @click="goDeviceSetting()">
|
|
|
<text>设备参数</text>
|
|
|
<image
|
|
|
src="../../static/rightArrow.png"
|
|
@@ -113,131 +113,117 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
+
|
|
|
watch: {
|
|
|
- fallSettingEnabled: {
|
|
|
- handler(newVal, oldVal) {
|
|
|
- // console.log("fallSettingEnabled", newVal, oldVal);
|
|
|
- if (newVal == 1) {
|
|
|
- // this.showFallSettingModle = true;
|
|
|
- } else {
|
|
|
- this.showFallSettingModle = false;
|
|
|
- this.closeFallSetting();
|
|
|
- }
|
|
|
- this.preFallSettingEnabled = oldVal;
|
|
|
- },
|
|
|
+ fallSettingEnabled(newVal, oldVal) {
|
|
|
+ this.preFallSettingEnabled = oldVal;
|
|
|
+
|
|
|
+ if (newVal === 1) {
|
|
|
+ // 显示弹窗(由 onFallSettingChange 控制即可)
|
|
|
+ // this.showFallSettingModle = true;
|
|
|
+ } else {
|
|
|
+ this.showFallSettingModle = false;
|
|
|
+ this.updateFallSetting(false); // 关闭时自动保存
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- godeviceApparatus() {
|
|
|
+ goDeviceSetting() {
|
|
|
uni.navigateTo({
|
|
|
- url:
|
|
|
- "/pagesA/adDevice/adDevice?devInfo=" +
|
|
|
- JSON.stringify(this.devInfo),
|
|
|
+ url: `/pagesA/adDevice/adDevice?devInfo=${JSON.stringify(
|
|
|
+ this.devInfo
|
|
|
+ )}`,
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
roomSetting() {
|
|
|
+ const { devId, clientId } = this.devInfo;
|
|
|
uni.navigateTo({
|
|
|
- url:
|
|
|
- "/pagesA/roomSetting/roomSetting?devId=" +
|
|
|
- this.devInfo.devId +
|
|
|
- "&clientId=" +
|
|
|
- this.devInfo.clientId,
|
|
|
+ url: `/pagesA/roomSetting/roomSetting?devId=${devId}&clientId=${clientId}`,
|
|
|
});
|
|
|
},
|
|
|
- // 初始化坐摔参数
|
|
|
+
|
|
|
+ // ====================== 初始化参数 ======================
|
|
|
setFallSetting(devInfo) {
|
|
|
- console.log("devInfo", devInfo);
|
|
|
- if (devInfo.fallSettingEnabled == 1) {
|
|
|
- this.preFallSettingEnabled = devInfo.preFallSettingEnabled;
|
|
|
- this.fallSettingEnabled = devInfo.fallSettingEnabled;
|
|
|
- this.lowZMax = devInfo.lowZMax;
|
|
|
- this.humanPredThreshold = devInfo.humanPredThreshold;
|
|
|
- this.minEventsForDetection = devInfo.minEventsForDetection;
|
|
|
- this.minHumanEventsForDetection =
|
|
|
- devInfo.minHumanEventsForDetection;
|
|
|
- }
|
|
|
- this.showFallSettingModle = false;
|
|
|
+ console.log("初始化坐摔参数:", devInfo);
|
|
|
+ Object.assign(this, {
|
|
|
+ preFallSettingEnabled: devInfo.preFallSettingEnabled,
|
|
|
+ fallSettingEnabled: devInfo.fallSettingEnabled,
|
|
|
+ lowZMax: devInfo.lowZMax,
|
|
|
+ humanPredThreshold: devInfo.humanPredThreshold,
|
|
|
+ minEventsForDetection: devInfo.minEventsForDetection,
|
|
|
+ minHumanEventsForDetection: devInfo.minHumanEventsForDetection,
|
|
|
+ showFallSettingModle: false,
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
+ // ====================== 监听切换 ======================
|
|
|
onFallSettingChange({ detail }) {
|
|
|
- this.fallSettingEnabled = detail.value == true ? 1 : 0;
|
|
|
- if (this.fallSettingEnabled == 1) {
|
|
|
- this.showFallSettingModle = true;
|
|
|
- } else {
|
|
|
- this.showFallSettingModle = false;
|
|
|
- }
|
|
|
+ this.fallSettingEnabled = detail.value ? 1 : 0;
|
|
|
+ this.showFallSettingModle = this.fallSettingEnabled === 1;
|
|
|
},
|
|
|
- cancleFall() {
|
|
|
+
|
|
|
+ cancelFall() {
|
|
|
this.fallSettingEnabled = this.preFallSettingEnabled;
|
|
|
this.showFallSettingModle = false;
|
|
|
},
|
|
|
|
|
|
- // 取消坐摔设置
|
|
|
- closeFallSetting() {
|
|
|
- this.showFallSettingModle = false;
|
|
|
- delete this.devInfo.preFallSettingEnabled;
|
|
|
- delete this.devInfo.fallSettingEnabled;
|
|
|
- delete this.devInfo.lowZMax;
|
|
|
- delete this.devInfo.humanPredThreshold;
|
|
|
- delete this.devInfo.minEventsForDetection;
|
|
|
- delete this.devInfo.minHumanEventsForDetection;
|
|
|
- this.$http
|
|
|
- .post("wap/device/updateDevice", this.devInfo, {
|
|
|
- header: {
|
|
|
- "Content-Type": "application/json;charset=UTF-8",
|
|
|
- },
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.data.code == 200) {
|
|
|
- uni.showToast({
|
|
|
- title: "设置成功",
|
|
|
- icon: "success",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: res.data.message,
|
|
|
- icon: "none",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
+ // ====================== 通用更新方法 ======================
|
|
|
+ async updateFallSetting(showToast = true) {
|
|
|
+ // 整理更新参数
|
|
|
+ const payload = {
|
|
|
+ ...this.devInfo,
|
|
|
+ preFallSettingEnabled: this.preFallSettingEnabled,
|
|
|
+ fallSettingEnabled: this.fallSettingEnabled,
|
|
|
+ lowZMax: this.lowZMax,
|
|
|
+ humanPredThreshold: this.humanPredThreshold,
|
|
|
+ minEventsForDetection: this.minEventsForDetection,
|
|
|
+ minHumanEventsForDetection: this.minHumanEventsForDetection,
|
|
|
+ };
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await this.$http.post(
|
|
|
+ "wap/device/updateDevice",
|
|
|
+ payload,
|
|
|
+ {
|
|
|
+ header: {
|
|
|
+ "Content-Type": "application/json;charset=UTF-8",
|
|
|
+ },
|
|
|
}
|
|
|
- });
|
|
|
- },
|
|
|
- // 保存坐摔设置
|
|
|
- saveFallSetting() {
|
|
|
- this.devInfo.preFallSettingEnabled = this.preFallSettingEnabled;
|
|
|
- this.devInfo.fallSettingEnabled = this.fallSettingEnabled;
|
|
|
- this.devInfo.lowZMax = this.lowZMax;
|
|
|
- this.devInfo.humanPredThreshold = this.humanPredThreshold;
|
|
|
- this.devInfo.minEventsForDetection = this.minEventsForDetection;
|
|
|
- this.devInfo.minHumanEventsForDetection =
|
|
|
- this.minHumanEventsForDetection;
|
|
|
+ );
|
|
|
|
|
|
- this.$http
|
|
|
- .post("wap/device/updateDevice", this.devInfo, {
|
|
|
- header: {
|
|
|
- "Content-Type": "application/json;charset=UTF-8",
|
|
|
- },
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res.data.code == 200) {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ if (showToast) {
|
|
|
uni.showToast({
|
|
|
title: "设置成功",
|
|
|
icon: "success",
|
|
|
duration: 1500,
|
|
|
});
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: res.data.message,
|
|
|
- icon: "none",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
}
|
|
|
- this.showFallSettingModle = false;
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.data.message || "设置失败",
|
|
|
+ icon: "none",
|
|
|
+ duration: 1500,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "网络异常,请稍后再试",
|
|
|
+ icon: "none",
|
|
|
+ duration: 1500,
|
|
|
});
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // ====================== 保存/关闭 ======================
|
|
|
+ async saveFallSetting() {
|
|
|
+ await this.updateFallSetting();
|
|
|
+ this.showFallSettingModle = false;
|
|
|
},
|
|
|
},
|
|
|
+
|
|
|
onLoad(options) {
|
|
|
if (JSON.stringify(options) != "{}") {
|
|
|
this.devInfo = JSON.parse(options.devInfo);
|