@using HushianWebApp.Service
@inject AuthService AuthService
@code {
private bool visible = false;
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public string Username { get; set; }
public int ID { get; set; } = 0;
public string Code { get; set; } = string.Empty;
//-----------------
private string code1, code2, code3, code4;
private ElementReference input1, input2, input3, input4;
}
@functions{
async Task Login()
{
visible = true;
ID= await AuthService.login(new Common.Models.Auth.UserSide.AuthRequestFromUserSide()
{
Mobile=Username
});
visible = false;
}
async Task ver()
{
visible = true;
if(await AuthService.Verificationlogin(ID, Code))
await OnMultipleOfThree.InvokeAsync();
visible = false;
}
private async Task MoveNext(ChangeEventArgs e)
{
if (e.Value?.ToString()?.Length == 1)
{
if (input1.Context == null) return;
if (string.IsNullOrEmpty(code1))
await input2.FocusAsync();
else if (string.IsNullOrEmpty(code2))
await input3.FocusAsync();
else if (string.IsNullOrEmpty(code3))
await input4.FocusAsync();
else if (string.IsNullOrEmpty(code4))
{
Code = $"{code1}{code2}{code3}{code4}";
}
}
}
private async Task OnLastInput(ChangeEventArgs e)
{
code4 = e.Value?.ToString();
if (!string.IsNullOrEmpty(code4) && code4.Length == 1)
{
Code = $"{code1}{code2}{code3}{code4}";
await ver();
}
}
}