Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 不是微信内置浏览器
            if (!WXManage.IsWXBrowser(Request))
            {
                Response.Redirect("/RequireWX.aspx?url=" + Request.Url);
                return;
            }

            if (IsPostBack)
            {
                // 手机
                var phone = Request.Form["tel"];
                // 短信验证码
                var code = Request.Form["code"];
                // 身份
                var iden = Int32.Parse(Request.Form["iden"]);

                // 格式检查
                if (!OSecurity.ValidPhone(phone) ||     // 手机号
                    !Regex.IsMatch(code, "^\\d{4}$") || // 验证码4位数字
                    iden < 1 || iden > 5                // 身份在[1,5]
                    )
                {
                    return;
                }
                // 验证码检查
                if (!AuthCode.CheckAuthCode(phone, code))
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "codeError", "alterError($('input[name=code]')[0]);", true);
                    return;
                }

                // 普通会员-业务员-施工队-管理员
                if (iden == 1 || iden == 2 || iden == 4 || iden == 5)
                {
                    if (DataBase.User.Exits(new Objects.User()
                    {
                        phone = phone,
                        identity = iden.ToString()
                    }))
                    {
                        Session["phone"] = phone;
                        Session["iden"]  = iden;
                        Response.Redirect("/UserIndex.aspx");
                    }
                }
            }
        }
