LoginInputView.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using UI.Login;
  2. using FairyGUI;
  3. using UnityEngine;
  4. namespace GFGGame
  5. {
  6. public class LoginInputView : BaseWindow
  7. {
  8. private UI_LoginInputUI _ui;
  9. public override void Dispose()
  10. {
  11. if (_ui != null)
  12. {
  13. _ui.Dispose();
  14. _ui = null;
  15. }
  16. base.Dispose();
  17. }
  18. protected override void OnInit()
  19. {
  20. base.OnInit();
  21. packageName = UI_LoginInputUI.PACKAGE_NAME;
  22. _ui = UI_LoginInputUI.Create();
  23. this.viewCom = _ui.target;
  24. this.viewCom.Center();
  25. this.modal = true;
  26. _ui.m_btnSure.onClick.Add(OnClickBtnSure);
  27. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  28. _ui.m_btnRegister.onClick.Add(OnClickBtnRegister);
  29. _ui.m_inputAccount.restrict = "[0-9A-Za-z_]";
  30. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  31. {
  32. _ui.m_inputPassword.promptText = "[color=#B8A492]当前支持免密登录[/color]";
  33. }
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. string account = PlayerPrefs.GetString(GameConst.ACCOUNT_LAST_LOGIN_KEY);
  39. if (account != null)
  40. {
  41. _ui.m_inputAccount.text = account;
  42. }
  43. _ui.m_boxChooseCanal.items = new string[] { "TapTap" , "好游快爆", "Bilibil", "华为", "UC九游(阿里游戏)", "小米", "VIVO", "OPPO", "4399", "联想", "应用宝", "酷派", "魅族", "雷电游戏", "QuickGame_安卓", "WAN665", "AppStore", "抖音", "测试"};
  44. _ui.m_boxChooseCanal.onChanged.Add(onChangedCanal);
  45. }
  46. protected override void OnHide()
  47. {
  48. base.OnHide();
  49. }
  50. protected override void AddEventListener()
  51. {
  52. base.AddEventListener();
  53. EventAgent.AddEventListener(ConstMessage.LOGIN_FAIL, OnLoginFail);
  54. }
  55. protected override void RemoveEventListener()
  56. {
  57. base.RemoveEventListener();
  58. EventAgent.RemoveEventListener(ConstMessage.LOGIN_FAIL, OnLoginFail);
  59. }
  60. private void onChangedCanal()
  61. {
  62. ET.Log.Debug("打印测试======选择的渠道==========" + (_ui.m_boxChooseCanal.selectedIndex + 1));
  63. }
  64. private void OnClickBtnSure()
  65. {
  66. var account = _ui.m_inputAccount.text;
  67. var password = _ui.m_inputPassword.text;
  68. if (string.IsNullOrEmpty(account))
  69. {
  70. PromptController.Instance.ShowFloatTextPrompt("请输入账号");
  71. return;
  72. }
  73. if (!string.IsNullOrEmpty(password))
  74. {
  75. LoginController.Login(account, password).Coroutine();
  76. }
  77. else if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  78. {
  79. LoginController.LoginTest(account).Coroutine();
  80. }
  81. else
  82. {
  83. PromptController.Instance.ShowFloatTextPrompt("请输入密码");
  84. }
  85. }
  86. private void OnClickBtnCancel()
  87. {
  88. this.Hide();
  89. }
  90. //private void OnClickBtnTourist()
  91. //{
  92. // if (GameGlobal.isOfflineVisitor)
  93. // {
  94. // LoginProxy.LoginAsVisitor();
  95. // }
  96. // else
  97. // {
  98. // Alert.Show("游客账号无法保证您的账号安全,且受到充值和时长限制,无法体验全部游戏内容。强烈建议您注册账号登录游戏。")
  99. // .SetLeftButton(true, "进入游戏", (object data) =>
  100. // {
  101. // LoginProxy.LoginAsVisitor();
  102. // })
  103. // .SetRightButton(true, "前往注册", (object data) =>
  104. // {
  105. // ViewManager.Show<RegisterView>();
  106. // })
  107. // .SetClickBlankToClose(true);
  108. // }
  109. //}
  110. private void OnClickBtnRegister()
  111. {
  112. ViewManager.Show<RegisterView>();
  113. }
  114. private void OnLoginFail(EventContext context)
  115. {
  116. string account = (string)context.data;
  117. _ui.m_inputAccount.text = account;
  118. }
  119. }
  120. }