zhaobao 1 年之前
父节点
当前提交
498c0d4085
共有 3 个文件被更改,包括 17 次插入27 次删除
  1. 10 10
      src/mixin/mqtt.js
  2. 1 4
      src/views/bigScreen/home/components/SensorWarningInfo.vue
  3. 6 13
      src/views/bigScreen/home/index.vue

+ 10 - 10
src/mixin/mqtt.js

@@ -1,6 +1,7 @@
 
 
 import { mqttUrl } from '@/settings'
 import { mqttUrl } from '@/settings'
 import mqtt from 'mqtt'
 import mqtt from 'mqtt'
+import { mapGetters } from 'vuex'
 export default {
 export default {
   destroyed() {
   destroyed() {
     if (this.client.connected) {
     if (this.client.connected) {
@@ -13,6 +14,11 @@ export default {
       }
       }
     }
     }
   },
   },
+  computed: {
+    ...mapGetters([
+      'userData'
+    ])
+  },
   methods: {
   methods: {
     initMqtt(
     initMqtt(
       params = {
       params = {
@@ -34,19 +40,13 @@ export default {
         }
         }
       }
       }
       const client = mqtt.connect(mqttUrl, options)
       const client = mqtt.connect(mqttUrl, options)
+      const subscribes = [`topic/iotplatform/update/all/${this.userData.ocId}`]
       client.on('connect', function() {
       client.on('connect', function() {
-        client.subscribe('topic/goaf/waring/person', function(err) {
-          if (!err) {
-            client.publish('topic/goaf/waring/person', 'Hello mqtt')
-          } else {
-            client.publish('topic/goaf/waring/person', 'Hello mqtt err')
-          }
-        })
-        client.subscribe('topic/goaf/waring/sensor', function(err) {
+        client.subscribe(subscribes, function(err) {
           if (!err) {
           if (!err) {
-            client.publish('topic/goaf/waring/sensor', 'Hello mqtt')
+            client.publish('topic/iotplatform/update/all', 'Hello mqtt')
           } else {
           } else {
-            client.publish('topic/goaf/waring/sensor', 'Hello mqtt err')
+            client.publish('topic/iotplatform/update/all', 'Hello mqtt err')
           }
           }
         })
         })
       })
       })

+ 1 - 4
src/views/bigScreen/home/components/SensorWarningInfo.vue

@@ -55,9 +55,6 @@ export default {
       total: 0
       total: 0
     }
     }
   },
   },
-  created() {
-    this.load()
-  },
   methods: {
   methods: {
     dangerStatus(val) {
     dangerStatus(val) {
       const status = ['待提交', '待评审', '待整改', '待验收', '完成']
       const status = ['待提交', '待评审', '待整改', '待验收', '完成']
@@ -67,7 +64,7 @@ export default {
       const obj = { 0: '一般', 1: '重大' }
       const obj = { 0: '一般', 1: '重大' }
       return obj[val] || '--'
       return obj[val] || '--'
     },
     },
-    load() {
+    loadData() {
       getSensorOverview().then((res) => {
       getSensorOverview().then((res) => {
         const { data } = res
         const { data } = res
         let tableData = []
         let tableData = []

+ 6 - 13
src/views/bigScreen/home/index.vue

@@ -63,6 +63,9 @@ export default {
           this.$refs['device-info'].loadData(data)
           this.$refs['device-info'].loadData(data)
         })
         })
       })
       })
+      this.$nextTick(() => {
+        this.$refs['sensor-warning-info'].loadData()
+      })
     },
     },
     initChart() {
     initChart() {
       /** 更新chart */
       /** 更新chart */
@@ -76,19 +79,9 @@ export default {
       }
       }
       const data = message ? JSON.parse(Uint8ArrayToString(message)) : ''
       const data = message ? JSON.parse(Uint8ArrayToString(message)) : ''
       this.$nextTick(() => {
       this.$nextTick(() => {
-        if (topic.includes('topic/goaf/waring/person')) {
-          this.$refs['check-warn-report'].load()
-        } else if (topic.includes('topic/goaf/waring/sensor')) {
-          this.$refs['sensor-warning-info'].load()
-        } else if (topic.includes('topic/goaf/fill/scale')) {
-          this.$refs.map.updateMapLayers(data.mapId)
-        } else if (topic.includes('topic/goaf/waring/camera')) {
-                    this.$refs['sensor-info-statistics']?.warn(data)
-        }
-        if (data.topictype === 'add') {
-          this.$refs.map.updateLayerState(data.layerId)
-        } else if (data.topictype === 'completed') {
-          this.$refs.map.updateLayerState(data.layerId, -1)
+        if (topic.includes('topic/iotplatform/update/all')) {
+          console.log(data)
+          this.init()
         }
         }
       })
       })
     }
     }