南昌市物联网技防平台-前端
shuishen
2021-03-24 ce4c7144dd232a001606c099be5823d95d89f88c
Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jfpt-Vue
2 files modified
46 ■■■■■ changed files
src/page/index/logo.vue 40 ●●●●● patch | view | raw | blame | history
src/page/index/top/index.vue 6 ●●●● patch | view | raw | blame | history
src/page/index/logo.vue
@@ -372,27 +372,33 @@
        if (!window.WebSocket) {
          return;
        }
        if (that.socket.readyState == WebSocket.OPEN) {
          that.socket.send(that.userId);
        if (window.WebSocket) {
          window.socket = new WebSocket("ws://36.134.81.48:9034/websocket");
          window.socket.onmessage = function (event) {
          };
          window.socket.onopen = function (event) {
          };
          window.socket.onclose = function (event) {
          };
        } else {
          console.log("WebSocket连接没有建立成功!!");
        }
      }, 4000);
      axios({
        url: "/api/blade-jfpts/alarm/alarm/getLimit",
        method: "get",
      }).then(function (response) {
        that.deviceId = response.data.data[0].id;
        //获得最新ID,开启实时报警循环
        that.layerRealtime();
      });
    },
    layerRealtime() {
      var that = this;
      window.clearTimeout(window.realTimeQuery);
      // that.deviceId = 334; // 测试用
      window.realTimeQuery = setInterval(function () {
        setTimeout(function () {
          if(!window.WebSocket){
            return;
          }
          if(window.socket.readyState == WebSocket.OPEN){
            window.socket.send(that.userId);
          }else{
            console.log("WebSocket连接没有建立成功!!");
          }
        }, 2000);
        axios({
          url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + that.deviceId,
          method: "post",
src/page/index/top/index.vue
@@ -19,7 +19,7 @@
      </span>
    </div>
    <div class="top-bar__right">
      <img src="/img/ydlg.png" style="height: 44px; vertical-align: middle;" alt="">
      <el-tooltip v-if="showColor"
                  effect="dark"
@@ -170,6 +170,10 @@
          cancelButtonText: this.$t("cancelText"),
          type: "warning"
        }).then(() => {
          //关闭webSocket
          window.socket.close();
          this.$store.dispatch("LogOut").then(() => {
            resetRouter();
            this.$router.push({path: "/login"});