feat: 增加下发短息按钮
This commit is contained in:
parent
fa3c2e4557
commit
9ed1fd8f20
|
@ -0,0 +1,7 @@
|
|||
<BootstrapInputGroup class="mt-3">
|
||||
<BootstrapInputGroupIcon Icon="fa fa-fw fa-lock" />
|
||||
<BootstrapInput TValue="string" typeof="number" name="code" class="digits" maxlength="4" IsDisabled="IsSendCode" PlaceHolder="验证码" />
|
||||
<Button class="btn-sms" Text="@SendCodeText" OnClick="OnSendCode" LoadingIcon="" IsAsync="true">
|
||||
<Tooltip Title="点击发送验证码" Placement="Placement.Top" />
|
||||
</Button>
|
||||
</BootstrapInputGroup>
|
|
@ -0,0 +1,43 @@
|
|||
namespace BootstrapAdmin.Web.Components;
|
||||
|
||||
public partial class SMSButton : IDisposable
|
||||
{
|
||||
private bool IsSendCode { get; set; } = true;
|
||||
|
||||
private string SendCodeText { get; set; } = "发送验证码";
|
||||
|
||||
private CancellationTokenSource? CancelToken { get; set; }
|
||||
|
||||
async Task OnSendCode()
|
||||
{
|
||||
IsSendCode = false;
|
||||
var count = 60;
|
||||
CancelToken ??= new CancellationTokenSource();
|
||||
while (!CancelToken.IsCancellationRequested && count > 0)
|
||||
{
|
||||
SendCodeText = $"发送验证码 ({count--})";
|
||||
StateHasChanged();
|
||||
await Task.Delay(1000, CancelToken.Token);
|
||||
}
|
||||
SendCodeText = "发送验证码";
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (CancelToken != null)
|
||||
{
|
||||
CancelToken.Cancel();
|
||||
CancelToken.Dispose();
|
||||
CancelToken = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
|
@ -12,13 +12,7 @@
|
|||
<BootstrapInputGroupIcon Icon="fa fa-fw fa-user" />
|
||||
<BootstrapInput TValue="string" type="tel" name="phone" class="digits" maxlength="11" PlaceHolder="手机号码" />
|
||||
</BootstrapInputGroup>
|
||||
<BootstrapInputGroup class="mt-3">
|
||||
<BootstrapInputGroupIcon Icon="fa fa-fw fa-lock" />
|
||||
<BootstrapInput TValue="string" typeof="number" name="code" class="digits" maxlength="4" IsDisabled="true" PlaceHolder="验证码" />
|
||||
<Button class="btn-sms" Text="发送验证码">
|
||||
<Tooltip Title="点击发送验证码" Placement="Placement.Top" />
|
||||
</Button>
|
||||
</BootstrapInputGroup>
|
||||
<SMSButton />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,51 +1,50 @@
|
|||
using BootstrapAdmin.Web.Core;
|
||||
|
||||
namespace BootstrapAdmin.Web.Pages.Account
|
||||
namespace BootstrapAdmin.Web.Pages.Account;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Login
|
||||
{
|
||||
private string? Title { get; set; }
|
||||
|
||||
private bool AllowMobile { get; set; } = true;
|
||||
|
||||
private bool UseMobileLogin { get; set; }
|
||||
|
||||
private bool AllowOAuth { get; set; } = true;
|
||||
|
||||
private bool RememberPassword { get; set; }
|
||||
|
||||
private string? PostUrl { get; set; } = "/Account/Login";
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IDict? DictsService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Login
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
private string? Title { get; set; }
|
||||
base.OnInitialized();
|
||||
|
||||
private bool AllowMobile { get; set; } = true;
|
||||
Title = DictsService.GetWebTitle();
|
||||
}
|
||||
|
||||
private bool UseMobileLogin { get; set; }
|
||||
void OnClickSwitchButton()
|
||||
{
|
||||
PostUrl = UseMobileLogin ? "/Account/Mobile" : "/Account/Login";
|
||||
}
|
||||
|
||||
private bool AllowOAuth { get; set; } = true;
|
||||
void OnSignUp()
|
||||
{
|
||||
|
||||
private bool RememberPassword { get; set; }
|
||||
}
|
||||
|
||||
private string? PostUrl { get; set; } = "/Account/Login";
|
||||
void OnForgotPassword()
|
||||
{
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IDict? DictsService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
Title = DictsService.GetWebTitle();
|
||||
}
|
||||
|
||||
void OnClickSwitchButton()
|
||||
{
|
||||
PostUrl = UseMobileLogin ? "/Account/Mobile" : "/Account/Login";
|
||||
}
|
||||
|
||||
void OnSignUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnForgotPassword()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
height: 32px;
|
||||
}
|
||||
|
||||
.btn-sms {
|
||||
::deep .btn-sms {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue