LoginInputView.cs 2.9 KB

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