中化加油站项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

80 lines
2.6 KiB

import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Router, ActivatedRoute } from '@angular/router'
import { CacheTokenService } from '../../service/cache-token.service' //引入服务
import { ChangepasswordComponent } from '../changepassword/changepassword.component'
import { CookieService } from 'ngx-cookie-service';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'app-tabbar',
templateUrl: './tabbar.component.html',
styleUrls: ['./tabbar.component.scss']
})
export class TabbarComponent implements OnInit {
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService,
private cookieService: CookieService, private message: NzMessageService) { }
surname: string
ngOnInit() {
setInterval(() => {
this.getTime()
}, 1000);
this.surname = JSON.parse(sessionStorage.getItem('userdata')).surname
// this.http.get('/api/services/app/Session/GetCurrentLoginInformations').subscribe((data: any) => {
// this.surname = data.result.user.surname
// })
}
//获得时间
time: string
getTime() {
let myDate = new Date();
let y = myDate.getFullYear();
let M = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
let d = myDate.getDate(); //获取当前日(1-31)
let h = myDate.getHours(); //获取当前小时数(0-23)
let m = myDate.getMinutes(); //获取当前分钟数(0-59)
let s = myDate.getSeconds(); //获取当前秒数(0-59)
//检查是否小于10
M = check(M);
d = check(d);
h = check(h);
m = check(m);
s = check(s);
let timestr = y + "-" + M + "-" + d + " " + h + ":" + m + ":" + s;
this.time = timestr;
//时间数字小于10,则在之前加个“0”补位。
function check(i) {
let num = (i < 10) ? ("0" + i) : i;
return num;
}
}
//退出系统
signOut() {
this.message.create('success', `退出成功`);
this.token.delete()
sessionStorage.clear()
window.localStorage.clear()
this.cookieService.set("token", '', new Date(new Date().getTime() + 1), '/');
this.cookieService.set("refreshToken", '', new Date(new Date().getTime() + 1), '/');
this.router.navigate(['/login'])
}
navChange(router) {
this.router.navigate([router])
}
//修改密码
changpsw() {
// let dialogRef = this.dialog.open(ChangepasswordComponent, { width: '348.000051px' });
// dialogRef.afterClosed().subscribe();
}
}