钞小赢 %!s(int64=2) %!d(string=hai) anos
pai
achega
0321ad9228

BIN=BIN
src/assets/images/bigScreen/1.png


BIN=BIN
src/assets/images/bigScreen/2.png


BIN=BIN
src/assets/images/bigScreen/cangwen.png


src/assets/images/bigScreen/icon6cwsd.png → src/assets/images/bigScreen/cnw.png


BIN=BIN
src/assets/images/bigScreen/fault.png


BIN=BIN
src/assets/images/bigScreen/huanxing.png


BIN=BIN
src/assets/images/bigScreen/ludian.png


BIN=BIN
src/assets/images/bigScreen/noNormal.png


BIN=BIN
src/assets/images/bigScreen/shanxing.png


BIN=BIN
src/assets/images/bigScreen/shidu.png


BIN=BIN
src/assets/images/bigScreen/tempBorder.png


src/assets/images/bigScreen/2湿度统计外框.png → src/assets/images/bigScreen/tempImg.png


BIN=BIN
src/assets/images/bigScreen/waiwen.png


BIN=BIN
src/assets/images/bigScreen/wendutj.png


src/assets/images/bigScreen/icon4温.png → src/assets/images/bigScreen/wsdbh.png


BIN=BIN
src/assets/images/bigScreen/wsdsb.png


BIN=BIN
src/assets/images/bigScreen/xiaomai.png


BIN=BIN
src/assets/images/bigScreen/组69.png


+ 92 - 4
src/views/system/visualized/index.vue

@@ -252,7 +252,7 @@
252 252
               <div class="wdDataShow">
253 253
                 <div class="left">
254 254
                   <img
255
-                    src="../../../assets/images/bigScreen/tempImg.png"
255
+                    src="../../../assets/images/bigScreen/wendutj.png"
256 256
                     alt=""
257 257
                     style="width: 100%; height: 100%"
258 258
                   />
@@ -517,12 +517,14 @@
517 517
 <script>
518 518
 import vueSeamlessScroll from "vue-seamless-scroll";
519 519
 import * as echarts from "echarts";
