Parcourir la source

websocket修改 地图修改

王通 il y a 2 ans
Parent
commit
6a77195a35
4 fichiers modifiés avec 32 ajouts et 21 suppressions
  1. 21 15
      src/components/vBottomMenu.vue
  2. 3 0
      src/views/forest.vue
  3. 4 3
      src/views/leader.vue
  4. 4 3
      src/views/tianzhangzhi.vue

+ 21 - 15
src/components/vBottomMenu.vue

@@ -367,7 +367,7 @@ import {
 import supermapTaskDialog from '@/components/supermap' //超图
 import TcPlayer from '@/components/TcPlayer' //视频预览
 import Cookies from 'js-cookie'
-
+import {selectConfigKey} from "@/api/system/config";
 export default {
   components: {
     supermapTaskDialog,
@@ -498,8 +498,8 @@ export default {
       filterchang: '', //林场搜索
       btmCurrent: '',
       websock: '',
-      wsuri:'ws://127.0.0.1:10012/messagePush/',
-      wsuri2:'ws://127.0.0.1:10005/taskPush/',
+      wsurl:'',
+      postName:'',
       setIntervalWesocketPush: null,
       websockSid: {
         userId: ''
@@ -517,15 +517,20 @@ export default {
     this.websockSid.userId=Cookies.get("userId")
   },
   methods: {
-    initWebSocket(wsurl,userId) {        //初始化weosocket
-      //const wsuri = 'ws://127.0.0.1:10003/eventPush/' + userId + '/' + eventTypeDl + '/' + eventType
-      const wsuri = wsurl+userId
-      // const wsuri = 'ws://172.28.20.82:10012/taskPush/'+userId
-      this.websock = new WebSocket(wsuri)
-      console.log('建立websocket连接'+wsuri)
-      this.websock.onopen = this.websocketonopen
-      this.websock.onmessage = this.websocketonmessage
-      this.websock.onerror = this.websocketonerror
+    initWebSocket(wsurl,postName,userId) {
+      this.postName=postName
+      this.wsurl=wsurl
+      selectConfigKey(wsurl).then(res => {
+        //初始化weosocket
+        //const wsuri = 'ws://127.0.0.1:10003/eventPush/' + userId + '/' + eventTypeDl + '/' + eventType
+        const wsuri = res.data + userId +postName+ userId
+        // const wsuri = 'ws://172.28.20.82:10012/taskPush/'+userId
+        this.websock = new WebSocket(wsuri)
+        //console.log('建立websocket连接' + wsuri)
+        this.websock.onopen = this.websocketonopen
+        this.websock.onmessage = this.websocketonmessage
+        this.websock.onerror = this.websocketonerror
+      })
     },
     websocketonopen() { //连接建立之后执行send方法发送数据
       console.log('websocket连接成功')
@@ -533,8 +538,9 @@ export default {
       this.sendPing()
     },
     websocketonerror() { //连接建立失败重连
-      this.initWebSocket(this.wsuri,this.websockSid.userId)
+      this.initWebSocket(this.wsurl,this.postName,this.websockSid.userId)
     },
+
     websocketonmessage(e) { //数据接收
       console.log('接收数据', e.data)
       // let data = "{\"fromId\":\"farming\"}";
@@ -795,7 +801,7 @@ export default {
         this.taskList = res.data
         this.taskCount = res.data.length
       })
-      this.initWebSocket(this.wsuri2,this.websockSid.userId)
+      this.initWebSocket('TASK_SOCKET','/taskPush/',this.websockSid.userId)
     },
     selectMessageById(id) {
       selectMessageById(id).then(response => {
@@ -815,7 +821,7 @@ export default {
         this.messageList = response.data
         this.messageCount = response.data.length
       });
-      this.initWebSocket(this.wsuri,this.websockSid.userId)
+      this.initWebSocket('MESSAGE_SOCKET','/messagePush/',this.websockSid.userId)
     },
     handleCheckedCitiesChangeBan(value) {
       this.choseLayerSwitchingList(this.banCheckList)

+ 3 - 0
src/views/forest.vue

@@ -493,6 +493,7 @@ export default {
     window.choseLayerSwitchingList = this.choseLayerSwitchingList
     /** ----------------------------------底部按钮公用组件结束------------------------------------- */
   },
+
   mounted() {
     this.getBaseInfo()
     this.getTodayEvents(this.getCurrentDataStr())
@@ -504,6 +505,7 @@ export default {
     this.getExposureStage(this.getCurrentDataStr())
     this.getSupermap(this.getCurrentDataStr())
     this.getMenuEventType()
+
     /** ----------------------------------weosocket开始------------------------------------- */
     // this.initWebSocket()
     /** ----------------------------------weosocket结束------------------------------------- */
@@ -886,6 +888,7 @@ export default {
       }, loading).then(res => {
         this.forestFarm = res.data
       })
+
     },
     getWeather(day) {
       let that = this

+ 4 - 3
src/views/leader.vue

@@ -69,8 +69,9 @@
         </div>
       </div>
       <!-- 地图 -->
-      <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"
-                :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false"></supermap>
+<!--      <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"-->
+<!--                :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false"></supermap>-->
+      <supermap ref="supermap" style="width: 100%;height: 100vh;" ></supermap>
       <!-- 右侧 -->
       <div class="rightbar" :class="indentright" ref="right">
         <div class="forthis">
@@ -153,7 +154,7 @@ import {
   getRy
 } from '@/api/leader'
 
-import supermap from '@/components/supermap' //超图
+import supermap from '@/components/supermap-2.5d' //超图
 import vheader from '@/components/v-header.vue' //一体化共用头部
 import vBottomMenu from '@/components/vBottomMenu.vue' //一体化公共底部菜单
 import eventLocation from '@/components/eventLocation.vue' //事件定位弹窗

+ 4 - 3
src/views/tianzhangzhi.vue

@@ -50,8 +50,9 @@
         </div>
       </div>
       <!-- 地图 -->
-      <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"
-                :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false"></supermap>
+<!--      <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"-->
+<!--                :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false"></supermap>-->
+      <supermap ref="supermap" style="width: 100%;height: 100vh;" ></supermap>
       <!-- 右侧 -->
       <div class="rightbar" ref="right">
         <div class="forthis">
@@ -109,7 +110,7 @@ import {
   getTianzhangList,selectVisuGridLength,selectGridLandInfo,remoteGetRegionalFlag
 } from '@/api/tianzhangzhi'
 
-import supermap from '@/components/supermap' //超图
+import supermap from '@/components/supermap-2.5d' //超图
 import vheader from '@/components/v-header.vue' //一体化共用头部
 import vBottomMenu from '@/components/vBottomMenu.vue' //一体化公共底部菜单
 import eventLocation from '@/components/eventLocation.vue' //事件定位弹窗