陈鹏飞
3 years ago
5 changed files with 47 additions and 13 deletions
@ -0,0 +1,39 @@ |
|||||||
|
import { HttpClient } from '@angular/common/http'; |
||||||
|
import { Injectable } from '@angular/core'; |
||||||
|
import { Component, OnInit, Inject } from '@angular/core'; |
||||||
|
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; |
||||||
|
import { ModeManager } from '../babylon/controller/mode-manager'; |
||||||
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
||||||
|
|
||||||
|
@Injectable({ |
||||||
|
providedIn: 'root' |
||||||
|
}) |
||||||
|
export class init3DGuard implements CanActivate { |
||||||
|
|
||||||
|
constructor(private router: Router, private http: HttpClient, private message: NzMessageService,) { } |
||||||
|
|
||||||
|
// 路由守卫
|
||||||
|
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot,): Promise<boolean> { |
||||||
|
return this.getGasStationBaseInfo().then((res: any) => { |
||||||
|
sessionStorage.setItem("3dSceneData", JSON.stringify(res)) |
||||||
|
let isMakeMode = ModeManager.s_isMakeMode |
||||||
|
if (isMakeMode || res.hasBuildingInfo) { |
||||||
|
return true |
||||||
|
} else if (!res.hasBuildingInfo) { |
||||||
|
this.message.info("当前站点没有数字油站!"); |
||||||
|
return false |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//获取 当前加油站基本信息
|
||||||
|
getGasStationBaseInfo() { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
let params = { organizationUnitId: (JSON.parse(sessionStorage.getItem('userdataOfgasstation'))).organization.id } |
||||||
|
this.http.get('/api/services/app/GasStation/Get', { params: params }).subscribe((data: any)=>{ |
||||||
|
resolve(data.result) |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue