///初始化User public IEnumerator sInitUser() { //OperatingDB.Instance.GetUser(); if (IsLoggedin()) { ///刷新accessToken WWWHelp www = new WWWHelp(); UserRefreshToken urt = new UserRefreshToken(); urt.accessToken = User.Instance.accessToken; urt.refreshToken = User.Instance.refreshToken; urt.client = GlobalConst.ClientFlag + "-" + User.Instance.deviceFlag; string parm = JsonConvert.SerializeObject(urt); //yield return StartCoroutine(www.WWWPostLoad(GlobalConst.UserRefreshTokenPath, parm)); if (www.CheckWWW()) { UserRefreshTokenResponse urtr = JsonConvert.DeserializeObject <UserRefreshTokenResponse>(www.text); if (urtr.result.code == 0) { User.Instance.accessToken = urtr.accessToken; User.Instance.refreshToken = urtr.refreshToken; SaveUser(); yield return(0); //yield return StartCoroutine(GetUserInfo()); if (string.IsNullOrEmpty(nickname)) { //UIManager.Instance.SetVisible(UIName.PanelSetNickname, true); } } else { Debug.Log("resultCode:" + urtr.result.code + " " + urtr.result.description); } } www.Dispose(); } }
public IEnumerator sGetUserInfo() { if (!IsLoggedin()) { yield break; } WWWHelp www = new WWWHelp(); //yield return StartCoroutine(www.WWWGetLoad(GlobalConst.USERPATH + User.Instance.id + GlobalConst.GETUSERINFO, new string[] { "Authorization" }, new string[] { User.Instance.accessToken })); if (www.CheckWWW()) { UserInfoResponse uir = JsonConvert.DeserializeObject <UserInfoResponse>(www.text); if (uir.result.code == 0) { Debug.Log("获取用户信息成功"); if (!uir.user.nickname.Equals(nickname)) { nickname = uir.user.nickname; SaveUser(); } } else if (uir.result.code == 1000) { Debug.Log("resultCode:" + uir.result.code + " " + uir.result.description); } else if (uir.result.code == 1004) { Debug.Log("resultCode:" + uir.result.code + " " + uir.result.description); } else { Debug.Log("resultCode:" + uir.result.code + " " + uir.result.description); } } www.Dispose(); }