123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { Component, OnInit, signal } from '@angular/core';
- import { CommonModule } from '@angular/common';
- import { FormsModule, ReactiveFormsModule } from '@angular/forms';
- import { Router, RouterModule } from '@angular/router';
- @Component({
- selector: 'app-auth',
- standalone: true,
- imports: [CommonModule, FormsModule, ReactiveFormsModule, RouterModule],
- templateUrl: './auth.html',
- styleUrls: ['./auth.scss']
- })
- export class Auth implements OnInit {
- // 表单数据
- username = signal('');
- password = signal('');
-
- // 状态管理
- isLoading = signal(false);
- errorMessage = signal('');
- successMessage = signal('');
- ngOnInit() {
- // 初始化时可以添加一些动画效果
- }
- onSubmit() {
- this.isLoading.set(true);
- this.errorMessage.set('');
- this.successMessage.set('');
- // 模拟登录请求
- setTimeout(() => {
- if (this.username() === '1' && this.password() === '1') {
- this.successMessage.set('登录成功!');
- this.router.navigate(['/hrauth/hr']);
- // 这里实际项目中应该是导航到主页
- } else {
- this.errorMessage.set('企业凭证或密码错误,请重试');
- }
- this.isLoading.set(false);
- }, 1500);
- }
- constructor(private router: Router){}
- }
|