Exemple #1
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(string info, string comId)
        {
            //接收微信用户数据
            var userInfoCache = CookieHelper.GetCurrentWxUser();
            var person        = CookieHelper.GetCurrentPeople();

            if (person == null && !string.IsNullOrEmpty(comId))
            {
                person = IPersonService.Get_ByComId(comId.GetInt());
                CookieHelper.CreatePeople(person);
            }
            UserCenterModel model = new UserCenterModel();

            if (!string.IsNullOrEmpty(info) && userInfoCache == null)
            {
                WXUser entity = info.DeserializeJson <WXUser>();
                if (entity != null)
                {
                    model.User = new Model.User()
                    {
                        NickName   = entity.nickname,
                        HeadImgUrl = entity.headimgurl
                    };
                    userInfoCache = entity;
                    //更新数据
                    IUserService.Update_User(entity);
                    CookieHelper.CreateWxUser(entity);
                }
            }

            model.User = new Model.User()
            {
                HeadImgUrl = userInfoCache.headimgurl,
                NickName   = userInfoCache.nickname
            };
            model.Score = IUserService.Find_PersonUserScore(person.UNID, userInfoCache.openid);
            var signModel = IUserSignService.Get_LastSign(userInfoCache.openid, person.UNID);

            model.SignNum = signModel == null ? 0 : (signModel.SignDate == DateTime.Now.Date || signModel.SignDate == DateTime.Now.AddDays(-1).Date ? signModel.SignNum : 0);

            return(View(model));
        }