钞小赢 2 vuotta sitten
vanhempi
commit
0321ad9228

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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

@@ -252,7 +252,7 @@
252
               <div class="wdDataShow">
252
               <div class="wdDataShow">
253
                 <div class="left">
253
                 <div class="left">
254
                   <img
254
                   <img
255
-                    src="../../../assets/images/bigScreen/tempImg.png"
255
+                    src="../../../assets/images/bigScreen/wendutj.png"
256
                     alt=""
256
                     alt=""
257
                     style="width: 100%; height: 100%"
257
                     style="width: 100%; height: 100%"
258
                   />
258
                   />
@@ -517,12 +517,14 @@
517
 <script>
517
 <script>
518
 import vueSeamlessScroll from "vue-seamless-scroll";
518
 import vueSeamlessScroll from "vue-seamless-scroll";
519
 import * as echarts from "echarts";
519
 import * as echarts from "echarts";
520
+import mqtt from 'mqtt'
520
 export default {
521
 export default {
521
   components: {
522
   components: {
522
     vueSeamlessScroll,
523
     vueSeamlessScroll,
523
   },
524
   },
524
   data() {
525
   data() {
525
     return {
526
     return {
527
+      client: {},
526
       //预警数据
528
       //预警数据
527
       yjData: [
529
       yjData: [
528
         {
530
         {
@@ -602,6 +604,84 @@ export default {
602
     },
604
     },
603
   },
605
   },
604
   methods: {
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
     tableRowClassName({ row, rowIndex }) {
685
     tableRowClassName({ row, rowIndex }) {
606
       if ((rowIndex + 1) % 2 === 0) {
686
       if ((rowIndex + 1) % 2 === 0) {
607
         return "jsrow";
687
         return "jsrow";
@@ -1225,7 +1305,7 @@ export default {
1225
           },
1305
           },
1226
           splitLine: {
1306
           splitLine: {
1227
             lineStyle: {
1307
             lineStyle: {
1228
-              color: "#40524f",
1308
+              color: "#011F13",
1229
             },
1309
             },
1230
           },
1310
           },
1231
         },
1311
         },
@@ -1241,7 +1321,7 @@ export default {
1241
           },
1321
           },
1242
           splitLine: {
1322
           splitLine: {
1243
             lineStyle: {
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
   created() {
1438
   created() {
1439
+    this.connect()
1359
     // let _this = this;
1440
     // let _this = this;
1360
     // setInterval(function () {
1441
     // setInterval(function () {
1361
     //   //用setInterval做动画感觉有问题
1442
     //   //用setInterval做动画感觉有问题
@@ -1369,6 +1450,9 @@ export default {
1369
       // this.drawSdtj();
1450
       // this.drawSdtj();
1370
     });
1451
     });
1371
   },
1452
   },
1453
+  destroyed(){
1454
+    this.unconnect()
1455
+  },
1372
   mounted() {
1456
   mounted() {
1373
     // this.$nextTick(() => {
1457
     // this.$nextTick(() => {
1374
     //   this.drawWsdbh();
1458
     //   this.drawWsdbh();
@@ -1592,9 +1676,11 @@ export default {
1592
                 flex-direction: row;
1676
                 flex-direction: row;
1593
                 flex: 1;
1677
                 flex: 1;
1594
                 .normal {
1678
                 .normal {
1679
+                  font-size:12px;
1595
                   margin-right: 5px;
1680
                   margin-right: 5px;
1596
                   width: 100px;
1681
                   width: 100px;
1597
                   height: 20px;
1682
                   height: 20px;
1683
+                  line-height: 22px;
1598
                   background: url("../../../assets/images/bigScreen/1.png")
1684
                   background: url("../../../assets/images/bigScreen/1.png")
1599
                     no-repeat;
1685
                     no-repeat;
1600
                   background-size: 100%;
1686
                   background-size: 100%;
@@ -1607,10 +1693,12 @@ export default {
1607
                 justify-content: center;
1693
                 justify-content: center;
1608
 
1694
 
1609
                 .hitch {
1695
                 .hitch {
1696
+                  font-size:12px;
1610
                   margin-right: 5px;
1697
                   margin-right: 5px;
1611
                   text-align: center;
1698
                   text-align: center;
1612
                   width: 100px;
1699
                   width: 100px;
1613
                   height: 20px;
1700
                   height: 20px;
1701
+                  line-height:22px;
1614
                   background: url("../../../assets/images/bigScreen/2.png")
1702
                   background: url("../../../assets/images/bigScreen/2.png")
1615
                     no-repeat;
1703
                     no-repeat;
1616
                   background-size: 100%;
1704
                   background-size: 100%;
@@ -1765,7 +1853,7 @@ export default {
1765
   overflow: hidden;
1853
   overflow: hidden;
1766
 }
1854
 }
1767
 #yjxxScroll {
1855
 #yjxxScroll {
1768
-  height: 150px;
1856
+  height: 140px;
1769
   overflow: hidden;
1857
   overflow: hidden;
1770
 }
1858
 }
1771
 </style>
1859
 </style>