import { Component, Input, Output, EventEmitter, signal } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; const API_HOST = 'https://server.fmode.cn'; const APP_ID = 'ncloudmaster'; @Component({ selector: 'app-login-modal', standalone: true, imports: [CommonModule, FormsModule], template: `
`, styles: [` .login-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: center; z-index: 200; animation: fadeIn 0.3s ease-out; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .login-modal { position: relative; background: #0A0A0A; border: 1px solid rgba(0,212,255,0.15); border-radius: 20px; padding: 40px 36px; width: 90%; max-width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 30px rgba(0,212,255,0.08); animation: slideUp 0.4s ease-out; } @keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } .logo-section { text-align: center; margin-bottom: 32px; } .logo-icon { width: 64px; height: 64px; margin: 0 auto 16px; background: rgba(0,212,255,0.1); border: 1px solid rgba(0,212,255,0.3); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: #00D4FF; animation: pulse 2s ease-in-out infinite; } @keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(0,212,255,0.4); } 50% { box-shadow: 0 0 0 12px rgba(0,212,255,0); } } .logo-icon svg { width: 32px; height: 32px; } .logo-title { margin: 0 0 8px 0; font-size: 24px; font-weight: 900; color: #fff; letter-spacing: 2px; } .logo-title span { color: #00D4FF; } .logo-subtitle { margin: 0; font-size: 14px; color: #888; } .login-form { margin-top: 28px; } .form-group { margin-bottom: 20px; } .form-group label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 12px; color: rgba(224,224,224,0.9); text-transform: uppercase; letter-spacing: 0.5px; } .input-wrapper { position: relative; display: flex; align-items: center; } .input-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: rgba(224,224,224,0.4); pointer-events: none; } .form-input { width: 100%; padding: 12px 14px 12px 44px; background: rgba(20,20,20,0.8); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; font-size: 14px; color: #E0E0E0; transition: all 0.2s; box-sizing: border-box; } .form-input:focus { outline: none; border-color: rgba(0,212,255,0.5); box-shadow: 0 0 0 3px rgba(0,212,255,0.1); } .form-input::placeholder { color: rgba(224,224,224,0.4); } .form-input:disabled { opacity: 0.6; cursor: not-allowed; } .code-input-wrapper { display: flex; gap: 10px; } .code-input-wrapper .input-wrapper { flex: 1; } .code-input { letter-spacing: 4px; font-weight: 700; text-align: center; } .btn-send-code { padding: 12px 16px; background: rgba(0,212,255,0.1); border: 1px solid rgba(0,212,255,0.3); border-radius: 10px; color: #00D4FF; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s; white-space: nowrap; min-width: 100px; } .btn-send-code:hover:not(:disabled) { background: rgba(0,212,255,0.2); border-color: rgba(0,212,255,0.5); } .btn-send-code:disabled { opacity: 0.5; cursor: not-allowed; } .btn-submit { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 20px; margin-top: 8px; background: linear-gradient(145deg, rgba(0,212,255,0.15), rgba(0,0,0,0.3)); border: 1px solid rgba(0,212,255,0.4); border-radius: 12px; color: #00D4FF; font-size: 15px; font-weight: 800; cursor: pointer; transition: all 0.2s; } .btn-submit:hover:not(:disabled) { background: linear-gradient(145deg, rgba(0,212,255,0.25), rgba(0,0,0,0.2)); border-color: rgba(0,212,255,0.6); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,212,255,0.2); } .btn-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; } .loading-spinner { width: 16px; height: 16px; border: 2px solid rgba(0,212,255,0.3); border-top-color: #00D4FF; border-radius: 50%; animation: spin 0.8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } .error-msg { padding: 10px 14px; margin-bottom: 12px; background: rgba(255,77,106,0.1); border: 1px solid rgba(255,77,106,0.3); border-radius: 8px; color: #FF4D6A; font-size: 13px; } .footer-hint { margin: 20px 0 0 0; text-align: center; font-size: 12px; color: rgba(224,224,224,0.4); line-height: 1.5; } @media (max-width: 480px) { .login-modal { padding: 28px 20px; } } `] }) export class LoginModalComponent { @Input() visible = false; @Output() loginSuccess = new EventEmitter<{ userId: string; sessionToken: string }>(); phone = ''; code = ''; errorMsg = ''; isLoading = signal(false); countdown = signal(0); countdownTimer: any = null; show(): void { this.visible = true; } hide(): void { this.visible = false; } validatePhone(): void { this.phone = this.phone.replace(/\D/g, '').substring(0, 11); } canSendCode(): boolean { return /^1[3-9]\d{9}$/.test(this.phone); } canSubmit(): boolean { return this.canSendCode() && this.code.length >= 4; } async sendCode(): Promise