public ActionResult Index(string id, string validCode, string phone) { SuggestionRes response = new SuggestionRes(); #region 各种校验 if (string.IsNullOrWhiteSpace(validCode)) { response.errorCode = 1; return Json(response); } if (string.IsNullOrWhiteSpace(phone) || (!Validator.IsPhone(phone))) { response.errorCode = 2; return Json(response); } if (string.IsNullOrWhiteSpace(validCode)) { response.errorCode = 3; return Json(response); } if (Session["__VCode"] == null || (Session["__VCode"].ToString() != validCode)) { response.errorCode = 6; return Json(response); } #endregion IHuiYuanBLL m_BLL = new HuiYuanBLL(); response.errorCode = m_BLL.GetByPhone(phone, id); //如果成功了,将手机号放入cookies中 Utils.WriteCookie("PhoneFind", phone, 1); return Json(response); }
public ActionResult Index(LoginViewModel model) { SuggestionRes response = new SuggestionRes(); #region 各种校验 if (string.IsNullOrWhiteSpace(model.BiaoShi)) {//标识是否存在 response.errorCode = 11; return Json(response); } if (string.IsNullOrWhiteSpace(model.UserName)) { response.errorCode = 2; return Json(response); } if (string.IsNullOrWhiteSpace(model.Password)) { response.errorCode = 3; return Json(response); } if (model.UserName.Length > 50) { response.errorCode = 4; return Json(response); } if (model.Password.Length > 20 || model.Password.Length < 6) { response.errorCode = 5; return Json(response); } #endregion Langben.IBLL.IHuiYuanBLL m_BLL = new HuiYuanBLL(); ValidationErrors validationErrors = new ValidationErrors(); HuiYuan item = m_BLL.GetByPhone(model.UserName, model.Password, model.BiaoShi); if (item != null) { if (item.State == "未审核") { response.errorCode = 6; } else { //写cookie Account account = new Account(); account.Name = item.MyName; account.PersonName = item.Name; account.Id = item.Id; account.BiaoShi = model.BiaoShi; Utils.WriteCookie("myaccount", account, 7); Utils.WriteCookie("SchoolName", item.SchoolName, 7); Utils.WriteCookie("Name", item.Name, 7); Utils.WriteCookie("PhoneNumber", item.PhoneNumber, 7); Utils.WriteCookie("BiaoShi", model.BiaoShi, 7); response.errorCode = 0; } } else { response.errorCode = 1; } return Json(response); }