|
@@ -55,6 +55,7 @@ import {
|
|
|
isWmpf,
|
|
|
} from "../../const.js";
|
|
|
import { AsyncValue } from "../../utils";
|
|
|
+import { onLoad } from "@dcloudio/uni-app";
|
|
|
|
|
|
const wmpfVoip = requirePlugin("wmpf-voip").default;
|
|
|
const envVersion = wx.getAccountInfoSync().miniProgram.envVersion;
|
|
@@ -74,9 +75,12 @@ const getEnvVersionForVoip = (function () {
|
|
|
})();
|
|
|
|
|
|
export default {
|
|
|
+ comments: {
|
|
|
+ name: "alarModel",
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- alarmModel: false,
|
|
|
+ alarmModel: true,
|
|
|
nowTime: "2025-06-20 10:30:00",
|
|
|
devName: "我的第一台设备",
|
|
|
localPhone: "13888888888",
|
|
@@ -374,7 +378,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- connectMQTT(clientId, devId) {
|
|
|
+ connectMQTT() {
|
|
|
const THRESHOLD = 2;
|
|
|
const params = {
|
|
|
keepalive: 60,
|
|
@@ -407,16 +411,14 @@ export default {
|
|
|
this.mqttClient = client;
|
|
|
client.on("connect", () => {
|
|
|
console.log("MQTT连接成功");
|
|
|
- client.subscribe(
|
|
|
- `/mps/wx_${uni.setStorageSync("userId")}/notice`,
|
|
|
- (err) => {
|
|
|
- if (err) {
|
|
|
- console.error("订阅失败", err);
|
|
|
- } else {
|
|
|
- console.log(`成功订阅设备主题: device/${clientId}`);
|
|
|
- }
|
|
|
+ let userId = uni.getStorageSync("userId");
|
|
|
+ client.subscribe(`/mps/wx_${userId}/notice`, (err) => {
|
|
|
+ if (err) {
|
|
|
+ console.error("订阅失败", err);
|
|
|
+ } else {
|
|
|
+ console.log(`成功订阅设备主题: device/${clientId}`);
|
|
|
}
|
|
|
- );
|
|
|
+ });
|
|
|
});
|
|
|
client.on("disconnect", () => {
|
|
|
console.log("MQTT不在连接");
|
|
@@ -442,20 +444,28 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
},
|
|
|
- onLoad(options) {
|
|
|
+ attached() {
|
|
|
+ console.log("子组件打印了");
|
|
|
if (!isWmpf) {
|
|
|
this.getVoipDevices();
|
|
|
}
|
|
|
this.connectMQTT();
|
|
|
},
|
|
|
- onUnload() {
|
|
|
- if (this.mqttClient) this.mqttClient.end(true);
|
|
|
- clearInterval(this.autoPlayinterval);
|
|
|
- clearInterval(this.inactivityTimer);
|
|
|
+ onLoad() {
|
|
|
+ console.log("子组件打印了");
|
|
|
+ if (!isWmpf) {
|
|
|
+ this.getVoipDevices();
|
|
|
+ }
|
|
|
+ this.connectMQTT();
|
|
|
},
|
|
|
onHide() {
|
|
|
if (this.mqttClient) this.mqttClient.end(true);
|
|
|
+ clearInterval(this.autoPlayinterval);
|
|
|
+ clearInterval(this.inactivityTimer);
|
|
|
},
|
|
|
+ // onHide() {
|
|
|
+ // if (this.mqttClient) this.mqttClient.end(true);
|
|
|
+ // },
|
|
|
onShareAppMessage() {},
|
|
|
};
|
|
|
</script>
|