/// <summary> /// 登陆 /// </summary> /// <param name="baseApi"></param> /// <returns></returns> public object Do_GetToken(BaseApi baseApi) { LoginParam loginParam = JsonConvert.DeserializeObject <LoginParam>(baseApi.param.ToString()); if (loginParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } if (loginParam.code == Global.XCSECRET) { SessionBag sessionBagX = SessionContainer.GetSession(Global.XCOPENID); if (sessionBagX != null) { if (sessionBagX.Name != "") { SessionContainer.RemoveFromCache(sessionBagX.OpenId); } } AccessTokenContainer.Register(Global.APPID, Global.APPSECRET); var sessionBag = SessionContainer.UpdateSession(null, Global.XCOPENID, Global.XCOPENID); OpenDao openDao = new OpenDao(); SessionUser sessionUser = new SessionUser(); Member member = openDao.GetMember(Utils.GetOpenID(sessionBag.Key)); if (member == null) { throw new ApiException(CodeMessage.SenparcCode, CodeMessage.SenparcCode.ToString()); } else { sessionUser.userType = "MEMBER"; sessionUser.openid = sessionBag.OpenId; sessionUser.memberId = member.memberId; sessionBag.Name = JsonConvert.SerializeObject(sessionUser); SessionContainer.Update(sessionBag.Key, sessionBag); SessionBag bag = new SessionBag(); bag.Name = sessionBag.Key; SessionContainer.UpdateSession(Global.XCOPENID, sessionBag.Key, sessionBag.Key); return(new { token = sessionBag.Key }); } } else { throw new ApiException(CodeMessage.SenparcCode, CodeMessage.SenparcCode.ToString()); } }