Browse Source

[完善]优化初始化路由判断

beijing
邵佳豪 2 years ago
parent
commit
1f41292eca
  1. 43
      src/app/pages/home/home.component.ts

43
src/app/pages/home/home.component.ts

@ -42,34 +42,36 @@ export class HomeComponent implements OnInit {
surname: string
userName: string
ngOnInit(): void {
// this.navChangeService.getMessage().subscribe((message: any) => {
// console.log(message);//send a message
// if (message.name == 'oilstation') {
// this.isGasStationNav = true
// }
// });
if (this.router.url.indexOf('petrolStation') != -1 && sessionStorage.getItem('isGasStation') == 'false') {//控制返回按钮显示
this.isGasStation = JSON.parse(sessionStorage.getItem('isGasStation'))
//初始化登陆 如果是油站用户
if (this.isGasStation) {
this.isGasStationNav = true
this.isGasStationBack = true
} else {
} else {//初始化登陆 如果是管理者用户
this.isGasStationNav = false
this.isGasStationBack = false
}
if (sessionStorage.getItem('isGasStation') == 'true') {
this.isGasStation = true
this.isGasStationNav = true
}
this.router.events.pipe(
filter(event => event instanceof NavigationEnd)
).subscribe((event: any) => {
if (event.url.indexOf('petrolStation') != -1 && sessionStorage.getItem('isGasStation') == 'false') {//控制返回按钮显示
//管理者进入油站页面
if (event.url.indexOf('petrolStation') != -1 && !this.isGasStation) {//控制返回按钮显示
this.isGasStationNav = true
this.isGasStationBack = true
} else {
}
//管理者进入非油站页面
if (event.url.indexOf('petrolStation') == -1 && !this.isGasStation) {//控制返回按钮显示
this.isGasStationNav = false
this.isGasStationBack = false
}
//油站人员进入管理页面
if (event.url.indexOf('petrolStation') == -1 && this.isGasStation) {//控制返回按钮显示
this.isGasStationNav = false
this.isGasStationBack = false
}
//油站人员进入油站
if (event.url.indexOf('petrolStation') != -1 && this.isGasStation) {//控制返回按钮显示
this.isGasStationNav = true
this.isGasStationBack = false
}
});
@ -77,7 +79,7 @@ export class HomeComponent implements OnInit {
setInterval(() => {
this.getTime()
}, 1000);
this.isGasStation = JSON.parse(sessionStorage.getItem('isGasStation'))
if (this.isGasStation) {
this.surname = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).name
this.userName = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).userName
@ -93,6 +95,7 @@ export class HomeComponent implements OnInit {
}
//初次登陆修改密码弹窗
isVisible = false
isConfirmLoading = false
@ -303,6 +306,7 @@ export class HomeComponent implements OnInit {
console.log('标记已读成功')
})
}
close(item) {
this.messageId.forEach((element) => {
if (element.id == item.notification.entityId) {
@ -310,6 +314,7 @@ export class HomeComponent implements OnInit {
}
})
}
//处置
updateState(item, type) {
let body = {

Loading…
Cancel
Save