UserInfo.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class UserInfo {
  5. //设备sn号
  6. public static string Serialno = string.Empty;
  7. //影创账号
  8. public static string Account = string.Empty;
  9. //影创应用号
  10. public static string AppID = string.Empty;
  11. //影创Token
  12. public static string Token = string.Empty;
  13. //应用Token
  14. public static string User_Token = string.Empty;
  15. //应用uid
  16. public static string uid = string.Empty;
  17. /// <summary>
  18. /// 判断是否为游客账号
  19. /// </summary>
  20. /// <returns><c>true</c>, if vistor account was ised, <c>false</c> otherwise.</returns>
  21. public static bool isVistorAccount()
  22. {
  23. return Serialno == Account;
  24. }
  25. /// <summary>
  26. /// 判断用户是否登陆
  27. /// </summary>
  28. /// <returns><c>true</c>, if login was ised, <c>false</c> otherwise.</returns>
  29. public static bool isLogin()
  30. {
  31. return Account != string.Empty;
  32. }
  33. private string _userToken;
  34. private int _userTokenExpireTime;
  35. private int _id;
  36. private string _nickName;
  37. public string _avatar;
  38. public string _devideID;
  39. public string _phone;
  40. public string _email;
  41. private bool _isActivate;
  42. public string UserToken
  43. {
  44. get => _userToken;
  45. }
  46. public int UserTokenExpireTime
  47. {
  48. get => _userTokenExpireTime;
  49. }
  50. public int Id { get => _id;}
  51. public string NickName { get => _nickName; }
  52. public bool IsActivate { get => _isActivate; }
  53. public void SetTokenInfo(string token, int expireTime)
  54. {
  55. _userToken = token;
  56. _userTokenExpireTime = expireTime;
  57. }
  58. public void SetUserInfo(int id, string token = "", int expireTime = 0, string avatar = "", string nickName = "", bool isActivate=false, string phoneNum = "", string email = "", string deviceID = "")
  59. {
  60. this._id = id;
  61. this._avatar = avatar;
  62. this._nickName = nickName;
  63. this._phone = phoneNum;
  64. this._email = email;
  65. this._devideID = deviceID;
  66. this._isActivate = isActivate;
  67. SetTokenInfo(token, expireTime);
  68. }
  69. public void UserClear(int id, string token = "", int expireTime = 0)
  70. {
  71. SetUserInfo(id, token, expireTime);
  72. }
  73. public void SetNickNameAvatar(string avatar, string nickName)
  74. {
  75. this._avatar = avatar;
  76. this._nickName = nickName;
  77. }
  78. }