南昌市物联网技防平台-前端
zengh
2023-01-16 8aa3edd56c279100c9053576f3e90fa55459fe77
src/page/index/logo.vue
@@ -2,7 +2,8 @@
  <div class="avue-logo">
    <transition name="fade">
      <span v-if="keyCollapse" class="avue-logo_subtitle" key="0">
        {{ website.logo }}
<!--        {{ website.logo }}-->
        <i class="icon-anbao"></i>
      </span>
    </transition>
    <transition-group name="fade">
@@ -20,7 +21,7 @@
        :append-to-body="true"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
        @opened="videoConversationReal = true"
        @opened="onDialogTableVisible"
        @close="closeDialog"
      >
        <el-form
@@ -193,7 +194,7 @@
              <el-form-item>
                <el-button
                  type="success"
                  @click.stop="updateJtyep(form, 1, '办结')"
                  @click.stop="updateJtyep(form, 2, '办结')"
                  >办结
                </el-button>
@@ -347,102 +348,58 @@
    };
  },
  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) {
        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;
        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 == userId
            ) {
              response.data.data[0].waringType = "一键求助";
              that.form = response.data.data[0];
              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;
              // Recorder.getPermiRecorderssion().then(() => {});
        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 = "一键求助";
              newAxios
                .post(
                  "/api_control",
                  {},
                  {
                    params: {
                      param: JSON.stringify({ PktType: "GetAccessToken" }),
                    },
                  }
                )
                .then((res) => {
                  newAxios
                    .get(
                      `https://web.byisf.com:18000/GetPlayUrl?deviceCode=${that.form.serialNumber}&chl=${that.form.channelNumber}`
                    )
                    .then((result) => {
                      axios({
                        method: "post",
                        url: `/api/blade-jfpts/rvideo/rVoid`,
                        timeout: 600000,
                        params: {
                            sourcePath: result.data.data.flv,
                            jid: that.form.id,
                        },
                      }).then((resdata) => {
                      });
                    });
                });
            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() {
      //关闭窗口回调,关闭警报
      this.videoConversationReal = false;
      this.oldVideoSatart = false;
    },
    getDate() {
      // 当前时间
      var timestamp = Date.parse(new Date());
@@ -573,10 +530,22 @@
        .then(function () {
          that.dialogTableVisible = false;
          that.$router.push({
            path: "/policeTracking/track",
            query: that.form,
          });
          axios({
            method: "post",
            url: `/api/blade-jfpts/rvideo/stop`,
            params: {
              jid: row.id,
            },
          }).then((resdata) => {});
          if (t == "办结") {
            location.reload();
          } else {
            that.$router.push({
              path: "/policeTracking/track",
              query: that.form,
            });
          }
        });
    },
    beginTimeOrEndTime(time) {
@@ -703,6 +672,7 @@
    },
    aKeyToCall() {
      this.isActive = true;
      var that = this;
      if (this.recorder == null) {
        this.recorder = new Recorder({
@@ -712,7 +682,6 @@
          // compiling: false,(0.x版本中生效,1.x增加中)  // 是否边录边转换,默认是false
        });
      }
      this.isActive = true;
      // 一键呼叫相关函数
      that.recorder.start().then(
@@ -728,6 +697,7 @@
    // 序列号后期待修改
    aKeyStopCall() {
      this.isActive = false;
      var newCallAxios = axios.create({
        baseURL: "https://web.byisf.com:18000",
        withCredentials: false,
@@ -735,8 +705,8 @@
          "Content-Type": "application/json;",
        },
      });
      var that = this;
      that.isActive = false;
      newCallAxios
        .post(
@@ -750,11 +720,30 @@
        )
        .then((result) => {
          var formData = new FormData();
          // that.recorder.downloadWAV("新文件");
          var blob = that.recorder.getPCMBlob(); //获取pcm格式音频数据
          //此处获取到blob对象后需要设置fileName满足当前项目上传需求,其它项目可直接传把blob作为file塞入formData
          var newbolb = new Blob([blob], { type: "audio/pcm" });
          var fileOfBlob = new File([newbolb], new Date().getTime() + ".pcm");
          formData.append("file", fileOfBlob);
          var wavBlob = that.recorder.getWAVBlob();
          var wavformData = new FormData();
          var wavform = new File([wavBlob], new Date().getTime() + ".wav");
          wavformData.append("file", wavform);
          axios({
            method: "post",
            url: "/api/blade-jfpts/xlfeedback/xlfeedback/put-objecty",
            data: wavformData,
            params: {
              jid: that.form.id,
            },
          }).then((resdata) => {
          });
          newCallAxios
            .post(`/api_control`, blob, {
              params: {
@@ -797,6 +786,8 @@
    //启动websocket
    websocketStart() {
      var that = this;
      if (!window.WebSocket) {
        window.WebSocket = window.MozWebSocket;
      }
@@ -805,13 +796,21 @@
        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) {};
        window.socket.onclose = function (event) {};
        window.socket.error = function (event) {
          //执行重连
          that.websocketStart();
        };
      } else {
        console.log("WebSocket连接没有建立成功!!");
      }
@@ -831,19 +830,57 @@
          //开启心跳传送
          window.websockPing = setInterval(function () {
            window.socket.send("ping");
          },10000);
        }else{
            if (window.socket.readyState == WebSocket.OPEN) {
              window.socket.send("ping");
            } else {
              console.log("心跳停止,断开重连");
              //断开连接,重连
              window.clearTimeout(window.websockPing);
              //执行重连
              that.websocketStart();
            }
          }, 4000);
        } else {
          console.log("WebSocket连接没有建立成功!!");
          //执行重连
          this.websocketStart();
          that.websocketStart();
        }
      }, 3000);
      }, 1000);
    },
    onDialogTableVisible() {
      var that = this;
      Recorder.getPermission().then(() => {});
      this.videoConversationReal = true;
      var userId = JSON.parse(
        window.localStorage.getItem("物联网安保云服务平台-userInfo")
      ).content.user_id;
      newAxios
        .post(
          "/api_control",
          {},
          {
            params: {
              param: JSON.stringify({ PktType: "GetAccessToken" }),
            },
          }
        )
        .then((res) => {
          newAxios
            .get(
              `https://web.byisf.com:18000/GetPlayUrl?deviceCode=${that.form.serialNumber}&chl=${that.form.channelNumber}`
            )
            .then((result) => {
              axios({
                method: "post",
                url: `/api/blade-jfpts/rvideo/rVoids`,
                params: {
                  url: result.data.data.flv,
                  uid: userId,
                },
              }).then((resdata) => {});
            });
        });
    },
  },
};