123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using UI.Login;
- using FairyGUI;
- using UnityEngine;
- namespace GFGGame
- {
- public class LoginInputView : BaseWindow
- {
- private UI_LoginInputUI _ui;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_LoginInputUI.PACKAGE_NAME;
- _ui = UI_LoginInputUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- _ui.m_btnSure.onClick.Add(OnClickBtnSure);
- _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
- _ui.m_btnRegister.onClick.Add(OnClickBtnRegister);
- _ui.m_inputAccount.restrict = "[0-9A-Za-z_]";
- if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
- {
- _ui.m_inputPassword.promptText = "[color=#B8A492]当前支持免密登录[/color]";
- }
- }
- protected override void OnShown()
- {
- base.OnShown();
- string account = PlayerPrefs.GetString(GameConst.ACCOUNT_LAST_LOGIN_KEY);
- if (account != null)
- {
- _ui.m_inputAccount.text = account;
- }
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.LOGIN_FAIL, OnLoginFail);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.LOGIN_FAIL, OnLoginFail);
- }
- private void OnClickBtnSure()
- {
- var account = _ui.m_inputAccount.text;
- var password = _ui.m_inputPassword.text;
- if (string.IsNullOrEmpty(account))
- {
- PromptController.Instance.ShowFloatTextPrompt("请输入账号");
- return;
- }
- if (!string.IsNullOrEmpty(password))
- {
- LoginController.Login(account, password).Coroutine();
- }
- else if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
- {
- LoginController.LoginTest(account).Coroutine();
- }
- else
- {
- PromptController.Instance.ShowFloatTextPrompt("请输入密码");
- }
- }
- private void OnClickBtnCancel()
- {
- this.Hide();
- }
- //private void OnClickBtnTourist()
- //{
- // if (GameGlobal.isOfflineVisitor)
- // {
- // LoginProxy.LoginAsVisitor();
- // }
- // else
- // {
- // Alert.Show("游客账号无法保证您的账号安全,且受到充值和时长限制,无法体验全部游戏内容。强烈建议您注册账号登录游戏。")
- // .SetLeftButton(true, "进入游戏", (object data) =>
- // {
- // LoginProxy.LoginAsVisitor();
- // })
- // .SetRightButton(true, "前往注册", (object data) =>
- // {
- // ViewManager.Show<RegisterView>();
- // })
- // .SetClickBlankToClose(true);
- // }
- //}
- private void OnClickBtnRegister()
- {
- ViewManager.Show<RegisterView>();
- }
- private void OnLoginFail(EventContext context)
- {
- string account = (string)context.data;
- _ui.m_inputAccount.text = account;
- }
- }
- }
|