DlgLoginFaild.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using TMPro;
  7. using UnityEngine;
  8. using UnityEngine.UI;
  9. namespace Assets
  10. {
  11. /// <summary> 请求状态枚举 </summary>
  12. public enum RequestState
  13. {
  14. Success,
  15. /// <summary> 不在白名单 </summary>
  16. HashFailed,
  17. /// <summary> Mac地址错误 </summary>
  18. MacFailed,
  19. /// <summary> 请求超时 </summary>
  20. TimeOut,
  21. /// <summary> 频繁请求,请求超限制 </summary>
  22. Frequently,
  23. /// <summary> 网络连接失败 </summary>
  24. URLFailed,
  25. }
  26. public class DlgLoginFaild : BasePanel
  27. {
  28. public Button confirm;
  29. public TextMeshProUGUI faildMsg;
  30. RequestState requestState;
  31. public override void OnCloseWindow()
  32. {
  33. }
  34. public override void OnDestroyWindow()
  35. {
  36. }
  37. public override void OnInitWindow()
  38. {
  39. OnShowWindow();
  40. LanguageMatchManager.Instance.changeLanguage += () =>
  41. {
  42. faildMsg.text = LanguageMatchManager.Instance.GetLanByKey(requestState.ToString());
  43. };
  44. }
  45. public void Update()
  46. {
  47. }
  48. public override void OnShowWindow()
  49. {
  50. switch (StepManager.requestCode)
  51. {
  52. case 1:
  53. //网络连接失败
  54. requestState = RequestState.URLFailed;
  55. break;
  56. case 1001:
  57. //Mac地址错误
  58. requestState = RequestState.MacFailed;
  59. break;
  60. case 1002:
  61. //登录超时
  62. requestState = RequestState.URLFailed;
  63. break;
  64. case 1003:
  65. //频繁请求,请求超限制
  66. requestState = RequestState.URLFailed;
  67. break;
  68. case 1004:
  69. //不在白名单
  70. requestState = RequestState.HashFailed;
  71. break;
  72. case 1005:
  73. //Mac未绑定
  74. requestState = RequestState.MacFailed;
  75. break;
  76. case 1006:
  77. //账号已绑定Mac地址
  78. requestState = RequestState.MacFailed;
  79. break;
  80. case 1007:
  81. //Mac请求网络错误
  82. requestState = RequestState.URLFailed;
  83. break;
  84. case 1008:
  85. //Login请求网络错误
  86. requestState = RequestState.URLFailed;
  87. break;
  88. }
  89. faildMsg.text = LanguageMatchManager.Instance.GetLanByKey(requestState.ToString());
  90. }
  91. private void Awake()
  92. {
  93. confirm.onClick.AddListener(() =>
  94. {
  95. UIManager.Instance.HideUI(WindowID.DlgLoginFaild);
  96. UIManager.Instance.HideUI(WindowID.DlgLoading);
  97. });
  98. }
  99. }
  100. }