Ejemplo n.º 1
0
 /**
  * 授权成功获取用户信息
  */
 public static void authSuccess(Action <Error, UserInfo> action)
 {
     HttpUtil.Http.Get(URLManager.getUserInfoUrl()).OnSuccess(result =>
     {
         if (result != null)
         {
             UserInfoResult userResult = JsonMapper.ToObject <UserInfoResult>(result);
             if (userResult.ret == 1)
             {
                 UserManager.Instance().isLogin  = true;
                 UserManager.Instance().userInfo = userResult.data;
                 // 用户数据持久化
                 UserManager.saveUserAuthToUserDefault(UserManager.Instance().authModel);
                 UserManager.saveUserInfoToUserDefault(UserManager.Instance().userInfo);
                 if (action != null)
                 {
                     action(null, userResult.data);
                 }
             }
             else
             {
                 if (action != null)
                 {
                     action(new Error(userResult.ret, userResult.msg), null);
                 }
             }
         }
     }).OnFail(result =>
     {
         if (action != null)
         {
             action(new Error(500, null), null);
         }
     }).Go();
 }