Пример #1
0
        public JsonResult LoginValidate(Models.WeiXinInfo userInfo)
        {
            var user = this.weUserAppService.GetWeUser(userInfo.OpenId);

            Common.JsonResultStatus rstJson = new Common.JsonResultStatus();
            rstJson.Code = 200;
            // var user = this.weUserAppService.GetWeUser("oCbECv1pwMNyAodYQtRJVvJf_Zsg");
            if (user == null)
            {
                WeUser.Dto.WeUserInputDto input = new WeUser.Dto.WeUserInputDto();
                input.HeadImgUrl = userInfo.HeadImgUrl;
                input.NickName   = userInfo.NickName;
                input.OpenId     = userInfo.OpenId;
                input.IsInit     = 1;
                weUserAppService.CreateWeUser(input);
                rstJson.Msg = "用户第一次初始化成功,即将跳转";
                // string regUrl = string.Format("/RegisterWeChat/Index?openId={0}&HeadImgUrl={1}&NickName={2}&retUrl=", userInfo.OpenId, userInfo.HeadImgUrl, userInfo.NickName, userInfo.RetUrl);
                // rstJson.RedirectUrl = regUrl;
                rstJson.RedirectUrl = userInfo.RetUrl;
                return(Json(rstJson));
            }
            else
            {
                UserPoints.Dto.UserPointsInputDto points = new UserPoints.Dto.UserPointsInputDto();
                points.Ip     = HttpContext.Request.UserHostAddress;
                points.Score  = int.Parse(Common.CommonConst.PointsScore);
                points.UserId = user.Id;
                this.userPointAppService.AddPointsScore(points);

                string encrtpt = Common.DESEncryptEx.Encrypt(string.Format("{0}|{1}|{2}|{3}|{4}", user.Id, user.PhoneNo, user.NickName, userInfo.AccessToken, userInfo.OpenId));
                Logger.Debug("当前用户Cookie" + encrtpt);
                //        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                //1,
                //user.NickName,
                //DateTime.Now,
                //DateTime.Now.Add(FormsAuthentication.Timeout), true, string.Format("{0}|{1}|{2}|{3}|{4}", user.Id, user.PhoneNo, user.NickName, accessToken, opentid)

                //);

                //DateTime.Now.Add(FormsAuthentication.Timeout), true, string.Format("{0}|{1}|{2}|{3}|{4}", user.Id, user.PhoneNo, user.NickName, accessToken, openId)
                //HttpCookie cookie = new HttpCookie(
                //    Common.CommonConst.AuthSaveKey,
                //    FormsAuthentication.Encrypt(ticket));
                HttpCookie cookie = new HttpCookie(
                    Common.CommonConst.AuthSaveKey,
                    encrtpt);
                Response.Cookies.Add(cookie);
                rstJson.Msg         = "用户验证成功,即将跳转";
                rstJson.RedirectUrl = userInfo.RetUrl;
                return(Json(rstJson));
            }


            //return Json(retUrl);
        }
Пример #2
0
 public JsonResult SignValidate()
 {
     UserPoints.Dto.UserPointsInputDto input = new UserPoints.Dto.UserPointsInputDto();
     input.Score  = int.Parse(Common.CommonConst.PointsScore);
     input.UserId = Common.UserHelper.Instance.getUserId();
     Common.JsonResultStatus json = new Common.JsonResultStatus();
     json.Code = 0;
     if (userPointsAppService.SignPoints(input) > 0)
     {
         json.Code   = 1;
         json.Result = Common.CommonConst.PointsScore;
         json.Msg    = "已签到";
     }
     else
     {
         json.Msg = "签到失败";
     }
     return(Json(json));
 }