/// <summary> /// 获取验证码 /// </summary> /// <param name="phone">手机号</param> public void getsms(string phone) { //MessageBox.ShowMsg(this,"生成随机验证码") Random rnd = new Random(); string str = rnd.Next(100000, 999999).ToString(); AutoRepair.Entity.tb_VerificationCodeEntity model = new AutoRepair.Entity.tb_VerificationCodeEntity(); try { model.Phone = phone; model.Code = str; model.Addtime = DateTime.Now; model.Outtime = DateTime.Now.AddMinutes(5); //MessageBox.ShowMsg(this,"插入数据") int i = AutoRepair.BLL.tb_VerificationCodeBLL.GetInstance().Insert(model); if (i > 0) { SmsHelper.VerifyCodeSms(phone, str); } Response.Write(1); } catch (Exception ex) { Response.Write(-1); Jnwf.Utils.Log.Logger.Log4Net.Error("getsms:" + ex.Data + "|" + ex.Message); } }
/// <summary> /// 注册信息/登入信息 /// </summary> /// <param name="phone">手机号</param> /// <param name="pwd">密码</param> /// <param name="yzm">验证码</param> public void Regisetered(string phone, string openid, string yzm) { //查看是否当前的验证码有效存在 AutoRepair.Entity.tb_VerificationCodeEntity verificationCode = AutoRepair.BLL.tb_VerificationCodeBLL.GetInstance().GetVerificationCodeModelByPhone(phone); if (verificationCode != null) { if (verificationCode.Code.Equals(yzm)) { //该用户是否存在 bool flag = AutoRepair.BLL.tb_UsersBLL.GetInstance().GetUsersModelByPhone(phone); if (!flag) { AutoRepair.Entity.tb_UsersEntity model = new AutoRepair.Entity.tb_UsersEntity(); try { model.Phone = phone.Trim(); model.OpenID = openid.Trim(); model.Addtime = DateTime.Now; int i = AutoRepair.BLL.tb_UsersBLL.GetInstance().Insert(model); if (i > 0) { //MessageBox.ShowMsg(this,"注册成功!") Response.Write(1); } } catch (Exception ex) { //MessageBox.ShowMsg(this,"注册失败"); Response.Write(-1); Jnwf.Utils.Log.Logger.Log4Net.Error("regisetered:" + ex.Data + "|" + ex.Message); } } else { Response.Write(1); } } else { //MessageBox.ShowMsg(this, "验证码错误或已失效"); Response.Write(-2); } } else { //MessageBox.ShowMsg(this, "验证码错误或已失效!"); Response.Write(-2); } }