コード例 #1
0
        public ActionResult Register(string phone, string password, string code)
        {
            account_member member = entity.account_member.FirstOrDefault(p => p.phone == phone);

            if (member == null)
            {
                SMSTool tool       = new SMSTool();
                bool    codeResult = tool.CheckCode(phone, code);
                if (codeResult == true)
                {
                    account_member new_member = new account_member()
                    {
                        enable       = true,
                        password     = DESTool.Encrypt(password),
                        phone        = phone,
                        sys_datetime = DateTime.Now,
                    };
                    entity.account_member.Add(new_member);
                    if (entity.SaveChanges() > 0)
                    {
                        HttpContext.Session["tpmember"] = new_member;
                        MessageTool.SendMessage(new_member.id, "系统通知", "恭喜您注册成功!");
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                    return(Json("用户创建失败", JsonRequestBehavior.AllowGet));
                }
                return(Json("验证码无效"));
            }
            return(Json("账号已被注册", JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult SendSMSCode(string phone)
        {
            SMSTool tool       = new SMSTool();
            string  code       = tool.CreateCode(phone);
            string  expireTime = tool.expireTime.ToString();
            bool    codeResult = tool.SendCode(phone, 100278, new string[] { code, expireTime });

            if (codeResult == true)
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("验证码发送失败", JsonRequestBehavior.AllowGet));
            }
        }