520
+import mqtt from 'mqtt'
520 521
 export default {
521 522
   components: {
522 523
     vueSeamlessScroll,
523 524
   },
524 525
   data() {
525 526
     return {
527
+      client: {},
526 528
       //预警数据
527 529
       yjData: [
528 530
         {
@@ -602,6 +604,84 @@ export default {
602 604
     },
603 605
   },
604 606
   methods: {
607
+    connect() {
608
+      let options = {
609
+        username: "admin",
610
+        password: "public",
611
+        cleanSession : true,
612
+        keepAlive:60,
613
+        clientId: 'mqttjs_'+ Math.random().toString(16).substr(2, 8),
614
+        connectTimeout: 4000
615
+      }
616
+      this.client = mqtt.connect('ws://192.168.50.169:1883/mqtt',options);
617
+      this.client.on("connect", (e)=>{
618
+        console.log("成功连接服务器2222222:",e);
619
+        //订阅三个名叫'top/#', 'three/#'和'#'的主题
620
+        this.client.subscribe(['topic/X1XXXQ2206090069/DPUT/upload'], { qos: 1 }, (err)=> {
621
+          if (!err) {
622
+            console.log("订阅成功");
623
+            //向主题叫“pubtop”发布一则内容为'hello,this is a nice day!'的消息
624
+            this.publish("pubtop", 'hello,this is a nice day!')
625
+          } else {
626
+            console.log('消息订阅失败!')
627
+          }
628
+        });
629
+      });
630
+      //重新连接
631
+      this.reconnect()
632
+      //是否已经断开连接
633
+      this.mqttError()
634
+      //监听获取信息
635
+      this.getMessage()
636
+    },
637
+//发布消息@topic主题  @message发布内容
638
+    publish(topic,message) {
639
+      if (!this.client.connected) {
640
+        console.log('客户端未连接')
641
+        return
642
+      }
643
+      this.client.publish(topic,message,{qos: 1},(err) => {
644
+        if(!err) {
645
+          console.log('主题为'+topic+ "发布成功")
646
+        }
647
+      })
648
+    },
649
+//监听接收消息
650
+    getMessage() {
651
+      this.client.on("message", (topic, message) => {
652
+        if(message) {
653
+          console.log('收到来着',topic,'的信息',message.toString())
654
+          const res = JSON.parse(message.toString())
655
+          this.runData=res.data
656
+          console.log(res, 'res',this.runData,'runData')
657
+      
658
+        }
659
+      });
660
+    },
661
+//监听服务器是否连接失败
662
+    mqttError() {
663
+      this.client.on('error',(error) => {
664
+        console.log('连接失败:',error)
665
+        this.client.end()
666
+      })
667
+    },
668
+    unsubscribe() {
669
+      this.client.unsubscribe(this.mtopic, (error)=> {
670
+        console.log('主题为'+ this.mtopic+'取消订阅成功',error)
671
+      })
672
+    },
673
+//断开连接
674
+    unconnect() {
675
+      this.client.end()
676
+      this.client = null
677
+      console.log('服务器已断开连接!')
678
+    },
679
+//监听服务器重新连接
680
+    reconnect() {
681
+      this.client.on('reconnect', (error) => {
682
+          console.log('正在重连:', error)
683
+      });
684
+    },
605 685
     tableRowClassName({ row, rowIndex }) {
606 686
       if ((rowIndex + 1) % 2 === 0) {
607 687
         return "jsrow";
@@ -1225,7 +1305,7 @@ export default {
1225 1305
           },
1226 1306
           splitLine: {
1227 1307
             lineStyle: {
1228
-              color: "#40524f",
1308
+              color: "#011F13",
1229 1309
             },
1230 1310
           },
1231 1311
         },
@@ -1241,7 +1321,7 @@ export default {
1241 1321
           },
1242 1322
           splitLine: {
1243 1323
             lineStyle: {
1244
-              color: "#40524f",
1324
+              color: "#011F13",
1245 1325
             },
1246 1326
           },
1247 1327
         },
@@ -1356,6 +1436,7 @@ export default {
1356 1436
     },
1357 1437
   },
1358 1438
   created() {
1439
+    this.connect()
1359 1440
     // let _this = this;
1360 1441
     // setInterval(function () {
1361 1442
     //   //用setInterval做动画感觉有问题
@@ -1369,6 +1450,9 @@ export default {
1369 1450
       // this.drawSdtj();
1370 1451
     });
1371 1452
   },
1453
+  destroyed(){
1454
+    this.unconnect()
1455
+  },
1372 1456
   mounted() {
1373 1457
     // this.$nextTick(() => {
1374 1458
     //   this.drawWsdbh();
@@ -1592,9 +1676,11 @@ export default {
1592 1676
                 flex-direction: row;
1593 1677
                 flex: 1;
1594 1678
                 .normal {
1679
+                  font-size:12px;
1595 1680
                   margin-right: 5px;
1596 1681
                   width: 100px;
1597 1682
                   height: 20px;
1683
+                  line-height: 22px;
1598 1684
                   background: url("../../../assets/images/bigScreen/1.png")
1599 1685
                     no-repeat;
1600 1686
                   background-size: 100%;
@@ -1607,10 +1693,12 @@ export default {
1607 1693
                 justify-content: center;
1608 1694
 
1609 1695
                 .hitch {
1696
+                  font-size:12px;
1610 1697
                   margin-right: 5px;
1611 1698
                   text-align: center;
1612 1699
                   width: 100px;
1613 1700
                   height: 20px;
1701
+                  line-height:22px;
1614 1702
                   background: url("../../../assets/images/bigScreen/2.png")
1615 1703
                     no-repeat;
1616 1704
                   background-size: 100%;
@@ -1765,7 +1853,7 @@ export default {
1765 1853
   overflow: hidden;
1766 1854
 }
1767 1855
 #yjxxScroll {
1768
-  height: 150px;
1856
+  height: 140px;
1769 1857
   overflow: hidden;
1770 1858
 }
1771 1859
 </style>