LoginInputView.cs 2.8 KB

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