static void Init() { window = ScriptableWizard.DisplayWizard<MyWindow>("Title"); // Get existing open window or if none, make a new one: window.minSize = new Vector2(500, 300); user = User.CreateInstance("User") as User; UserSaveLoad userSL = UserSaveLoad.CreateInstance("UserSaveLoad") as UserSaveLoad; userSL.LoadData(); user.InitUser(); user.SetUser(userSL.myData._iUser.userID, userSL.myData._iUser.userNickName, userSL.myData._iUser.userName, userSL.myData._iUser.accessToken, userSL.myData._iUser.refreshToken); //Debug.LogError(user.nickname); }
///检测是否已登录 public bool IsLoggedin() { UserSaveLoad userSL = new UserSaveLoad(); userSL.LoadData(); if (string.IsNullOrEmpty(userSL.myData._iUser.userID)) { return(false); } else { return(true); } }
public void InitUser() { if (IsLoggedin()) { UserSaveLoad userSL = new UserSaveLoad(); userSL.LoadData(); HTTPRequest request = new HTTPRequest(new Uri(GlobalConst.UserLoginPath), OnRefreshRequestFinished); request.MethodType = BestHTTP.HTTPMethods.Post; request.AddHeader("Content-Type", "application/json;charset=utf-8"); UserRefreshToken urt = new UserRefreshToken(); urt.accessToken = userSL.myData._iUser.accessToken; urt.refreshToken = userSL.myData._iUser.refreshToken; urt.client = GlobalConst.ClientFlag + "-" + deviceFlag; string parm = JsonConvert.SerializeObject(urt); byte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(parm); request.RawData = data; } }