From c8cdf34397fd53087b8f14084e2c1f84d27474e4 Mon Sep 17 00:00:00 2001 From: sunzhenyu Date: Fri, 27 Nov 2020 17:24:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=89=E7=BB=B4=E5=AE=A2?= =?UTF-8?q?=E6=B5=81=E9=80=80=E5=87=BA=E9=A1=B5=E9=9D=A2=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jl3dtrafficplan/connect/stationconnect.js | 2 +- .../jlmap3d/trafficplan/jl3dtrafficplan.vue | 37 +++++++++++-------- .../jlmap3d/trafficplan/jl3dtraffictrain.vue | 12 ++++-- src/views/newMap/jlmapNew/index.vue | 11 +++--- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js b/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js index e1e8b604f..6976370f2 100644 --- a/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js @@ -32,7 +32,7 @@ export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passe const data = JSON.parse(Response.body); if(data.type == "PFV"){ - + console.log(data); for(let i=0;i this.unloadHandler(e)); document.querySelector("link[rel*='icon']").href = loginInfo[this.$route.query.project].linkIcon || ProjectIcon[this.$route.query.project]; }, mounted() { + window.addEventListener('beforeunload', e => this.beforeunloadHandler(e)); + window.addEventListener('unload', e => this.unloadHandler(e)); + this.group = this.$route.query.group; this.mapId = this.$route.query.mapId; this.lineCode = this.$route.query.lineCode; @@ -95,26 +96,26 @@ export default { this.isCctv = false; } }, - - beforeDestroy() { + destroyed() { + window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e)) window.removeEventListener('unload', e => this.unloadHandler(e)) }, - destroyed() { - window.removeEventListener('beforeunload', this.updateHandler); - }, methods: { - updateHandler() { + beforeunloadHandler(){ this.beforeUnloadTime=new Date().getTime(); -   }, - unloadHandler(){ + }, + async unloadHandler(e){ this.gapTime=new Date().getTime()-this.beforeUnloadTime; //判断是窗口关闭还是刷新 - if(this.gapTime<=5){ - deletePassenger(this.$route.query.group,this.initCode).then(netdata => { - console.log(netdata); + console.log( this.gapTime); + console.log( this.$route.query.group,this.$route.query.deviceCode); + if(this.gapTime<=5){//浏览器关闭 + //自己的操作行为 + await deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => { }); } }, + init: function (code) { // let mapdata = this.$store.state.socket.device; const dom = document.getElementById('jl3d'); @@ -153,7 +154,11 @@ export default { this.value = selVal; }, back() { - window.close(); + deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => { + // console.log(netdata); + window.close(); + }); + } } }; diff --git a/src/views/jlmap3d/trafficplan/jl3dtraffictrain.vue b/src/views/jlmap3d/trafficplan/jl3dtraffictrain.vue index ee3a5019b..aafb7e9f4 100644 --- a/src/views/jlmap3d/trafficplan/jl3dtraffictrain.vue +++ b/src/views/jlmap3d/trafficplan/jl3dtraffictrain.vue @@ -177,10 +177,11 @@ export default { }, beforeDestroy() { - window.removeEventListener('unload', e => this.unloadHandler(e)) + window.removeEventListener('beforeunload', this.updateHandler); + }, destroyed() { - window.removeEventListener('beforeunload', this.updateHandler); + window.removeEventListener('unload', e => this.unloadHandler(e)) }, methods: { updateHandler() { @@ -189,10 +190,10 @@ export default { unloadHandler(){ this.gapTime=new Date().getTime()-this.beforeUnloadTime; //判断是窗口关闭还是刷新 - + alert("netdata"); if(this.gapTime<=5){ deletePassenger(this.$route.query.group,this.initCode).then(netdata => { - console.log(netdata); + alert(netdata); }); } }, @@ -274,7 +275,10 @@ export default { return re; }, back() { + deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => { + // console.log(netdata); window.close(); + }); } } }; diff --git a/src/views/newMap/jlmapNew/index.vue b/src/views/newMap/jlmapNew/index.vue index 5f89001fa..62fe6abf4 100644 --- a/src/views/newMap/jlmapNew/index.vue +++ b/src/views/newMap/jlmapNew/index.vue @@ -382,11 +382,12 @@ export default { } this.$store.dispatch('training/emitTipFresh'); + }, + unConnect3d(code){ + }, // 点击选择事件 onSelected(em) { - console.log(em); - const path = window.location.href; if (path.includes('/practiceDisplay')) { @@ -395,7 +396,7 @@ export default { if (em.deviceType == 'StationStand') { runPassenger(this.$route.query.group,em.deviceCode).then(netdata => { - + console.log(netdata); if(netdata.data){ const routeData = this.$router.resolve({ path:'/jlmap3d/trafficplan', @@ -416,9 +417,9 @@ export default { } if (em.deviceType == 'Train') { - // console.log(em.deviceType ); + runPassenger(this.$route.query.group,em.deviceCode).then(netdata => { - + console.log(netdata); if(netdata.data){ const routeData = this.$router.resolve({ path:'/jlmap3d/traffictrain',