/// <summary> /// 发送手机验证码(重置密码) /// </summary> /// <returns></returns> public ActionResult ResetPhoneCode() { string phone = Request["phone"].ToString();//取现接受验证码手机号码 //验证注册的手机号码唯一性 var Vphone = HomeBLL.GetUserInfoByPhone(phone); if (Vphone == null) { return(OperContext.PackagingAjaxMsg(AjaxStatu.err, "当前手机号不存在,请确认")); } DateTime Vdate; //Session["RegCode"] = "123456";//验证码 //Session["Vdate"] = DateTime.Now;//验证码发送时间 //return OperContext.PackagingAjaxMsg(AjaxStatu.ok, "验证码已发送您的手机,请获取"); string count = SendPhoneCode.SendVerifyCode(phone, out Vdate);//发送验证码 if (count != "") { Session["RegCode"] = count; //验证码 Session["Vdate"] = Vdate; //验证码发送时间 return(OperContext.PackagingAjaxMsg(AjaxStatu.ok, "验证码已发送您的手机,请获取")); } else { return(OperContext.PackagingAjaxMsg(AjaxStatu.err, "验证码发送失败")); } }
//获取验证码按钮 被点击 private void ButtonGetPhoneCode_Click(object sender, EventArgs e) { //1检查手机号 //2发送短信 //3点击注册按钮时对比验证码是否是发送出去的验证码。及时间是否在有效期内。 if (!IsPhoneset(textBoxPhone.Text)) { System.Windows.Forms.MessageBox.Show("请输入正确的手机号", "提示:"); return; } //禁用验证码按钮 this.buttonGetPhoneCode.Enabled = false; //随机验证码 Random rd = new Random(); int a = rd.Next(0, 10); int b = rd.Next(0, 10); int c = rd.Next(0, 10); int d = rd.Next(0, 10); phoneCode = a.ToString() + b.ToString() + c.ToString() + d.ToString(); int result = SendPhoneCode.sendVerifyPhoneMsg(phoneNum, "注册验证码" + phoneCode + ",2分钟内有效。"); if (result != 0) { System.Windows.Forms.MessageBox.Show("密码找回功能维护中!稍后再试!" + result); return; } else { int waitCount = 120; //开启一个计时器 System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Enabled = true; timer.Start(); timer.Tick += (sen, eve) => { waitCount--; this.buttonGetPhoneCode.Text = waitCount + "(s)内有效"; if (waitCount == 0) { phoneCode = ""; this.buttonGetPhoneCode.Enabled = true;//恢复验证码按钮 this.buttonGetPhoneCode.Text = "获取短信验证码"; ((System.Windows.Forms.Timer)sen).Stop(); ((System.Windows.Forms.Timer)sen).Dispose(); } }; } }
//确定 teamviewer 和其他的一些 干扰排除 public void timerExcludeOKButtonCallBack(object sender, EventArgs e) { Point btnPos = new Point(); double result = MatchTemplate(ref btnPos); //Debug.Print("排除确定按钮"+ result); //处理验证码*********************************** btnPos = new Point(); result = MatchTemplate(ref btnPos); if (result > 0.78) { // MessageBox.Show("发现了验证码"+result); // TipSound.play(Application.StartupPath + @"\thank.wav"); SendPhoneCode.sendVerifyPhoneMsg(ConfigurationManager.AppSettings["phone"], "注册验证码666,2分钟内有效。"); Environment.Exit(0); } else { // MessageBox.Show(result.ToString()); } }
public ActionResult SendCode() { string phone = Request["phone"].ToString();//取现接受验证码手机号码 //验证注册的手机号码唯一性 //DataTable Vphone = UserBLL.Vphone(phone); //if (Vphone != null && Vphone.Rows.Count > 0) //{ // return OperContext.PackagingAjaxMsg(AjaxStatu.err, "当前手机号已存在,请换更换"); //} DateTime Vdate = DateTime.Now; string count = SendPhoneCode.SendVerifyCode(phone, out Vdate);//发送验证码 if (count != "") { Session["RegCode"] = count; //验证码 Session["Vdate"] = Vdate; //验证码发送时间 return(OperContext.PackagingAjaxMsg(AjaxStatu.ok, "验证码已发送您的手机,请获取")); } else { return(OperContext.PackagingAjaxMsg(AjaxStatu.err, "验证码发送失败")); } }
/// <summary> /// 设置密码是验证码 /// </summary> /// <returns></returns> public ActionResult SendCodePwd() { var phone = User.Identity.Name;//登陆者手机号码 //验证注册的手机号码唯一性 if (phone == null && phone == "") { return(OperContext.PackagingAjaxMsg(AjaxStatu.err, "当前用户未登录,请先登录")); } DateTime Vdate = DateTime.Now; string count = SendPhoneCode.SendVerifyCode(phone, out Vdate);//发送验证码 if (count != "") { Session["RegCode"] = count; //验证码 Session["Vdate"] = Vdate; //验证码发送时间 return(OperContext.PackagingAjaxMsg(AjaxStatu.ok, "验证码已发送您的手机,请获取")); } else { return(OperContext.PackagingAjaxMsg(AjaxStatu.err, "验证码发送失败")); } }
//点击获取短信验证码 private void buttonGetPhoneCode_Click(object sender, EventArgs e) { this.buttonGetPhoneCode.Enabled = false;//禁用验证码按钮 //1检查手机号 //2发送短信 //3点击注册按钮时对比验证码是否是发送出去的验证码。及时间是否在有效期内。 if (accRight == false) { labelregistResult.Text = "注册账号格式不正确!"; return; } else if (psdRight == false) { labelregistResult.Text = "注册密码格式不正确!"; return; } else if (phoneRight == false) { labelregistResult.Text = "手机号格式不正确!"; return; } else { //随机验证码 Random rd = new Random(); int a = rd.Next(0, 10); int b = rd.Next(0, 10); int c = rd.Next(0, 10); int d = rd.Next(0, 10); phoneCode = a.ToString() + b.ToString() + c.ToString() + d.ToString(); // MessageBox.Show(phoneCode+" "+ textBoxRegistPhone.Text); int result = SendPhoneCode.sendVerifyPhoneMsg(textBoxRegistPhone.Text, "注册验证码" + phoneCode + ",2分钟内有效。"); if (result != 0) { MessageBox.Show("注册功能维护中!稍后再试!" + result); return; } else { int waitCount = 120; //开启一个计时器 System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Enabled = true; timer.Start(); timer.Tick += (sen, eve) => { waitCount--; this.buttonGetPhoneCode.Text = waitCount + "(s)内有效"; if (waitCount == 0) { phoneCode = ""; this.buttonGetPhoneCode.Enabled = true;//恢复验证码按钮 this.buttonGetPhoneCode.Text = "获取短信验证码"; ((System.Windows.Forms.Timer)sen).Stop(); ((System.Windows.Forms.Timer)sen).Dispose(); } }; } } }