.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 = "点击获取。";
        }
    }

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值