コード例 #1
0
ファイル: MemberController.cs プロジェクト: wenlei456/CPCAR
        public ActionResult RegMember(RegUserModel model)
        {
            if (ModelState.IsValid)
            {
                MemberBLL bll = new MemberBLL();
                if (bll.VerRegCode(model.PhoneNumber, model.PhoneCode))
                {
                    FriendCodeBLL fbll = new FriendCodeBLL();

                    DAO.MemberLevel levelModel = new DAO.MemberLevel();
                    DAO.MemberBase  m          = new DAO.MemberBase();
                    m.LoginName = model.loginName;
                    m.PassWord  = Md5Util.PwdMd5(model.passWord);
                    m.Mobile    = model.PhoneNumber;
                    m.Email     = model.eMail;
                    m.State     = 1;
                    int upUser = fbll.GetUpUser(model.FriendCode);
                    m.UpUser   = upUser;//上级用户
                    m.Levels   = 0;
                    m.Integral = 0;
                    m.Source   = "self";
                    m.RegDate  = DateTime.Now;
                    DAO.MemberBase u = bll.Reg(m);                    //注册
                    Session["memberID"] = u.ID;
                    levelModel          = bll.GetLevel(u.ID, upUser); //注册初始化级别
                    VoucherBus vbll = new VoucherBus();
                    vbll.RegGiveAVoucher(u.ID);                       //给一张注册优惠券
                    u.Levels   = levelModel.LevelId;
                    u.Integral = levelModel.MinIntegral;
                    DAO.MemberBase allu = bll.UpdateUser(u);
                    if (allu != null)
                    {
                        //给上级积分
                        bll.GiveUpUserInt(allu.ID, upUser);
                    }
                    return(RedirectToAction("UserHome"));
                }
                else
                {
                    ViewBag.phoneCodeValid = "手机注册码错误";
                    return(View("RegView", model));
                }
            }
            else
            {
                return(View("RegView", model));
            }
        }
コード例 #2
0
ファイル: MemberController.cs プロジェクト: wenlei456/CPCAR
        public ActionResult Reg(string phone, string phonecode, string fcode)
        {
            //RegMsg RegUserModel model

            MemberBLL bll = new MemberBLL();

            if (!bll.VerPhone(phone))
            {
                return(Json(new { r = false, msg = "手机号已经被注册!" }));
            }
            if (bll.VerRegCode(phone, phonecode))    //验证手机号与手机验证码
            {
                FriendCodeBLL fbll = new FriendCodeBLL();

                DAO.MemberLevel levelModel = new DAO.MemberLevel();
                DAO.MemberBase  m          = new DAO.MemberBase();
                m.LoginName = phone;
                m.PassWord  = Md5Util.PwdMd5(phone.Substring(5));
                m.Mobile    = phone;
                //m.Email = "";
                m.State = 1;
                int upUser = fbll.GetUpUser(fcode);
                m.UpUser   = upUser;  //上级用户
                m.Levels   = 0;
                m.Integral = 0;
                m.Source   = "self";
                m.RegDate  = DateTime.Now;
                DAO.MemberBase u = bll.Reg(m);     //注册
                Session["memberID"] = u.ID;
                VoucherBus vbll = new VoucherBus();
                vbll.RegGiveAVoucher(u.ID);              //给一张注册优惠券
                levelModel = bll.GetLevel(u.ID, upUser); //注册初始化级别
                u.Levels   = levelModel.LevelId;
                u.Integral = levelModel.MinIntegral;
                DAO.MemberBase allu = bll.UpdateUser(u);
                if (allu != null)
                {
                    //给上级积分
                    bll.GiveUpUserInt(allu.ID, upUser);
                }

                return(Json(new { r = true, msg = "注册成功,初始密码为您手机号后四位!" }));
            }
            else
            {
                return(Json(new { r = false, msg = "手机验证码错误" }));
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //获取从wxProcess.aspx传递过来的跳转地址reurl
                if (Request.QueryString["reurl"] != null && Request.QueryString["reurl"] != "")
                {
                    reurl = Request.QueryString["reurl"].ToString();
                }

                string code = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    //获取微信回传的code
                    code = Request.QueryString["code"].ToString();
                    OAuth_Token    Model           = Get_token(code); //获取token
                    OAuthUser      OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    DAO.MemberBase m   = new DAO.MemberBase();
                    MemberBLL      bll = new MemberBLL();
                    //if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "")  //已获取得openid及其他信息
                    //{
                    MemberBase selectUser = bll.selectWx(OAuthUser_Model.openid);
                    if (selectUser != null)
                    {
                        bll.updateWx(OAuthUser_Model);

                        Session["memberID"] = selectUser.ID;
                        //Session["mobile"] = model.Mobile;
                        Session.Timeout = 30;
                    }
                    else
                    {
                        FriendCodeBLL fbll = new FriendCodeBLL();

                        DAO.MemberLevel levelModel = new DAO.MemberLevel();
                        m.LoginName = OAuthUser_Model.nickname;
                        //m.LoginName = phone;
                        //m.PassWord = Md5Util.PwdMd5(phone.Substring(5));
                        //m.Mobile = phone;
                        ////m.Email = "";
                        m.State = 1;
                        //int upUser = fbll.GetUpUser(fcode);
                        m.UpUser = 0;    //上级用户
                        //m.Levels = 0;
                        //m.Integral = 0;
                        //m.Source = "self";
                        m.wxOpenid     = OAuthUser_Model.openid;
                        m.wxNickname   = OAuthUser_Model.nickname;
                        m.wxSex        = Convert.ToInt32(OAuthUser_Model.sex);
                        m.wxProvince   = OAuthUser_Model.province;
                        m.wxCity       = OAuthUser_Model.city;
                        m.wxCountry    = OAuthUser_Model.country;
                        m.wxHeadimgurl = OAuthUser_Model.headimgurl;
                        m.wxPrivilege  = OAuthUser_Model.privilege;
                        m.RegDate      = DateTime.Now;
                        DAO.MemberBase u = bll.Reg(m);     //注册
                        Session["memberID"] = u.ID;
                        VoucherBus vbll = new VoucherBus();
                        vbll.RegGiveAVoucher(u.ID);         //给一张注册优惠券
                        levelModel = bll.GetLevel(u.ID, 0); //注册初始化级别
                        u.Levels   = levelModel.LevelId;
                        u.Integral = levelModel.MinIntegral;
                        DAO.MemberBase allu = bll.UpdateUser(u);

                        Session["memberID"] = u.ID;
                        //Session["mobile"] = model.Mobile;
                        Session.Timeout = 30;
                    }



                    ////在页面上输出用户信息
                    //Response.Write("用户OPENID:" + OAuthUser_Model.openid + "<br>用户昵称:" + OAuthUser_Model.nickname + "<br>性别:" + OAuthUser_Model.sex + "<br>所在省:" + OAuthUser_Model.province + "<br>所在市:" + OAuthUser_Model.city + "<br>所在国家:" + OAuthUser_Model.country + "<br>头像地址:" + OAuthUser_Model.headimgurl + "<br>用户特权信息:" + OAuthUser_Model.privilege);
                    ////或跳转到自己的页面,想怎么处理就怎么处理
                    Response.Redirect(reurl);
                    //}
                    //else  //未获得openid,回到wxProcess.aspx,访问弹出微信授权页面,提示用户授权
                    //{
                    //    Response.Redirect("wxProcess.aspx?auth=1");
                    //}
                }
            }
        }