|
@@ -637,8 +637,6 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
- console.log("alarModel mounted111111");
|
|
|
-
|
|
|
const userId = uni.getStorageSync("userId");
|
|
|
const topic = `/mps/wx_${userId}/notice`;
|
|
|
this.unsubscribeFnNotice = MqttService.subscribe(
|
|
@@ -676,14 +674,53 @@ export default {
|
|
|
console.log("处理后的 CMD 数据:", data);
|
|
|
},
|
|
|
(err) => {
|
|
|
- if (!err) console.log(`✅ 页面B 已订阅 ${topic}`);
|
|
|
+ if (!err) console.log(`✅ 页面组件 已订阅 ${topic}`);
|
|
|
}
|
|
|
);
|
|
|
+
|
|
|
+ uni.$on("mqttDataReadyOnce", (client) => {
|
|
|
+ this.unsubscribeFnNotice = MqttService.subscribe(
|
|
|
+ "DATA",
|
|
|
+ topic,
|
|
|
+ (message, msgTopic) => {
|
|
|
+ console.log(`接收到 ${msgTopic} 消息:`, message);
|
|
|
+ // 处理消息
|
|
|
+ const data = JSON.parse(message);
|
|
|
+ let userId = uni.getStorageSync("userId");
|
|
|
+ const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
|
|
|
+ const match = topic.match(noticeMatch);
|
|
|
+ if (!match) return;
|
|
|
+ // 更新页面数据
|
|
|
+ this.alarmModel = true;
|
|
|
+ this.clientId = data.clientId;
|
|
|
+ this.devName = data.devName;
|
|
|
+ this.sn = data.clientId;
|
|
|
+ this.eventListId = data.eventListId;
|
|
|
+ // VOIP 相关逻辑
|
|
|
+ this.getVoipAuthor(this.clientId, userId);
|
|
|
+ // 格式化时间
|
|
|
+ const now = new Date();
|
|
|
+ this.nowTime = `${now.getFullYear()}-${String(
|
|
|
+ now.getMonth() + 1
|
|
|
+ ).padStart(2, "0")}-${String(now.getDate()).padStart(
|
|
|
+ 2,
|
|
|
+ "0"
|
|
|
+ )} ${String(now.getHours()).padStart(2, "0")}:${String(
|
|
|
+ now.getMinutes()
|
|
|
+ ).padStart(2, "0")}`;
|
|
|
+ if (!isWmpf) {
|
|
|
+ this.getVoipDevices();
|
|
|
+ }
|
|
|
+ console.log("处理后的 CMD 数据:", data);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ if (!err) console.log(`✅ 页面组件 已订阅 ${topic}`);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
beforeDestroy() {
|
|
|
- console.log("alarModel mounted22222");
|
|
|
-
|
|
|
if (this.unsubscribeFnNotice) {
|
|
|
this.unsubscribeFnNotice();
|
|
|
this.unsubscribeFnNotice = null;
|