考核考试系统
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.
 
 
 
 
 

58 lines
1.8 KiB

import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Router,ActivatedRoute } from '@angular/router'
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { IsLoginService } from '../../is-login.service'//引入服务
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
})
export class LoginComponent implements OnInit {
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar,private isLogin:IsLoginService) { }
ngOnInit() {
}
errmsg :string = ''; //错误信息
//登录
onSubmit(e){
let params = { roleType: '0' }
this.http.post('/api/Account/SignIn',e,{params}).subscribe((data:any)=>{
sessionStorage.setItem('username',e.name)
sessionStorage.setItem('expires',data.expires)
sessionStorage.setItem('realName',data.realName)
sessionStorage.setItem('roleType',data.roleType)
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
this.token.startUp(); //登陆成功启动定时器刷新token
this.router.navigate(['/home/teachear']) //登陆成功跳转页面
},(err) => {this.errmsg = err})
}
//跳转教员学员登录页面
toAdminLogin () {
this.router.navigate(['/login']) //跳转管理员登录页面
}
//忘记密码弹窗
forget () {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请联系 系统维护技术人员','确定',config);
}
}