liuyg
2021-04-26 7c4b47852e921718259c3e27421f44f8d2edb7fc
src/page/index/logo.vue
@@ -347,71 +347,52 @@
    };
  },
  created() {
    // this.getData();
    this.websocketStart();
  },
  computed: {
    ...mapGetters(["website", "keyCollapse"]),
  },
  methods: {
    getData() {
    layerRealtime(jid) {
      var that = this;
      axios({
        url: "/api/blade-jfpts/alarm/alarm/getLimit",
        url: "/api/blade-jfpts/alarm/alarm/page",
        method: "get",
        params: {
          id: jid,
        },
      }).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);
      // that.deviceId = 334; // 测试用
      window.realTimeQuery = setInterval(function () {
        axios({
          url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + that.deviceId,
          method: "post",
        }).then(function (response) {
          var userId = JSON.parse(
            window.localStorage.getItem("物联网安保云服务平台-userInfo")
          ).content.user_id;
        var userId = JSON.parse(
          window.localStorage.getItem("物联网安保云服务平台-userInfo")
        ).content.user_id;
          if (response.data.data.length > 0) {
            that.deviceId = response.data.data[0].id;
            that.form = response.data.data[0];
        if (response.data.data.records.length > 0) {
          that.form = response.data.data.records[0];
          if (
            response.data.data.records[0].waringType == "紧急求救" &&
            response.data.data.records[0].alarmId == userId
          ) {
            response.data.data.records[0].waringType = "一键求助";
            if (
              response.data.data[0].waringType == "紧急求救" &&
              response.data.data[0].alarmId == userId
            ) {
              response.data.data[0].waringType = "一键求助";
            that.peopleList = [
              { label: that.form.oneContacts, value: that.form.onePhone },
              { label: that.form.twoContacts, value: that.form.twoPhone },
              { label: that.form.threeContacts, value: that.form.threePhone },
            ];
            that.peopleName = that.form.oneContacts;
            that.peoplePhone = that.form.onePhone;
            that.dialogTableVisible = true;
              that.peopleList = [
                { label: that.form.oneContacts, value: that.form.onePhone },
                { label: that.form.twoContacts, value: that.form.twoPhone },
                { label: that.form.threeContacts, value: that.form.threePhone },
              ];
              that.peopleName = that.form.oneContacts;
              that.peoplePhone = that.form.onePhone;
              that.dialogTableVisible = true;
            that.ofX = null;
            that.ofY = null;
              that.ofX = null;
              that.ofY = null;
            window.addEventListener("mousemove", that.handleMousemove);
              window.addEventListener("mousemove", that.handleMousemove);
              that.$refs.realAudio.src = "./realVideo/audio.mp3";
              that.$refs.realAudio.play();
            }
            that.$refs.realAudio.src = "./realVideo/audio.mp3";
            that.$refs.realAudio.play();
          }
        });
      }, 5000);
        }
      });
    },
    closeDialog() {
      //关闭窗口回调,关闭警报
@@ -756,7 +737,6 @@
              jid: that.form.id,
            },
          }).then((resdata) => {
            console.log(resdata);
          });
          newCallAxios
@@ -811,9 +791,12 @@
        window.socket = new WebSocket("wss://web.byisf.com/wss/websocket/");
        //http
        // window.socket = new WebSocket("ws://localhost:9034/websocket");
        //window.socket = new WebSocket("ws://localhost:9034/websocket");
        window.socket.onmessage = function (event) {};
        window.socket.onmessage = function (event) {
          // alert(event.data)
          that.layerRealtime(event.data);
        };
        window.socket.onopen = function (event) {};