.net/wpf 验证码倒计时

protected DispatcherTimer showtime;//声明-定时器

//发送验证码
private void Click_01(object sender, RoutedEventArgs e)
{
string S_Account_ = S_Account.Text.ToString().Trim();
bool State_Count = dbs_06.Select_173(S_Account_);
if (State_Count == true)
{
bool ID_Phone_State = 10Base.CheckPhone.IsMobilePhone(S_Account);
if (ID_Phone_State == true)
{
int Count = dbs_06.Page_Load(S_Account_);
if (Count > 0)
{
Application.Current.Properties[“mobile_code”] = Count;
Verification_Code = 60;
IDVerification_Code.IsEnabled = false;
//查询-定时器
dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(Select_Send);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Start();
}
else
{
MyCustomControlLibrary.MMessageBox.ShouBox(“网络异常,验证码发送失败!请一分钟后重试。”, “信 息”, MyCustomControlLibrary.MMessageBox.ButtonType.Yes
, MyCustomControlLibrary.MMessageBox.IconType.error, Orientation.Horizontal, “是”, null); TextBlock_01.Foreground = Brushes.Red;
}
}
else { MyCustomControlLibrary.MMessageBox.ShowAlert(“请输入正确的手机号码!”, Orientation.Horizontal, null, “#FFBDE1FF”, false, true, 2); TextBlock_01.Foreground = Brushes.Red; }
}
else { MyCustomControlLibrary.MMessageBox.ShowAlert(“该账号已经存在了!”, Orientation.Horizontal, null, “#FFBDE1FF”, false, true, 2); TextBlock_01.Foreground = Brushes.Red; }
}
//验证码倒计时
private void Select_Send(object sender, EventArgs e)
{
Verification_Code–;
IDVerification_Code.Content = “发送验证码(” + Verification_Code + “)”;
TextBlock_09.Text = “验证码已发送…”;
if (Verification_Code < 1)
{

            dispatcherTimer.Stop();
            IDVerification_Code.IsEnabled = true;
            TextBlock_09.Text = string.Empty;
            IDVerification_Code.Content = "发送验证码(60)";
            TextBlock_09.Text = "点击获取。";
        }
    }

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

发布了115 篇原创文章 · 获赞 36 · 访问量 9889

猜你喜欢

转载自blog.csdn.net/weixin_44548307/article/details/102974672