南昌市物联网技防平台-前端
shuishen
2021-03-25 10f7b6b5751b63df9822ecd8a075cc8747c3b07e
还原
1 files modified
64 ■■■■■ changed files
src/page/index/logo.vue 64 ●●●●● patch | view | raw | blame | history
src/page/index/logo.vue
@@ -261,7 +261,7 @@
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import axios from "axios";
@@ -276,8 +276,6 @@
      videoConversationReal: false,
      oldVideoSatart: false,
      deviceId: null,
      userId: null,
      socket: null,
      form: {},
      itemOption: {
        menuBtn: false,
@@ -340,10 +338,6 @@
    };
  },
  created() {
    this.userId = JSON.parse(
      window.localStorage.getItem("物联网安保云服务平台-userInfo")
    ).content.user_id;
    this.getData();
  },
  computed: {
@@ -353,46 +347,33 @@
    getData() {
      var that = this;
      if (!window.WebSocket) {
        window.WebSocket = window.MozWebSocket;
      }
      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连接没有建立成功!!");
      }
      setTimeout(function () {
        if(!window.WebSocket){
          return;
        }
        if(window.socket.readyState == WebSocket.OPEN){
          window.socket.send(that.userId);
        }else{
          console.log("WebSocket连接没有建立成功!!");
        }
      }, 2000);
      setTimeout(function () {
      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 () {
        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;
          if (response.data.data.length > 0) {
            that.deviceId = response.data.data[0].id;
            if (
              response.data.data[0].waringType == "紧急求救" &&
              response.data.data[0].alarmId == that.userId
              response.data.data[0].alarmId == userId
            ) {
              response.data.data[0].waringType = "一键求助";
              that.form = response.data.data[0];
@@ -405,7 +386,6 @@
              that.peoplePhone = that.form.onePhone;
              that.dialogTableVisible = true;
              Recorder.getPermiRecorderssion().then(() => {});
              that.ofX = null;
              that.ofY = null;
@@ -786,7 +766,7 @@
  },
};
</script>
<style lang="scss">
.fade-leave-active {
  transition: opacity 0.2s;
@@ -903,4 +883,4 @@
  height: calc(100% - 44px);
  box-sizing: border-box;
}
</style>
</style>