From fe9be2557c00090bc3074a378907d59c19ffe455 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 25 Mar 2021 15:02:20 +0800
Subject: [PATCH] Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jfpt-Vue
---
src/page/index/logo.vue | 64 +++++++++++++++++++++++++++++--
1 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/src/page/index/logo.vue b/src/page/index/logo.vue
index d8dbed0..666cccb 100644
--- a/src/page/index/logo.vue
+++ b/src/page/index/logo.vue
@@ -262,7 +262,7 @@
</div>
</div>
</template>
-
+
<script>
import { mapGetters } from "vuex";
import axios from "axios";
@@ -339,7 +339,8 @@
};
},
created() {
- this.getData();
+ //this.getData();
+ this.websocketStart();
},
computed: {
...mapGetters(["website", "keyCollapse"]),
@@ -347,7 +348,6 @@
methods: {
getData() {
var that = this;
-
axios({
url: "/api/blade-jfpts/alarm/alarm/getLimit",
method: "get",
@@ -764,10 +764,64 @@
this.ofX = e.offsetX;
this.ofY = e.offsetY;
},
+
+ //启动websocket
+ websocketStart(){
+ if (!window.WebSocket) {
+ window.WebSocket = window.MozWebSocket;
+ }
+ if (window.WebSocket) {
+ //https
+ //window.socket = new WebSocket("wss://web.byisf.com/wss/websocket/");
+
+ //http
+ window.socket = new WebSocket("ws://localhost:9034/websocket");
+
+ window.socket.onmessage = function (event) {
+ };
+
+ window.socket.onopen = function (event) {
+ };
+
+ window.socket.onclose = function (event) {
+ };
+ } else {
+ console.log("WebSocket连接没有建立成功!!");
+ }
+
+ setTimeout(function () {
+
+ window.clearTimeout(window.websockPing);
+
+ if(!window.WebSocket){
+ return;
+ }
+ if(window.socket.readyState == WebSocket.OPEN){
+
+ var userId = JSON.parse(
+ window.localStorage.getItem("物联网安保云服务平台-userInfo")
+ ).content.user_id;
+
+ window.socket.send(userId);
+
+ //开启心跳传送
+ window.websockPing = setInterval(function () {
+ window.socket.send("ping");
+ },20000);
+
+
+ }else{
+ console.log("WebSocket连接没有建立成功!!");
+ }
+ }, 2000);
+
+
+
+ },
},
};
</script>
-
+
<style lang="scss">
.fade-leave-active {
transition: opacity 0.2s;
@@ -884,4 +938,4 @@
height: calc(100% - 44px);
box-sizing: border-box;
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3