瀏覽代碼

websocket bug修复

王通 1 年之前
父節點
當前提交
fb6aa548b1
共有 6 個文件被更改,包括 288 次插入201 次删除
  1. 175 142
      src/components/TVWall.vue
  2. 49 31
      src/components/TVWalls.vue
  3. 35 18
      src/dahua/TVWalllib/DHWs.js
  4. 1 1
      src/dahua/TVWalllib/main.ts
  5. 22 5
      src/dahua/lib/DHWs.js
  6. 6 4
      src/views/forest.vue

+ 175 - 142
src/components/TVWall.vue

@@ -38,7 +38,7 @@ import { tvCameraList } from '@/api/haikang/haikang'
 import DHWs from '@/dahua/lib/DHWs'
 import { rotation } from '@/api/monitor'
 import Cookies from "js-cookie"
-
+import {selectConfigKey} from "@/api/system/config";
 /** ----------------------------------摄像头预览结束------------------------------------- */
 export default {
   dicts: ['event_source'],
@@ -286,79 +286,96 @@ export default {
     },
     //火点联动电视墙调用
     showTVWall1(longitude,latitude,tvListJson) {
-
-      // let that=this;
-      /** ----------------------------------大华摄像头预览开始------------------------------------- */
-      this.ws.addEventListener('connectStateChange', data => {
-        if (data) {
-          console.log('连接成功')
-        } else {
-          console.log('连接失败,下载客户端')
-          this.alertReinstall()
-        }
-      })
-      getDahuaVideoServer().then(newResponse => {
-        this.ws.detectConnectQt().then(res => {
-          if (res) { // 连接客户端成功
-            this.alertLogin()
-            this.ws.login({
-              loginIp: newResponse.loginIp,
-              loginPort: newResponse.loginPort,
-              userName: newResponse.userName,
-              userPwd: newResponse.userPwd,
-              // loginIp: '192.168.100.100',
-              // loginPort: 8314,
-              // userName: 'system',
-              // userPwd: 'Admin@123',
-              token: '',
-              https: 1
-            })
-            this.ws.on('loginState', (res) => {
-              this.isLogin = res
-              console.log('---res-----', res)
-              if (res) {
-                this.alertLoginSuccess()
-                this.activePanel = 'key2'
-                console.log(tvListJson)
-                const array=[]
-                const array1=[]
-                if (tvListJson!=null)
-                {
-                  tvListJson[0].treeLabels.forEach((item,index)=>
-                  {
-                    if (index!=0)
+      selectConfigKey("DssVersion").then(res => {
+        if(this.ws.getLocalDssVersion()!=res.data){
+          this.$modal.confirm('系统检测到新客户端版本,请更新后使用', '系统提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }
+          ).then(() => {
+            window.open("https://pan.baidu.com/s/1MlWyhFw6pEYiaLvzsje-BA?pwd=3jps");
+          }).catch(() => {
+            return
+          });
+          return
+        }else{
+          // let that=this;
+          /** ----------------------------------大华摄像头预览开始------------------------------------- */
+          this.ws.addEventListener('connectStateChange', data => {
+            if (data) {
+              console.log('连接成功')
+            } else {
+              console.log('连接失败,下载客户端')
+              this.alertReinstall()
+            }
+          })
+          getDahuaVideoServer().then(newResponse => {
+            this.ws.detectConnectQt().then(res => {
+              if (res) { // 连接客户端成功
+                this.alertLogin()
+                this.ws.login({
+                  loginIp: newResponse.loginIp,
+                  loginPort: newResponse.loginPort,
+                  userName: newResponse.userName,
+                  userPwd: newResponse.userPwd,
+                  // loginIp: '192.168.100.100',
+                  // loginPort: 8314,
+                  // userName: 'system',
+                  // userPwd: 'Admin@123',
+                  token: '',
+                  https: 1
+                })
+                this.ws.on('loginState', (res) => {
+                  this.isLogin = res
+                  console.log('---res-----', res)
+                  if (res) {
+                    this.alertLoginSuccess()
+                    this.activePanel = 'key2'
+                    console.log(tvListJson)
+                    const array=[]
+                    const array1=[]
+                    if (tvListJson!=null)
                     {
-                      const param =Object.assign({})
-                      param.channelId=item.labelCode
-                      array.push(param)
-                      array1.push(item.labelCode)
+                      tvListJson[0].treeLabels.forEach((item,index)=>
+                      {
+                        if (index!=0)
+                        {
+                          const param =Object.assign({})
+                          param.channelId=item.labelCode
+                          array.push(param)
+                          array1.push(item.labelCode)
+                        }
+
+                      })
                     }
-
-                  })
-                }
-                this.create1(longitude,latitude,tvListJson,array,array1)
-                // var obj=JSON.parse(tvListJson)
-              } else {
-                this.alertLoginFailed()
+                    this.create1(longitude,latitude,tvListJson,array,array1)
+                    // var obj=JSON.parse(tvListJson)
+                  } else {
+                    this.alertLoginFailed()
+                  }
+                })
+              } else { // 连接客户端失败
+                this.alertReinstall()
               }
             })
-          } else { // 连接客户端失败
-            this.alertReinstall()
-          }
-        })
 
+          })
+          /** ----------------------------------大华摄像头预览结束------------------------------------- */
+          /** ----------------------------------海康摄像头预览开始------------------------------------- */
+          // tvCameraList().then(response => {
+          //   this.cameraList=response.data
+          // })
+          // that.initPlugin()
+          // setTimeout(function() {
+          //   that.playhk();
+          // }, 5000)
+          // /** ----------------------------------海康摄像头预览结束------------------------------------- */
+          this.TVWallVisible = true
+
+        }
       })
-      /** ----------------------------------大华摄像头预览结束------------------------------------- */
-      /** ----------------------------------海康摄像头预览开始------------------------------------- */
-      // tvCameraList().then(response => {
-      //   this.cameraList=response.data
-      // })
-      // that.initPlugin()
-      // setTimeout(function() {
-      //   that.playhk();
-      // }, 5000)
-      // /** ----------------------------------海康摄像头预览结束------------------------------------- */
-      this.TVWallVisible = true
+
 
     },
     create1(longitude,latitude,tvListJson,array,array1) { // 调用创建控件接口
@@ -408,85 +425,101 @@ export default {
       })
     },
     showTVWall(tvListJson,bfArray) {
-      if(tvListJson){
-        this.preview(tvListJson,bfArray);
-        this.TVWallVisible = true;
-        return;
-      }
-      // let that=this;
-      /** ----------------------------------大华摄像头预览开始------------------------------------- */
-      this.ws.addEventListener('connectStateChange', data => {
-        if (data) {
-          console.log('连接成功')
-        } else {
-          console.log('连接失败,下载客户端')
-          this.alertReinstall()
-        }
-      })
-      this.preview()
-      /** ----------------------------------大华摄像头预览结束------------------------------------- */
-      /** ----------------------------------海康摄像头预览开始------------------------------------- */
-      // tvCameraList().then(response => {
-      //   this.cameraList=response.data
-      // })
-      // that.initPlugin()
-      // setTimeout(function() {
-      //   that.playhk();
-      // }, 5000)
-      // /** ----------------------------------海康摄像头预览结束------------------------------------- */
-      this.TVWallVisible = true
-    },
-    /** ----------------------------------大华摄像头预览开始------------------------------------- */
-    alertLogin: function() {
-      this.$modal.msg('登录中....')
-    },
-    alertLoginSuccess: function() {
-      this.$modal.msgSuccess('登录成功!')
-    },
-    alertLoginFailed: function() {
-      this.$modal.msgError('登陆失败!')
-    },
-    alertReinstall: function() {
-      this.$modal.msgWarning('请重新安装客户端')
-    },
-    /** 预览按钮操作 */
-    preview(tvListJson,bfArray) {
-      getTVWallList().then(newres => {
-        getDahuaVideoServer().then(newResponse => {
-          this.ws.detectConnectQt().then(res => {
-            if (res) { // 连接客户端成功
-              this.alertLogin()
-              this.ws.login({
-                loginIp: newResponse.loginIp,
-                loginPort: newResponse.loginPort,
-                userName: newResponse.userName,
-                userPwd: newResponse.userPwd,
-                // loginIp: '192.168.100.100',
-                // loginPort: 8314,
-                // userName: 'system',
-                // userPwd: 'Admin@123',
-                token: '',
-                https: 1
-              })
-              this.ws.on('loginState', (res) => {
-                this.isLogin = res
-                console.log('---res-----', res)
-                if (res) {
-                  this.alertLoginSuccess()
-                  this.activePanel = 'key2'
-                  this.create(tvListJson?tvListJson:newres.data,bfArray)
-                } else {
-                  this.alertLoginFailed()
-                }
-              })
-            } else { // 连接客户端失败
+      selectConfigKey("DssVersion").then(res => {
+        if(this.ws.getLocalDssVersion()!=res.data){
+          this.$modal.confirm('系统检测到新客户端版本,请更新后使用', '系统提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }
+          ).then(() => {
+            window.open("https://pan.baidu.com/s/1MlWyhFw6pEYiaLvzsje-BA?pwd=3jps");
+          }).catch(() => {
+            return
+          });
+          return
+        }else{
+
+          if(tvListJson){
+            this.preview(tvListJson,bfArray);
+            this.TVWallVisible = true;
+            return;
+          }
+          // let that=this;
+          /** ----------------------------------大华摄像头预览开始------------------------------------- */
+          this.ws.addEventListener('connectStateChange', data => {
+            if (data) {
+              console.log('连接成功')
+            } else {
+              console.log('连接失败,下载客户端')
               this.alertReinstall()
             }
           })
-        })
+          this.preview()
+          /** ----------------------------------大华摄像头预览结束------------------------------------- */
+          /** ----------------------------------海康摄像头预览开始------------------------------------- */
+          // tvCameraList().then(response => {
+          //   this.cameraList=response.data
+          // })
+          // that.initPlugin()
+          // setTimeout(function() {
+          //   that.playhk();
+          // }, 5000)
+          // /** ----------------------------------海康摄像头预览结束------------------------------------- */
+          this.TVWallVisible = true
+        },
+        /** ----------------------------------大华摄像头预览开始------------------------------------- */
+        alertLogin: function() {
+          this.$modal.msg('登录中....')
+        },
+        alertLoginSuccess: function() {
+          this.$modal.msgSuccess('登录成功!')
+        },
+        alertLoginFailed: function() {
+          this.$modal.msgError('登陆失败!')
+        },
+        alertReinstall: function() {
+          this.$modal.msgWarning('请重新安装客户端')
+        },
+        /** 预览按钮操作 */
+        preview(tvListJson,bfArray) {
+          getTVWallList().then(newres => {
+            getDahuaVideoServer().then(newResponse => {
+              this.ws.detectConnectQt().then(res => {
+                if (res) { // 连接客户端成功
+                  this.alertLogin()
+                  this.ws.login({
+                    loginIp: newResponse.loginIp,
+                    loginPort: newResponse.loginPort,
+                    userName: newResponse.userName,
+                    userPwd: newResponse.userPwd,
+                    // loginIp: '192.168.100.100',
+                    // loginPort: 8314,
+                    // userName: 'system',
+                    // userPwd: 'Admin@123',
+                    token: '',
+                    https: 1
+                  })
+                  this.ws.on('loginState', (res) => {
+                    this.isLogin = res
+                    console.log('---res-----', res)
+                    if (res) {
+                      this.alertLoginSuccess()
+                      this.activePanel = 'key2'
+                      this.create(tvListJson?tvListJson:newres.data,bfArray)
+                    } else {
+                      this.alertLoginFailed()
+                    }
+                  })
+                } else { // 连接客户端失败
+                  this.alertReinstall()
+                }
+              })
+            })
+          })
+        }
       })
     },
-
     create(tvListJson,bfArray) { // 调用创建控件接口
       // debugger
       let _this = this

+ 49 - 31
src/components/TVWalls.vue

@@ -35,6 +35,7 @@ import {tvCameraList} from '@/api/haikang/haikang'
 import {findCameraByEventCoordinate, rotation} from '@/api/monitor'
 import DHWs from '@/dahua/lib/DHWs'
 import Cookies from "js-cookie"
+import {selectConfigKey} from "@/api/system/config";
 /** ----------------------------------摄像头预览结束------------------------------------- */
 export default {
   dicts: ['event_source'],
@@ -284,39 +285,56 @@ export default {
       }
     },
     showTVWall(data, val) {
-      this.tvListJson = data
-      this.data = val
-      this.autoList = []
-      this.stringList = []
-      let length = data[0].treeLabels.length >= 4 ? 5 : data[0].treeLabels.length
-      for (let i = 1; i < length; i++) {
-        this.autoList.push({"channelId": data[0].treeLabels[i].labelCode})
-        this.stringList.push(data[0].treeLabels[i].labelCode)
-      }
-      console.log("this.autoList",this.autoList);
-      console.log("this.stringList",this.stringList);
-      // let that=this;
-      /** ----------------------------------大华摄像头预览开始------------------------------------- */
-      this.ws.addEventListener('connectStateChange', data => {
-        if (data) {
-          console.log('连接成功')
-        } else {
-          console.log('连接失败,下载客户端')
-          this.alertReinstall()
+      selectConfigKey("DssVersion").then(res => {
+        if(this.ws.getLocalDssVersion()!=res.data){
+          this.$modal.confirm('系统检测到新客户端版本,请更新后使用', '系统提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }
+          ).then(() => {
+            window.open("https://pan.baidu.com/s/1MlWyhFw6pEYiaLvzsje-BA?pwd=3jps");
+          }).catch(() => {
+            return
+          });
+          return
+        }else{
+          this.tvListJson = data
+          this.data = val
+          this.autoList = []
+          this.stringList = []
+          let length = data[0].treeLabels.length >= 4 ? 5 : data[0].treeLabels.length
+          for (let i = 1; i < length; i++) {
+            this.autoList.push({"channelId": data[0].treeLabels[i].labelCode})
+            this.stringList.push(data[0].treeLabels[i].labelCode)
+          }
+          console.log("this.autoList",this.autoList);
+          console.log("this.stringList",this.stringList);
+          // let that=this;
+          /** ----------------------------------大华摄像头预览开始------------------------------------- */
+          this.ws.addEventListener('connectStateChange', data => {
+            if (data) {
+              console.log('连接成功')
+            } else {
+              console.log('连接失败,下载客户端')
+              this.alertReinstall()
+            }
+          })
+          this.preview()
+          /** ----------------------------------大华摄像头预览结束------------------------------------- */
+          /** ----------------------------------海康摄像头预览开始------------------------------------- */
+          // tvCameraList().then(response => {
+          //   this.cameraList=response.data
+          // })
+          // that.initPlugin()
+          // setTimeout(function() {
+          //   that.playhk();
+          // }, 5000)
+          // /** ----------------------------------海康摄像头预览结束------------------------------------- */
+          this.TVWallVisible = true
         }
       })
-      this.preview()
-      /** ----------------------------------大华摄像头预览结束------------------------------------- */
-      /** ----------------------------------海康摄像头预览开始------------------------------------- */
-      // tvCameraList().then(response => {
-      //   this.cameraList=response.data
-      // })
-      // that.initPlugin()
-      // setTimeout(function() {
-      //   that.playhk();
-      // }, 5000)
-      // /** ----------------------------------海康摄像头预览结束------------------------------------- */
-      this.TVWallVisible = true
+
     },
     /** ----------------------------------大华摄像头预览开始------------------------------------- */
     alertLogin: function () {

+ 35 - 18
src/dahua/TVWalllib/DHWs.js

@@ -7381,24 +7381,41 @@
 	        let _this = this;
 	        this.getVersion();
 	        console.log(`ws-getLocalDssVersion-getVersionEnd-${this.getVersionEnd}`);
-	        return new Promise((resolve, reject) => {
-	            if (!this.getVersionEnd) { // 连接中或者获取中
-	                // let now = Date.now();
-	                // if((now - _this.getVersionStartTime) > _this.getVersionTimeOut) {
-	                // 	console.log(`ws-this.getVersionEndTime-${now}`);
-	                // 	reject('get version timeout');
-	                // }
-	                let _interval = setInterval(() => {
-	                    if (_this.getVersionEnd) {
-	                        clearInterval(_interval);
-	                        resolve(_this.currentDssVersion);
-	                    }
-	                }, 50);
-	            }
-	            else {
-	                resolve(_this.currentDssVersion);
-	            }
-	        });
+        if (!this.getVersionEnd) { // 连接中或者获取中
+          // let now = Date.now();
+          // if((now - _this.getVersionStartTime) > _this.getVersionTimeOut) {
+          // 	console.log(`ws-this.getVersionEndTime-${now}`);
+          // 	reject('get version timeout');
+          // }
+          let _interval = setInterval(() => {
+            if (_this.getVersionEnd) {
+              clearInterval(_interval);
+              return _this.currentDssVersion;
+            }
+          }, 50);
+        }
+        else {
+          return _this.currentDssVersion;
+        }
+
+        // return new Promise((resolve, reject) => {
+        //   if (!this.getVersionEnd) { // 连接中或者获取中
+        //     // let now = Date.now();
+        //     // if((now - _this.getVersionStartTime) > _this.getVersionTimeOut) {
+        //     // 	console.log(`ws-this.getVersionEndTime-${now}`);
+        //     // 	reject('get version timeout');
+        //     // }
+        //     let _interval = setInterval(() => {
+        //       if (_this.getVersionEnd) {
+        //         clearInterval(_interval);
+        //         resolve(_this.currentDssVersion);
+        //       }
+        //     }, 50);
+        //   }
+        //   else {
+        //     resolve(_this.currentDssVersion);
+        //   }
+        // });
 	    }
 	    /**
 	     * @description 比较客户端版本

+ 1 - 1
src/dahua/TVWalllib/main.ts

@@ -530,4 +530,4 @@ function getScrollbarWidth() {
 	document.body.removeChild(scrollDiv);
 
 	return scrollbarWidth;
-}
+}

+ 22 - 5
src/dahua/lib/DHWs.js

@@ -7367,7 +7367,6 @@
 	        let _this = this;
 	        this.getVersion();
 	        console.log(`ws-getLocalDssVersion-getVersionEnd-${this.getVersionEnd}`);
-	        return new Promise((resolve, reject) => {
 	            if (!this.getVersionEnd) { // 连接中或者获取中
 	                // let now = Date.now();
 	                // if((now - _this.getVersionStartTime) > _this.getVersionTimeOut) {
@@ -7377,14 +7376,32 @@
 	                let _interval = setInterval(() => {
 	                    if (_this.getVersionEnd) {
 	                        clearInterval(_interval);
-	                        resolve(_this.currentDssVersion);
+	                        return _this.currentDssVersion;
 	                    }
 	                }, 50);
 	            }
 	            else {
-	                resolve(_this.currentDssVersion);
-	            }
-	        });
+                return _this.currentDssVersion;
+	            }
+
+        // return new Promise((resolve, reject) => {
+        //   if (!this.getVersionEnd) { // 连接中或者获取中
+        //     // let now = Date.now();
+        //     // if((now - _this.getVersionStartTime) > _this.getVersionTimeOut) {
+        //     // 	console.log(`ws-this.getVersionEndTime-${now}`);
+        //     // 	reject('get version timeout');
+        //     // }
+        //     let _interval = setInterval(() => {
+        //       if (_this.getVersionEnd) {
+        //         clearInterval(_interval);
+        //         resolve(_this.currentDssVersion);
+        //       }
+        //     }, 50);
+        //   }
+        //   else {
+        //     resolve(_this.currentDssVersion);
+        //   }
+        // });
 	    }
 	    /**
 	     * @description 比较客户端版本

+ 6 - 4
src/views/forest.vue

@@ -1205,8 +1205,7 @@
           this.getEventByEventType(this.getCurrentDataStr(), true);
           this.getEventByReportorOrder(this.getCurrentDataStr(), true);
           this.getExposureStage(this.getCurrentDataStr(), true);
-          this.$refs.bottomMenu.updateAlert();
-          this.$refs.up.play();
+
           // thes.$refs.up.pause();//停止播放音乐
         }
       },
@@ -1226,7 +1225,7 @@
               } else if (res.data.eventType == 602) {
                 res.data.picturePath = "../assets/images/水质监测.png"
               }
-              if (res.data.eventStatusValue !== "forest_event_status_1") {
+              // if (res.data.eventStatusValue !== "forest_event_status_1") {
                 //插入到第一条
                 this.eventList.unshift(res.data)
                 // 插入后删除最后一条 保证列表中为10条数据
@@ -1234,7 +1233,10 @@
                   this.eventList.splice(10, 1)
                 // 将收到的数据在地图上添加
                 this.getWebSocketEvent(res.data)
-              }
+
+              // }
+              this.$refs.bottomMenu.updateAlert();
+              this.$refs.up.play();
             }
           })
         }