|
@@ -360,7 +360,7 @@
|
|
|
@click="breathShow = false"
|
|
|
></l-echart>
|
|
|
</view>
|
|
|
- <alarModel v-if="showModle" />
|
|
|
+ <alarModel v-if="showModle" ref="alarmModel" />
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
@@ -857,7 +857,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
- console.error("保存失败:", err);
|
|
|
uni.showToast({
|
|
|
title: "保存失败",
|
|
|
icon: "none",
|
|
@@ -866,7 +865,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
- console.error("导出失败:", err);
|
|
|
uni.showToast({
|
|
|
title: "导出失败",
|
|
|
icon: "none",
|
|
@@ -874,99 +872,6 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
- // 订阅mqtt实时点位
|
|
|
- connectMqtt() {
|
|
|
- this.mqttClienTwoFlag = false;
|
|
|
- if (this.mqttClienTwoFlag) {
|
|
|
- console.log("主题已订阅");
|
|
|
- return;
|
|
|
- }
|
|
|
- const THRESHOLD = 2;
|
|
|
- const params = {
|
|
|
- keepalive: 6000,
|
|
|
- clean: true,
|
|
|
- connectTimeout: 30 * 1000,
|
|
|
- clientId:
|
|
|
- "xcx_mqtt_data1" +
|
|
|
- this.clientIdProp +
|
|
|
- Date.now() +
|
|
|
- "_" +
|
|
|
- Math.random().toString(16).substring(2, 8),
|
|
|
- username: "lnradar",
|
|
|
- password: "lnradar",
|
|
|
- // 微信小程序特定配置
|
|
|
- wsOptions: {
|
|
|
- WebSocket: function (url) {
|
|
|
- return wx.connectSocket({
|
|
|
- url: url,
|
|
|
- header: {
|
|
|
- "content-type": "application/json",
|
|
|
- },
|
|
|
- protocols: ["mqtt"],
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
- let clientTwo = "";
|
|
|
- let selectedService = uni.getStorageSync("sercviceChoice");
|
|
|
- if (!selectedService || selectedService == "aloneServe") {
|
|
|
- if (__wxConfig.envVersion == "develop") {
|
|
|
- clientTwo = mqtt.connect(
|
|
|
- "wxs://data.radar-power.cn/mqtt/",
|
|
|
- params
|
|
|
- );
|
|
|
- }
|
|
|
- if (__wxConfig.envVersion == "trial") {
|
|
|
- clientTwo = mqtt.connect(
|
|
|
- "wxs://data.radar-power.cn/mqtt/",
|
|
|
- params
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- clientTwo = mqtt.connect("wxs://data.radar-power.cn/mqtt/", params);
|
|
|
- console.log("主题开始订阅5555");
|
|
|
- // 存储client引用以便后续操作
|
|
|
- this.mqttClientOne = clientTwo;
|
|
|
- clientTwo.on("connect", () => {
|
|
|
- console.log("MQTT_DATA连接成功");
|
|
|
- this.mqttClienTwoFlag = true;
|
|
|
- if (this.clientIdProp !== null) {
|
|
|
- clientTwo.subscribe(
|
|
|
- `/dev/${this.clientIdProp}/tracker_targets`,
|
|
|
- (err) => {
|
|
|
- if (err) {
|
|
|
- console.error("订阅clientId失败", err);
|
|
|
- } else {
|
|
|
- console.log(
|
|
|
- `成功订阅设备主题: /dev/${this.clientIdProp}/dsp_data`
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
- console.log(this.clientIdProp);
|
|
|
- });
|
|
|
- clientTwo.on("disconnect", () => {
|
|
|
- console.log("MQTT不在连接");
|
|
|
- });
|
|
|
- clientTwo.on("error", (err) => {
|
|
|
- this.mqttClienTwoFlag = false;
|
|
|
- setTimeout(() => {
|
|
|
- this.connectMqtt();
|
|
|
- }, 1000);
|
|
|
- });
|
|
|
-
|
|
|
- clientTwo.on("reconnect", () => {});
|
|
|
-
|
|
|
- clientTwo.on("close", () => {});
|
|
|
-
|
|
|
- clientTwo.on("message", (topic, message) => {
|
|
|
- // 处理点位消息
|
|
|
- if (this.clientIdProp !== null) {
|
|
|
- this.handleMessage(topic, message, this.clientIdProp);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
|
|
|
handleMessage(topic, message, clientId) {
|
|
|
// 清除不活动定时器
|
|
@@ -974,10 +879,6 @@ export default {
|
|
|
this.inactivityTimer = setTimeout(() => {
|
|
|
this.targetPoints = {};
|
|
|
}, 1500);
|
|
|
-
|
|
|
- console.log(topic, 99999);
|
|
|
- console.log(JSON.parse(message.toString()), "99999999");
|
|
|
-
|
|
|
// 验证topic格式
|
|
|
const match = topic.match(/^\/dev\/(.+)\/tracker_targets$/);
|
|
|
if (!match || match[1] !== clientId) return;
|
|
@@ -990,16 +891,11 @@ export default {
|
|
|
data.health.breath_rpm === 0
|
|
|
) {
|
|
|
this.receptHealth(Math.floor(data.health.breath_rpm));
|
|
|
- // this.$emit(
|
|
|
- // "sendHealth",
|
|
|
- // Math.floor(data.health.breath_rpm)
|
|
|
- // );
|
|
|
} else {
|
|
|
- // this.$emit("sendHealth", 0);
|
|
|
}
|
|
|
}
|
|
|
this.processTrackerData(data.tracker_targets);
|
|
|
- console.log(data.tracker_targets, "MQTT消息解析成功22222");
|
|
|
+ // console.log(data.tracker_targets, "MQTT消息解析成功22222");
|
|
|
} catch (e) {
|
|
|
console.error("MQTT消息解析失败", e);
|
|
|
}
|
|
@@ -1053,7 +949,6 @@ export default {
|
|
|
(item) => item !== null && item !== undefined
|
|
|
);
|
|
|
}
|
|
|
- console.log("当前目标点11111", this.targetPoints);
|
|
|
}
|
|
|
},
|
|
|
createNewTargetPoint(x, y, z, id) {
|
|
@@ -1094,7 +989,6 @@ export default {
|
|
|
if (this.mqttClientOne) {
|
|
|
this.mqttClientOne.end();
|
|
|
this.mqttClientOne = null;
|
|
|
- console.log("MQTT连接已断开");
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@@ -1102,7 +996,6 @@ export default {
|
|
|
this.clientIdProp = uni.getStorageSync("clientIDetail");
|
|
|
this.todayDate = this.$time(new Date(), 2);
|
|
|
this.showModle = true;
|
|
|
- console.log(this.showModle, "showModle");
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
const devItem = this.parseDeviceItem(options.devItem);
|
|
@@ -1114,13 +1007,16 @@ export default {
|
|
|
this.autoSwipe();
|
|
|
}, 3000);
|
|
|
this.getCurrentDate();
|
|
|
- // this.connectMqtt();
|
|
|
|
|
|
- console.log(clientId, "clientId88888");
|
|
|
this.mqttData = createMqttData(clientId);
|
|
|
|
|
|
if (this.mqttData) {
|
|
|
this.mqttData.on("message", (topic, message) => {
|
|
|
+ console.log("topic", topic, message);
|
|
|
+ const match = topic.match(/^\/dev\/(.+)\/tracker_targets$/);
|
|
|
+ if (!match || match[1] !== clientId) {
|
|
|
+ this.$refs.alarmModel.hanOtherMessage(topic, message);
|
|
|
+ }
|
|
|
this.handleMessage(topic, message, clientId);
|
|
|
});
|
|
|
}
|