private void SendPhoneVerifyCode(HttpContext context)
        {
            string phone = String_Manage.Return_Request_Str("Phone");

            //前台生成的验证码,用于点击发送验证码前验证用
            string send_code_yzm = String_Manage.Return_Request_Str("send_code_yzm");

            if (send_code_yzm != "")
            {
                try
                {
                    if (HttpContext.Current.Session["code"] != null)
                    {
                        if (!string.IsNullOrEmpty(HttpContext.Current.Session["code"].ToString()))
                        {
                            string str_yzm = HttpContext.Current.Session["code"].ToString();
                            if (send_code_yzm != str_yzm)
                            {
                                context.Response.Write("error_yzm");
                            }
                            else
                            {
                                if (phone != "")
                                {
                                    Random rd   = new Random();
                                    string code = rd.Next(100000, 999999).ToString();

                                    try
                                    {
                                        if (HttpContext.Current.Session["PhoneVerifyCode"] == null)
                                        {
                                            HttpContext.Current.Session["PhoneVerifyCode"] = code + "-" + phone;
                                        }
                                        else
                                        {
                                            if (string.IsNullOrEmpty(HttpContext.Current.Session["PhoneVerifyCode"].ToString()))
                                            {
                                                HttpContext.Current.Session["PhoneVerifyCode"] = code + "-" + phone;
                                            }
                                            else
                                            {
                                                string strSess = HttpContext.Current.Session["PhoneVerifyCode"].ToString();
                                                HttpContext.Current.Session["PhoneVerifyCode"] = strSess + "," + code + "-" + phone;
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        HttpContext.Current.Session["PhoneVerifyCode"] = code + "-" + phone;
                                    }
                                    finally
                                    {
                                        //判断当前用户是否已经绑定过手机
                                        var istel = ValidatePhone_Function(context, phone);
                                        if (istel != "ok")
                                        {
                                            context.Response.Write(istel);
                                        }
                                        else
                                        {
                                            #region  发送短信
                                            string shortMessageWord = "衣品搭配注册验证码:" + code + ",欢迎加入衣品搭配。";
                                            string result           = Send_Short_Message.Send_Message_Short(shortMessageWord, phone);
                                            //string result = "ok";
                                            //result = result + code;

                                            context.Response.Write(result);
                                            #endregion
                                        }
                                    }
                                }
                                else
                                {
                                    context.Response.Write("notel");
                                }
                            }
                        }
                        else
                        {
                            context.Response.Write("noyzm");
                        }
                    }
                    else
                    {
                        context.Response.Write("noyzm");
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                context.Response.Write("noyzm");
            }
        }
Beispiel #2
0
        private void SendPhoneVerifyCode(HttpContext context)
        {
            int uid = CheckIsLogin_HongRenHui.GetUserID("FINDRED_HREN_USERID");

            string phone = "";

            user_model = user_bll.GetModel(uid);

            if (user_model != null)
            {
                phone = user_model.TEL;
            }

            if (phone != "")
            {
                Random rd   = new Random();
                string code = rd.Next(100000, 999999).ToString();



                //前台生成的验证码,用于点击发送验证码前验证用
                string send_code_yzm = String_Manage.Return_Request_Str("send_code_yzm");

                if (send_code_yzm != "")
                {
                    try
                    {
                        if (HttpContext.Current.Session["code"] != null)
                        {
                            if (!string.IsNullOrEmpty(HttpContext.Current.Session["code"].ToString()))
                            {
                                string str_yzm = HttpContext.Current.Session["code"].ToString();
                                if (send_code_yzm != str_yzm)
                                {
                                    context.Response.Write("error_yzm");
                                }
                                else
                                {
                                    try
                                    {
                                        if (HttpContext.Current.Session["PhoneVerifyCode"] == null)
                                        {
                                            HttpContext.Current.Session["PhoneVerifyCode"] = code + "-" + phone;
                                        }
                                        else
                                        {
                                            if (string.IsNullOrEmpty(HttpContext.Current.Session["PhoneVerifyCode"].ToString()))
                                            {
                                                HttpContext.Current.Session["PhoneVerifyCode"] = code + "-" + phone;
                                            }
                                            else
                                            {
                                                string strSess = HttpContext.Current.Session["PhoneVerifyCode"].ToString();
                                                HttpContext.Current.Session["PhoneVerifyCode"] = strSess + "," + code + "-" + phone;
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        HttpContext.Current.Session["PhoneVerifyCode"] = code + "-" + phone;
                                    }
                                    finally
                                    {
                                        //判断当前用户是否已经绑定过手机
                                        #region  发送短信
                                        string shortMessageWord = "衣品搭配密码找回验证码:" + code + ",牢记密码,小主记得常来哦。";
                                        string result           = Send_Short_Message.Send_Message_Short(shortMessageWord, phone);
                                        //string result = "ok";
                                        //result = result + code;

                                        context.Response.Write(result);
                                        #endregion
                                    }
                                }
                            }
                            else
                            {
                                context.Response.Write("noyzm");
                            }
                        }
                        else
                        {
                            context.Response.Write("noyzm");
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    context.Response.Write("noyzm");
                }
            }
            else
            {
                context.Response.Write("nologin");
            }
        }