Esempio n. 2
0
 protected void vcodeBtn_Click(object sender, EventArgs e)
 {
     if (OSecurity.ValidPhone(tel.Value))
     {
         // 发送间隔校验
         if (Session["vcodeSend"] != null)
         {
             if (OSecurity.DateTimeToTimeStamp(DateTime.Now) - Int64.Parse(Session["vcodeSend"].ToString()) < 60)
             {
                 return;
             }
         }
         Session["vcodeSend"] = OSecurity.DateTimeToTimeStamp(DateTime.Now);
         AuthCode.SendAuthCode(tel.Value);
         ScriptManager.RegisterStartupScript(this, GetType(), "success", "success(1, '验证码已发送', false);", true);
         ScriptManager.RegisterStartupScript(this, GetType(), "successcd", "startCountDown();", true);
     }
     else
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "phoneError", "alterError($('input[name=tel]')[0]);", true);
     }
 }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 不是微信内置浏览器
            if (!WXManage.IsWXBrowser(Request))
            {
                Response.Redirect("/RequireWX.aspx?url=" + Request.Url);
                return;
            }

            if (IsPostBack)
            {
                // 姓名
                var name = Request.Form["name"];
                // 手机
                var phone = Request.Form["tel"];
                // 短信验证码
                var code = Request.Form["code"];
                // 身份
                var iden = Request.Form["iden"];

                // 格式检查
                if (name == "" ||                                  // 姓名不空
                    !OSecurity.ValidPhone(phone) ||                // 手机号
                    !Regex.IsMatch(code, "^\\d{4}$") ||            // 验证码4位数字
                    Int32.Parse(iden) < 1 || Int32.Parse(iden) > 5 // 身份在[1,5]
                    )
                {
                    return;
                }
                // 验证码检查
                if (!AuthCode.CheckAuthCode(phone, code))
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "codeError", "alterError($('input[name=code]')[0]);", true);
                    return;
                }

                // 身份证(业务员-施工队-管理员)
                String IDCardYWY = null;
                // 身份证(经销商)
                String IDCardJXS;
                // 区县(经销商)
                String location;
                // 详细地址
                String detailLocation;

                if (iden == "2" || iden == "4" || iden == "5")
                {
                    IDCardYWY = Request.Form["idcard_ywy"];
                    // 身份证检查
                    if (!OSecurity.ValidIDCard(IDCardYWY))
                    {
                        return;
                    }
                }

                if ((iden == "1" || iden == "2" || iden == "4" || iden == "5") &&
                    DataBase.User.Add(new Objects.User()
                {
                    phone = phone,
                    name = name,
                    identity = iden,
                    IDCard = IDCardYWY
                }))
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "success", "success(" + iden + ", '注册成功', true);", true);
                }
                // 经销商
                else if (iden == "3")
                {
                    IDCardJXS      = Request.Form["idcard_jxs"];
                    location       = Request.Form["location"];
                    detailLocation = Request.Form["detailLocation"];

                    // 不实现
                }
                else
                {
                    return;
                }
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 不是微信内置浏览器
            if (!WXManage.IsWXBrowser(Request))
            {
                Response.Redirect("/RequireWX.aspx?url=" + Request.Url);
                return;
            }
            if (Request.QueryString["aid"] == null)
            {
                Response.Redirect("/Activity.aspx");
                return;
            }

            if (IsPostBack)
            {
                string phone          = Request.Form["tel"];            // 手机
                string name           = Request.Form["name"];           // 姓名
                string code           = Request.Form["code"];           // 验证码
                string location       = Request.Form["location"];       // 地址
                string locationDetail = Request.Form["detailLocation"]; // 详细地址

                // 格式检查
                if (name == "" ||                       // 姓名不空
                    !OSecurity.ValidPhone(phone) ||     // 手机号
                    !Regex.IsMatch(code, "^\\d{4}$") || // 验证码4位数字
                    location == ""                      // 详细地址为空
                    )
                {
                    return;
                }
                // 验证码检查
                if (!AuthCode.CheckAuthCode(phone, code))
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "codeError", "alterError($('input[name=code]')[0]);", true);
                    return;
                }

                string activityID = Request.QueryString["aid"];
                string userID     = Request.QueryString["uid"]; // 即手机号
                if (activityID == "" || userID == "")
                {
                    return;
                }
                var activity = DataBase.Activity.Get(new Objects.Activity()
                {
                    id = activityID
                });
                if (activity == null)
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "noaid", "alert('不存在此活动!');", true);
                    return;
                }
                if (activity.timeEnd <= DateTime.Now)
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "ended", "alert('活动已结束!');", true);
                    return;
                }

                var user = DataBase.User.Get(new Objects.User()
                {
                    phone = userID, identity = "1"
                });
                if (user == null)
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "nouid", "alert('不存在该推荐人!');", true);
                    return;
                }

                if (DataBase.ActivitySign.Add(new Objects.ActivitySign()
                {
                    name = name,
                    phone = phone,
                    location = location,
                    locationDetail = locationDetail,
                    activityID = activityID,
                    shareSource = userID
                }))
                {
                    // 发送新报名提示
                    var admins = DataBase.User.Gets("5");
                    foreach (var admin in admins)
                    {
                        var openid = DataBase.User.GetOpenID(admin);
                        if (!string.IsNullOrEmpty(openid))
                        {
                            WXManage.SendMessage(openid, "有一条新报名信息!");
                        }
                    }
                    Response.Redirect("/ActivitySignSuccess.aspx");
                    return;
                }
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 不是微信内置浏览器
            if (!WXManage.IsWXBrowser(Request))
            {
                Response.Redirect("/RequireWX.aspx?url=" + Request.Url);
                return;
            }
            if (Session["phone"] != null && Session["iden"] != null)
            {
                Response.Redirect("/UserIndex.aspx");
                return;
            }

            if (IsPostBack)
            {
                String phone    = Request.Form["tel"];
                String password = Request.Form["password"];
                int    iden     = Int32.Parse(Request.Form["iden"]);
                bool   reme     = Request.Form["autoLogin"] == "on";

                // 格式检查
                if (!OSecurity.ValidPhone(phone) || // 手机号
                    iden < 1 || iden > 5            // 身份在[1,5]
                    )
                {
                    return;
                }

                // 普通会员-业务员-施工队-管理员
                if (iden == 1 || iden == 2 || iden == 4 || iden == 5)
                {
                    if (DataBase.User.Login(new Objects.User()
                    {
                        phone = phone,
                        password = password,
                        identity = iden.ToString()
                    }))
                    {
                        Session["phone"] = phone;
                        Session["iden"]  = iden;
                        if (reme)
                        {
                            var telc = new HttpCookie("tel", phone);
                            telc.Expires = DateTime.Now.AddDays(15);
                            var pasc = new HttpCookie("__p", OSecurity.AESEncrypt(password));
                            pasc.Expires = DateTime.Now.AddDays(15);
                            var idenc = new HttpCookie("ide", iden.ToString());
                            idenc.Expires = DateTime.Now.AddDays(15);
                            Response.SetCookie(telc);
                            Response.SetCookie(pasc);
                            Response.SetCookie(idenc);
                        }
                        Response.Redirect("/UserIndex.aspx");
                    }
                }
            }
            else
            {
                /* 自动登录 */
                if (Request.Cookies["tel"] != null && Request.Cookies["__p"] != null && Request.Cookies["ide"] != null)
                {
                    var phone    = Request.Cookies["tel"].Value;
                    var password = Request.Cookies["__p"].Value;
                    var iden     = Request.Cookies["ide"].Value;
                    if (DataBase.User.Login(new Objects.User()
                    {
                        phone = phone,
                        password = OSecurity.AESDecrypt(password),
                        identity = iden.ToString()
                    }))
                    {
                        Session["phone"] = phone;
                        Session["iden"]  = iden;
                        Response.Redirect("/UserIndex.aspx");
                    }
                }
            }
        }