From a4e06ccd3cd976fbe4eef99e188d42ec9f3ad054 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 08 Apr 2021 09:32:05 +0800
Subject: [PATCH] 样式修改

---
 src/page/index/logo.vue |  112 ++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 68 insertions(+), 44 deletions(-)

diff --git a/src/page/index/logo.vue b/src/page/index/logo.vue
index 8d2cb22..e7b5548 100644
--- a/src/page/index/logo.vue
+++ b/src/page/index/logo.vue
@@ -20,7 +20,7 @@
         :append-to-body="true"
         :close-on-press-escape="false"
         :close-on-click-modal="false"
-        @opened="videoConversationReal = true"
+        @opened="onDialogTableVisible"
         @close="closeDialog"
       >
         <el-form
@@ -360,7 +360,11 @@
         url: "/api/blade-jfpts/alarm/alarm/getLimit",
         method: "get",
       }).then(function (response) {
-        that.deviceId = response.data.data[0].id;
+        if (response.data.data.length > 0) {
+          that.deviceId = response.data.data[0].id;
+        } else {
+          that.deviceId = 0;
+        }
         //获得最新ID,开启实时报警循环
         that.layerRealtime();
       });
@@ -380,12 +384,38 @@
 
           if (response.data.data.length > 0) {
             that.deviceId = response.data.data[0].id;
+            that.form = response.data.data[0];
+            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,
+                      },
+                    }).then((resdata) => {});
+                  });
+              });
             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 },
@@ -394,36 +424,6 @@
               that.peopleName = that.form.oneContacts;
               that.peoplePhone = that.form.onePhone;
               that.dialogTableVisible = true;
-              // Recorder.getPermiRecorderssion().then(() => {});
-
-              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.ofX = null;
               that.ofY = null;
@@ -442,7 +442,6 @@
       this.videoConversationReal = false;
       this.oldVideoSatart = false;
     },
-
     getDate() {
       // 当前时间
       var timestamp = Date.parse(new Date());
@@ -572,6 +571,14 @@
         )
         .then(function () {
           that.dialogTableVisible = false;
+
+          axios({
+            method: "post",
+            url: `/api/blade-jfpts/rvideo/stop`,
+            params: {
+              jid: row.id,
+            },
+          }).then((resdata) => {});
 
           that.$router.push({
             path: "/policeTracking/track",
@@ -703,6 +710,8 @@
     },
 
     aKeyToCall() {
+      this.isActive = true;
+
       var that = this;
       if (this.recorder == null) {
         this.recorder = new Recorder({
@@ -712,7 +721,6 @@
           // compiling: false,(0.x版本中生效,1.x增加中)  // 是否边录边转换,默认是false
         });
       }
-      this.isActive = true;
 
       // 一键呼叫相关函数
       that.recorder.start().then(
@@ -728,6 +736,8 @@
 
     // 序列号后期待修改
     aKeyStopCall() {
+      this.isActive = false;
+
       var newCallAxios = axios.create({
         baseURL: "https://web.byisf.com:18000",
         withCredentials: false,
@@ -736,7 +746,6 @@
         },
       });
       var that = this;
-      that.isActive = false;
 
       newCallAxios
         .post(
@@ -751,6 +760,7 @@
         .then((result) => {
           var formData = new FormData();
           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");
@@ -797,6 +807,8 @@
 
     //启动websocket
     websocketStart() {
+      var that = this;
+
       if (!window.WebSocket) {
         window.WebSocket = window.MozWebSocket;
       }
@@ -812,6 +824,10 @@
         window.socket.onopen = function (event) {};
 
         window.socket.onclose = function (event) {};
+        window.socket.error = function (event) {
+          //执行重连
+          that.websocketStart();
+        };
       } else {
         console.log("WebSocket连接没有建立成功!!");
       }
@@ -831,19 +847,27 @@
 
           //开启心跳传送
           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();
+            }
+          }, 10000);
+        } else {
           console.log("WebSocket连接没有建立成功!!");
           //执行重连
-          this.websocketStart();
+          that.websocketStart();
         }
       }, 3000);
+    },
 
-
-
+    onDialogTableVisible() {
+      Recorder.getPermission().then(() => {});
+      this.videoConversationReal = true;
     },
   },
 };

--
Gitblit v1.9.3