|
@@ -14,11 +14,8 @@
|
|
{{ nowTime }}
|
|
{{ nowTime }}
|
|
</view>
|
|
</view>
|
|
<view class="alarm-info">
|
|
<view class="alarm-info">
|
|
- 检测到
|
|
|
|
<text style="color: #ff6d6d">{{ devName }}</text>
|
|
<text style="color: #ff6d6d">{{ devName }}</text>
|
|
- 可能发生跌倒事件,已通知
|
|
|
|
- <text style="color: #ff6d6d">{{ localPhone }}</text>
|
|
|
|
- 用户,请立即处理!
|
|
|
|
|
|
+ 检测到可能发生跌倒事件,请立即处理!
|
|
</view>
|
|
</view>
|
|
<view class="backImg">
|
|
<view class="backImg">
|
|
<image src="../../static/actionRed.png" mode="" />
|
|
<image src="../../static/actionRed.png" mode="" />
|
|
@@ -34,13 +31,16 @@
|
|
<view class="alarm-voice" v-else @click="authorizeIot">
|
|
<view class="alarm-voice" v-else @click="authorizeIot">
|
|
语音确认
|
|
语音确认
|
|
</view>
|
|
</view>
|
|
- <view class="alarm-handle" @click="handleAlarm"> 已知晓 </view>
|
|
|
|
|
|
+ <view class="alarm-handle" @click="handleAlarm()">
|
|
|
|
+ 已知晓
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
import config from "../../data/config.js";
|
|
import config from "../../data/config.js";
|
|
|
|
+import mqtt from "../../utils/mqtt";
|
|
import {
|
|
import {
|
|
getSnTicket,
|
|
getSnTicket,
|
|
authorize,
|
|
authorize,
|
|
@@ -80,18 +80,18 @@ export default {
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- alarmModel: true,
|
|
|
|
- nowTime: "2025-06-20 10:30:00",
|
|
|
|
- devName: "我的第一台设备",
|
|
|
|
- localPhone: "13888888888",
|
|
|
|
|
|
+ alarmModel: false,
|
|
|
|
+ nowTime: "",
|
|
|
|
+ devName: "",
|
|
authorizeFlag: true,
|
|
authorizeFlag: true,
|
|
- clientId: "30EDA036351C",
|
|
|
|
- dev_id: "30EDA036351C",
|
|
|
|
|
|
+ clientId: "",
|
|
|
|
+ dev_id: "",
|
|
|
|
+ mqttClient: "",
|
|
// voip相关
|
|
// voip相关
|
|
isWmpf: isWmpf,
|
|
isWmpf: isWmpf,
|
|
name: "用户",
|
|
name: "用户",
|
|
voipDevices: [],
|
|
voipDevices: [],
|
|
- sn: "30EDA036351C",
|
|
|
|
|
|
+ sn: "",
|
|
isShowPopUp: false,
|
|
isShowPopUp: false,
|
|
contactList: [],
|
|
contactList: [],
|
|
isWmpf,
|
|
isWmpf,
|
|
@@ -405,7 +405,18 @@ export default {
|
|
let client = "";
|
|
let client = "";
|
|
let selectedService = uni.getStorageSync("sercviceChoice");
|
|
let selectedService = uni.getStorageSync("sercviceChoice");
|
|
if (!selectedService || selectedService == "aloneServe") {
|
|
if (!selectedService || selectedService == "aloneServe") {
|
|
- client = mqtt.connect("wxs://radar-power.cn:8084/mqtt", params);
|
|
|
|
|
|
+ if (__wxConfig.envVersion == "develop") {
|
|
|
|
+ client = mqtt.connect(
|
|
|
|
+ "wxs://api.radar-power.asia:8084/mqtt",
|
|
|
|
+ params
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ if (__wxConfig.envVersion == "trial") {
|
|
|
|
+ client = mqtt.connect(
|
|
|
|
+ "wxs://radar-power.cn:8084/mqtt",
|
|
|
|
+ params
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// 存储client引用以便后续操作
|
|
// 存储client引用以便后续操作
|
|
this.mqttClient = client;
|
|
this.mqttClient = client;
|
|
@@ -416,7 +427,7 @@ export default {
|
|
if (err) {
|
|
if (err) {
|
|
console.error("订阅失败", err);
|
|
console.error("订阅失败", err);
|
|
} else {
|
|
} else {
|
|
- console.log(`成功订阅设备主题: device/${clientId}`);
|
|
|
|
|
|
+ console.log(`成功订阅设备主题: device/mps`);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -425,7 +436,7 @@ export default {
|
|
});
|
|
});
|
|
client.on("error", (err) => {
|
|
client.on("error", (err) => {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
- this.connectMQTT(clientId, devId);
|
|
|
|
|
|
+ this.connectMQTT();
|
|
}, 5000);
|
|
}, 5000);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -434,24 +445,24 @@ export default {
|
|
client.on("close", () => {});
|
|
client.on("close", () => {});
|
|
|
|
|
|
client.on("message", (topic, message) => {
|
|
client.on("message", (topic, message) => {
|
|
- // clearTimeout(this.inactivityTimer);
|
|
|
|
- // this.inactivityTimer = setTimeout(() => {
|
|
|
|
- // this.targetPoints = {};
|
|
|
|
- // }, 1500);
|
|
|
|
- // if (!match) return;
|
|
|
|
|
|
+ this.alarmModel = true;
|
|
const data = JSON.parse(message.toString());
|
|
const data = JSON.parse(message.toString());
|
|
|
|
+ this.clientId = data.clientId;
|
|
|
|
+ this.devName = data.devName;
|
|
|
|
+ this.sn = data.clientId;
|
|
|
|
+ const now = new Date();
|
|
|
|
+ const year = now.getFullYear();
|
|
|
|
+ const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
|
|
+ const day = now.getDate().toString().padStart(2, "0");
|
|
|
|
+ const hours = now.getHours().toString().padStart(2, "0");
|
|
|
|
+ const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
|
|
+ const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
|
|
+ this.nowTime = formattedTime;
|
|
console.log("接收到消息:", topic, data);
|
|
console.log("接收到消息:", topic, data);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- attached() {
|
|
|
|
- console.log("子组件打印了");
|
|
|
|
- if (!isWmpf) {
|
|
|
|
- this.getVoipDevices();
|
|
|
|
- }
|
|
|
|
- this.connectMQTT();
|
|
|
|
- },
|
|
|
|
- onLoad() {
|
|
|
|
|
|
+ beforeMount() {
|
|
console.log("子组件打印了");
|
|
console.log("子组件打印了");
|
|
if (!isWmpf) {
|
|
if (!isWmpf) {
|
|
this.getVoipDevices();
|
|
this.getVoipDevices();
|
|
@@ -463,10 +474,6 @@ export default {
|
|
clearInterval(this.autoPlayinterval);
|
|
clearInterval(this.autoPlayinterval);
|
|
clearInterval(this.inactivityTimer);
|
|
clearInterval(this.inactivityTimer);
|
|
},
|
|
},
|
|
- // onHide() {
|
|
|
|
- // if (this.mqttClient) this.mqttClient.end(true);
|
|
|
|
- // },
|
|
|
|
- onShareAppMessage() {},
|
|
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|