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',