|
@@ -264,7 +264,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <!-- <alarModel /> -->
|
|
|
+ <alarModel ref="alarModel" />
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
@@ -413,16 +413,15 @@ export default {
|
|
|
};
|
|
|
let client = "";
|
|
|
let selectedService = uni.getStorageSync("sercviceChoice");
|
|
|
- // if (!selectedService || selectedService == "aloneServe") {
|
|
|
- // client = mqtt.connect("wxs://radar-power.cn:8084/mqtt", params);
|
|
|
- // }
|
|
|
- client = mqtt.connect("wxs://radar-power.cn:8084/mqtt", params);
|
|
|
+ if (!selectedService || selectedService == "aloneServe") {
|
|
|
+ client = mqtt.connect("wxs://radar-power.cn:8084/mqtt", params);
|
|
|
+ }
|
|
|
// 存储client引用以便后续操作
|
|
|
this.mqttClient = client;
|
|
|
|
|
|
client.on("connect", () => {
|
|
|
console.log("MQTT连接成功");
|
|
|
- client.subscribe(`/mps/${clientId}/realtime_pos`, (err) => {
|
|
|
+ client.subscribe(`/dev/${clientId}/dsp_data`, (err) => {
|
|
|
if (err) {
|
|
|
console.error("订阅失败", err);
|
|
|
} else {
|
|
@@ -456,7 +455,7 @@ export default {
|
|
|
console.log("长时间没有点位,消除");
|
|
|
}, 1500);
|
|
|
|
|
|
- const match = topic.match(/^\/mps\/(.+)\/realtime_pos$/);
|
|
|
+ const match = topic.match(/^\/dev\/(.+)\/dsp_data$/);
|
|
|
if (!match) return;
|
|
|
|
|
|
const msgDevId = match[1];
|
|
@@ -465,7 +464,7 @@ export default {
|
|
|
try {
|
|
|
const data = JSON.parse(message.toString());
|
|
|
// console.log(data, 9999);
|
|
|
- const arr = data.targetPoints;
|
|
|
+ const arr = data.tracker_targets;
|
|
|
this.left = arr[0];
|
|
|
this.top = arr[1];
|
|
|
if (arr.length > 0) {
|
|
@@ -505,7 +504,17 @@ export default {
|
|
|
delete this.targetPoints[id];
|
|
|
}
|
|
|
});
|
|
|
- this.targetPoints = [...this.targetPoints];
|
|
|
+ let cleanPoints = JSON.parse(
|
|
|
+ JSON.stringify(this.targetPoints)
|
|
|
+ );
|
|
|
+ this.targetPoints = cleanPoints.filter(
|
|
|
+ (item) => item !== null
|
|
|
+ );
|
|
|
+ this.targetPoints = this.targetPoints.filter(
|
|
|
+ (item, index, self) =>
|
|
|
+ self.findIndex((i) => i.id === item.id) ===
|
|
|
+ index
|
|
|
+ );
|
|
|
console.log("🚀🚀🚀🚀targets", this.targetPoints);
|
|
|
} else {
|
|
|
this.targetPoints.forEach(
|
|
@@ -791,19 +800,23 @@ export default {
|
|
|
this.autoPlayinterval = setTimeout(() => {
|
|
|
this.autoSwipe();
|
|
|
}, 3000);
|
|
|
-
|
|
|
this.getCurrentDate();
|
|
|
},
|
|
|
onUnload() {
|
|
|
- if (this.mqttClient) this.mqttClient.end(true);
|
|
|
+ if (this.mqttClient) {
|
|
|
+ this.mqttClient.end();
|
|
|
+ }
|
|
|
clearInterval(this.autoPlayinterval);
|
|
|
clearInterval(this.inactivityTimer);
|
|
|
},
|
|
|
onHide() {
|
|
|
- if (this.mqttClient) this.mqttClient.end(true);
|
|
|
+ if (this.mqttClient) {
|
|
|
+ this.mqttClient.end();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ this.$refs.alarModel.connectMQTTwo();
|
|
|
},
|
|
|
- onShow() {},
|
|
|
- // onShareAppMessage() {},
|
|
|
};
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|