LoginInputView.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. _ui = UI_LoginInputUI.Create();
  22. this.viewCom = _ui.target;
  23. this.viewCom.Center();
  24. this.modal = true;
  25. _ui.m_btnSure.onClick.Add(OnClickBtnSure);
  26. _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
  27. _ui.m_btnRegister.onClick.Add(OnClickBtnRegister);
  28. }
  29. protected override void OnShown()
  30. {
  31. base.OnShown();
  32. string account = PlayerPrefs.GetString(GameConst.ACCOUNT_LAST_LOGIN_KEY);
  33. if (account != null)
  34. {
  35. _ui.m_inputAccount.text = account;
  36. }
  37. }
  38. protected override void OnHide()
  39. {
  40. base.OnHide();
  41. }
  42. private void OnClickBtnSure()
  43. {
  44. var account = _ui.m_inputAccount.text;
  45. var password = _ui.m_inputPassword.text;
  46. if (string.IsNullOrEmpty(account))
  47. {
  48. PromptController.Instance.ShowFloatTextPrompt("请输入账号");
  49. return;
  50. }
  51. if (!string.IsNullOrEmpty(password))
  52. {
  53. LoginController.Login(account, password).Coroutine();
  54. }
  55. else if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  56. {
  57. LoginController.LoginTest(account).Coroutine();
  58. }
  59. else
  60. {
  61. PromptController.Instance.ShowFloatTextPrompt("请输入密码");
  62. }
  63. }
  64. private void OnClickBtnCancel()
  65. {
  66. this.Hide();
  67. }
  68. //private void OnClickBtnTourist()
  69. //{
  70. // if (GameGlobal.isOfflineVisitor)
  71. // {
  72. // LoginProxy.LoginAsVisitor();
  73. // }
  74. // else
  75. // {
  76. // Alert.Show("游客账号无法保证您的账号安全,且受到充值和时长限制,无法体验全部游戏内容。强烈建议您注册账号登录游戏。")
  77. // .SetLeftButton(true, "进入游戏", (object data) =>
  78. // {
  79. // LoginProxy.LoginAsVisitor();
  80. // })
  81. // .SetRightButton(true, "前往注册", (object data) =>
  82. // {
  83. // ViewManager.Show<RegisterView>();
  84. // })
  85. // .SetClickBlankToClose(true);
  86. // }
  87. //}
  88. private void OnClickBtnRegister()
  89. {
  90. ViewManager.Show<RegisterView>();
  91. }
  92. }
  93. }