|
|
|
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 { MatDialog } from '@angular/material/dialog';
|
|
|
|
import { ChangepasswordComponent } from '../changepassword/changepassword.component'
|
|
|
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
|
|
import { CookieService } from 'ngx-cookie-service';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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, public dialog: MatDialog, public snackBar: MatSnackBar,
|
|
|
|
private cookieService: CookieService) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
setInterval(()=>{
|
|
|
|
this.getTime()
|
|
|
|
},1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
//获得时间
|
|
|
|
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() {
|
|
|
|
let out = confirm("您确定要退出吗")
|
|
|
|
if (out) {
|
|
|
|
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'])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//修改密码
|
|
|
|
changpsw() {
|
|
|
|
let dialogRef = this.dialog.open(ChangepasswordComponent,{ width: '348px' });
|
|
|
|
dialogRef.afterClosed().subscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|