南昌市物联网技防平台-前端
zengh
2021-04-26 bf22f722969bb6a4a70921db8defd7817d2af25a
Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jfpt-Vue
1 files modified
45 ■■■■ changed files
src/page/index/logo.vue 45 ●●●● patch | view | raw | blame | history
src/page/index/logo.vue
@@ -354,28 +354,28 @@
    ...mapGetters(["website", "keyCollapse"]),
  },
  methods: {
    getData() {
    // getData() {
    //   var that = this;
    //   axios({
    //     url: "/api/blade-jfpts/alarm/alarm/getLimit",
    //     method: "get",
    //   }).then(function (response) {
    //     if (response.data.data.length > 0) {
    //       that.deviceId = response.data.data[0].id;
    //     } else {
    //       that.deviceId = 0;
    //     }
    //     //获得最新ID,开启实时报警循环
    //     that.layerRealtime();
    //   });
    // },
    layerRealtime(jid) {
      var that = this;
      axios({
        url: "/api/blade-jfpts/alarm/alarm/getLimit",
        method: "get",
      }).then(function (response) {
        if (response.data.data.length > 0) {
          that.deviceId = response.data.data[0].id;
        } else {
          that.deviceId = 0;
        }
        //获得最新ID,开启实时报警循环
        that.layerRealtime();
      });
    },
    layerRealtime() {
      var that = this;
      window.clearTimeout(window.realTimeQuery);
      // window.clearTimeout(window.realTimeQuery);
      // that.deviceId = 334; // 测试用
      window.realTimeQuery = setInterval(function () {
      // window.realTimeQuery = setInterval(function () {
        axios({
          url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + that.deviceId,
          url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + jid,
          method: "post",
        }).then(function (response) {
          var userId = JSON.parse(
@@ -383,7 +383,7 @@
          ).content.user_id;
          if (response.data.data.length > 0) {
            that.deviceId = response.data.data[0].id;
            // that.deviceId = response.data.data[0].id;
            that.form = response.data.data[0];
            if (
@@ -411,7 +411,7 @@
            }
          }
        });
      }, 5000);
      // }, 5000);
    },
    closeDialog() {
      //关闭窗口回调,关闭警报
@@ -814,7 +814,8 @@
        //window.socket = new WebSocket("ws://localhost:9034/websocket");
        window.socket.onmessage = function (event) {
          alert(event.data)
          // alert(event.data)
          that.layerRealtime(event.data);
        };
        window.socket.onopen = function (event) {};