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.
62 lines
1.9 KiB
62 lines
1.9 KiB
import { Component, OnInit } from '@angular/core'; |
|
import { Router,ActivatedRoute } from '@angular/router' |
|
import { MatSnackBarConfig, MatSnackBar } from '@angular/material/snack-bar'; |
|
import { HttpClient } from '@angular/common/http'; |
|
import { IsLoginService } from '../../is-login.service'//引入服务 |
|
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务 |
|
|
|
|
|
|
|
@Component({ |
|
selector: 'app-lockscreen', |
|
templateUrl: './lockscreen.component.html', |
|
styleUrls: ['./lockscreen.component.scss'] |
|
}) |
|
export class LockscreenComponent implements OnInit { |
|
|
|
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar,private isLogin:IsLoginService) { } |
|
|
|
ngOnInit() { |
|
|
|
} |
|
|
|
roleType:string = '1'; //登录角色 |
|
errmsg :string = ''; //错误信息 |
|
|
|
|
|
|
|
//登录 |
|
onSubmit(e){ |
|
let params = { roleType: this.roleType } |
|
this.http.post('/api/ExamAccounts/SignIn',e,{params}).subscribe((data:any)=>{ |
|
sessionStorage.setItem("realName",data.realName); |
|
sessionStorage.setItem("roleType",data.roleType); |
|
sessionStorage.setItem("token",data.token); |
|
sessionStorage.setItem("refreshToken",data.refreshToken); |
|
sessionStorage.setItem("level",data.level); |
|
this.token.startUp(); //登陆成功启动定时器刷新token |
|
this.roleType == '1'? this.router.navigate(['/home/createexam-index']) : this.router.navigate(['/home/student-index']) |
|
},(err) => {this.errmsg = err}) |
|
} |
|
|
|
//切换登录角色 |
|
toggle (e) { |
|
this.roleType = e |
|
} |
|
|
|
//跳转管理员登录页面 |
|
toAdminLogin () { |
|
this.router.navigate(['/adminLogin']) //跳转管理员登录页面 |
|
} |
|
|
|
//忘记密码弹窗 |
|
forget () { |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('请联系管理员重置密码','确定',config); |
|
} |
|
|
|
|
|
|
|
}
|
|
|