コード例 #1
0
        // GET: /Ucenter/
        public ActionResult Register()
        {
            string userAgent = Request.UserAgent;

            string CODE = Request["code"];

            string            STATE    = Request["state"];
            WebchatJsUserinfo userinfo = new WebchatJsUserinfo();

            if (string.IsNullOrEmpty(CODE))
            {
                return(RedirectToAction("WechatLogin", new { redirectUrl = "http://peiban.zzd123.com/Ucenter/Register" }));
            }
            else
            {
                userinfo = WechatJsServices.GetUserInfo(userAgent, CODE);
                var wxusers = unitOfWork.rensRepository.Get(filter: u => u.RenOpenid == userinfo.openid);
                if (wxusers.Count() > 0)
                {
                    return(RedirectToAction("ShengjiVIP"));
                }
            }
            ViewData["userInfo"] = userinfo;
            return(View());
        }
コード例 #2
0
        public ActionResult ShengjiPeibanshi()
        {
            string userAgent = Request.UserAgent;

            string CODE = Request["code"];

            string STATE = Request["state"];

            if (string.IsNullOrEmpty(CODE))
            {
                return(RedirectToAction("WechatLogin", new { redirectUrl = "http://peiban.zzd123.com/Ucenter/ShengjiPeibanshi" }));
            }
            else
            {
                WebchatJsUserinfo userinfo = WechatJsServices.GetUserInfo(userAgent, CODE);

                var wxusers = unitOfWork.rensRepository.Get(filter: u => u.RenOpenid == userinfo.openid);

                if (wxusers.Count() > 0)
                {
                    Ren ren = wxusers.First();
                    ViewData["renuser"] = ren;
                    return(View());
                }

                else
                {
                    //你尚未注册
                    return(RedirectToAction("Register", "Ucenter"));
                }
            }
        }
コード例 #3
0
        public ActionResult GetUserId()
        {
            string CODE  = Request["code"];
            string STATE = Request["state"];

            string userAgent = Request.UserAgent;

            WebchatJsUserinfo userinfo = WechatJsServices.GetUserInfo(userAgent, CODE);

            return(View(userinfo));
        }
コード例 #4
0
        public ActionResult Index()
        {
            string userAgent = Request.UserAgent;

            string CODE = Request["code"];

            string STATE = Request["state"];

            if (string.IsNullOrEmpty(CODE))
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                WebchatJsUserinfo userinfo = WechatJsServices.GetUserInfo(userAgent, CODE);

                var         cus      = unitOfWork.adsCustomersRepository.Get(filter: u => u.CustomerOpenid == userinfo.openid);
                int         aa       = cus.Count();
                AdsCustomer customer = new AdsCustomer();
                if (aa == 0)
                {
                    customer.CustomerOpenid   = userinfo.openid;
                    customer.CustomerNickName = userinfo.nickname;
                    if (userinfo.sex == 0)
                    {
                        customer.CustomerSex = "未知";
                    }
                    if (userinfo.sex == 1)
                    {
                        customer.CustomerSex = "男";
                    }
                    if (userinfo.sex == 2)
                    {
                        customer.CustomerSex = "女";
                    }
                    customer.CustomerUnionid       = userinfo.unionid;
                    customer.CustomerIdentity      = AdsCustomer.IdentiyStatus.未申请计划;
                    customer.CustomerLastLoginTime = System.DateTime.Now;
                    customer.CustomerRegTime       = System.DateTime.Now;

                    customer.CustomerAvatar   = userinfo.headimgurl;
                    customer.CustomerUserName = userinfo.openid;
                    customer.CustomerProvince = userinfo.province;
                    customer.CustomerCity     = userinfo.city;

                    unitOfWork.adsCustomersRepository.Insert(customer);
                    unitOfWork.Save();
                }
                else
                {
                    customer = cus.First() as AdsCustomer;
                }

                Session["CustomerNickName"] = customer.CustomerNickName;
                Session["CustomerOpenid"]   = customer.CustomerOpenid;
                Session["openid"]           = customer.CustomerOpenid;
                Session["CustomerId"]       = customer.CustomerId;

                //   return Redirect(STATE);
                return(RedirectToAction("Calendar"));
            }



            // return View();
        }