修改三维客流退出页面取消订阅

This commit is contained in:
sunzhenyu 2020-11-27 17:24:52 +08:00
parent c3a8ab7929
commit c8cdf34397
4 changed files with 36 additions and 26 deletions

View File

@ -32,7 +32,7 @@ export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passe
const data = JSON.parse(Response.body); const data = JSON.parse(Response.body);
if(data.type == "PFV"){ if(data.type == "PFV"){
console.log(data);
for(let i=0;i<passerStation.stationlist.length;i++){ for(let i=0;i<passerStation.stationlist.length;i++){
if(passerStation.stationlist[i].code == data.body){ if(passerStation.stationlist[i].code == data.body){
jl3d.changestation(passerStation.stationlist[i].name); jl3d.changestation(passerStation.stationlist[i].name);

View File

@ -47,6 +47,8 @@ export default {
}, },
data() { data() {
return { return {
beforeUnloadTime: '',
gapTime: '',
initCode:null, initCode:null,
localStatic:JL3D_LOCAL_STATIC, localStatic:JL3D_LOCAL_STATIC,
jl3d: null, jl3d: null,
@ -59,8 +61,6 @@ export default {
mapId:'', mapId:'',
lineCode:'', lineCode:'',
deviceCode:'', deviceCode:'',
beforeUnloadTime:'',
gapTime:'',
loadingProjectList: ['login', 'design', 'xty', 'designxty', 'gzb', 'designxty', 'xadt', 'designxadt', 'drts', 'designdrts','bjd'] loadingProjectList: ['login', 'design', 'xty', 'designxty', 'gzb', 'designxty', 'xadt', 'designxadt', 'drts', 'designdrts','bjd']
}; };
}, },
@ -79,11 +79,12 @@ export default {
if (this.loadingProjectList.includes(this.$route.query.project)) { if (this.loadingProjectList.includes(this.$route.query.project)) {
this.$store.dispatch('app/transitionAnimations'); this.$store.dispatch('app/transitionAnimations');
} }
window.addEventListener('beforeunload', this.updateHandler);
window.addEventListener('unload', e => this.unloadHandler(e));
document.querySelector("link[rel*='icon']").href = loginInfo[this.$route.query.project].linkIcon || ProjectIcon[this.$route.query.project]; document.querySelector("link[rel*='icon']").href = loginInfo[this.$route.query.project].linkIcon || ProjectIcon[this.$route.query.project];
}, },
mounted() { mounted() {
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e));
window.addEventListener('unload', e => this.unloadHandler(e));
this.group = this.$route.query.group; this.group = this.$route.query.group;
this.mapId = this.$route.query.mapId; this.mapId = this.$route.query.mapId;
this.lineCode = this.$route.query.lineCode; this.lineCode = this.$route.query.lineCode;
@ -95,26 +96,26 @@ export default {
this.isCctv = false; this.isCctv = false;
} }
}, },
destroyed() {
beforeDestroy() { window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e))
window.removeEventListener('unload', e => this.unloadHandler(e)) window.removeEventListener('unload', e => this.unloadHandler(e))
}, },
destroyed() {
window.removeEventListener('beforeunload', this.updateHandler);
},
methods: { methods: {
updateHandler() { beforeunloadHandler(){
this.beforeUnloadTime=new Date().getTime(); this.beforeUnloadTime=new Date().getTime();
  }, },
unloadHandler(){ async unloadHandler(e){
this.gapTime=new Date().getTime()-this.beforeUnloadTime; this.gapTime=new Date().getTime()-this.beforeUnloadTime;
// //
if(this.gapTime<=5){ console.log( this.gapTime);
deletePassenger(this.$route.query.group,this.initCode).then(netdata => { console.log( this.$route.query.group,this.$route.query.deviceCode);
console.log(netdata); if(this.gapTime<=5){//
//
await deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => {
}); });
} }
}, },
init: function (code) { init: function (code) {
// let mapdata = this.$store.state.socket.device; // let mapdata = this.$store.state.socket.device;
const dom = document.getElementById('jl3d'); const dom = document.getElementById('jl3d');
@ -153,7 +154,11 @@ export default {
this.value = selVal; this.value = selVal;
}, },
back() { back() {
window.close(); deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => {
// console.log(netdata);
window.close();
});
} }
} }
}; };

View File

@ -177,10 +177,11 @@ export default {
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('unload', e => this.unloadHandler(e)) window.removeEventListener('beforeunload', this.updateHandler);
}, },
destroyed() { destroyed() {
window.removeEventListener('beforeunload', this.updateHandler); window.removeEventListener('unload', e => this.unloadHandler(e))
}, },
methods: { methods: {
updateHandler() { updateHandler() {
@ -189,10 +190,10 @@ export default {
unloadHandler(){ unloadHandler(){
this.gapTime=new Date().getTime()-this.beforeUnloadTime; this.gapTime=new Date().getTime()-this.beforeUnloadTime;
// //
alert("netdata");
if(this.gapTime<=5){ if(this.gapTime<=5){
deletePassenger(this.$route.query.group,this.initCode).then(netdata => { deletePassenger(this.$route.query.group,this.initCode).then(netdata => {
console.log(netdata); alert(netdata);
}); });
} }
}, },
@ -274,7 +275,10 @@ export default {
return re; return re;
}, },
back() { back() {
deletePassenger(this.$route.query.group,this.$route.query.deviceCode).then(netdata => {
// console.log(netdata);
window.close(); window.close();
});
} }
} }
}; };

View File

@ -382,11 +382,12 @@ export default {
} }
this.$store.dispatch('training/emitTipFresh'); this.$store.dispatch('training/emitTipFresh');
},
unConnect3d(code){
}, },
// //
onSelected(em) { onSelected(em) {
console.log(em);
const path = window.location.href; const path = window.location.href;
if (path.includes('/practiceDisplay')) { if (path.includes('/practiceDisplay')) {
@ -395,7 +396,7 @@ export default {
if (em.deviceType == 'StationStand') { if (em.deviceType == 'StationStand') {
runPassenger(this.$route.query.group,em.deviceCode).then(netdata => { runPassenger(this.$route.query.group,em.deviceCode).then(netdata => {
console.log(netdata);
if(netdata.data){ if(netdata.data){
const routeData = this.$router.resolve({ const routeData = this.$router.resolve({
path:'/jlmap3d/trafficplan', path:'/jlmap3d/trafficplan',
@ -416,9 +417,9 @@ export default {
} }
if (em.deviceType == 'Train') { if (em.deviceType == 'Train') {
// console.log(em.deviceType );
runPassenger(this.$route.query.group,em.deviceCode).then(netdata => { runPassenger(this.$route.query.group,em.deviceCode).then(netdata => {
console.log(netdata);
if(netdata.data){ if(netdata.data){
const routeData = this.$router.resolve({ const routeData = this.$router.resolve({
path:'/jlmap3d/traffictrain', path:'/jlmap3d/traffictrain',