Browse Source

websocket修改 地图修改

王通 2 năm trước cách đây
mục cha
commit
88aff821f3
2 tập tin đã thay đổi với 27 bổ sung18 xóa
  1. 23 15
      src/components/vBottomMenu.vue
  2. 4 3
      src/views/leader.vue

+ 23 - 15
src/components/vBottomMenu.vue

@@ -497,8 +497,8 @@
 				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: ''
@@ -518,23 +518,30 @@
     },
 
     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连接成功')
         this.weosocket = true
         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)
@@ -796,7 +803,8 @@
 					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) {
@@ -812,12 +820,12 @@
         });
       },
       /** 获取消息列表 */
-      selectMessageList(){
+      selectMessageList() {
         selectMessageList(Cookies.get("userId")).then(response => {
           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)

+ 4 - 3
src/views/leader.vue

@@ -68,8 +68,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">
@@ -152,7 +153,7 @@
 		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' //事件定位弹窗