|
|
@@ -11,6 +11,8 @@ namespace GFGGame
|
|
|
{
|
|
|
private UI_LoginInputUI _ui;
|
|
|
|
|
|
+ private List<AccountPasswordModel> _accountPasswordList;
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
if (_ui != null)
|
|
|
@@ -18,6 +20,7 @@ namespace GFGGame
|
|
|
_ui.Dispose();
|
|
|
_ui = null;
|
|
|
}
|
|
|
+
|
|
|
base.Dispose();
|
|
|
}
|
|
|
|
|
|
@@ -33,8 +36,13 @@ namespace GFGGame
|
|
|
_ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
|
_ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
|
_ui.m_btnRegister.onClick.Add(OnClickBtnRegister);
|
|
|
+ _ui.m_btnSkipAccount.onClick.Add(OnClickBtnOpenZhAccount);
|
|
|
+ _ui.m_btnSkipPasword.onClick.Add(OnClickBtnOpenZhUpPassword);
|
|
|
+
|
|
|
+ _ui.m_comAccount.m_selBtin.onClick.Add(OnClickOpenAccountListBtn);
|
|
|
+ _ui.m_comAccount.m_txtAccount.restrict = "[0-9A-Za-z_]";
|
|
|
+ _ui.m_comAccount.m_list.itemRenderer = RenderListItem;
|
|
|
|
|
|
- _ui.m_inputAccount.restrict = "[0-9A-Za-z_]";
|
|
|
if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
|
|
|
{
|
|
|
_ui.m_inputPassword.promptText = "[color=#B8A492]当前支持免密登录[/color]";
|
|
|
@@ -46,11 +54,25 @@ namespace GFGGame
|
|
|
protected override void OnShown()
|
|
|
{
|
|
|
base.OnShown();
|
|
|
- string account = PlayerPrefs.GetString(GameConst.ACCOUNT_LAST_LOGIN_KEY);
|
|
|
+ _accountPasswordList = AccountManager.Instance.GetAccounts();
|
|
|
+ string account = null;
|
|
|
+ string password = null;
|
|
|
+ if (_accountPasswordList != null && _accountPasswordList.Count > 0)
|
|
|
+ {
|
|
|
+ account = _accountPasswordList[0].Account;
|
|
|
+ password = _accountPasswordList[0].Password;
|
|
|
+ }
|
|
|
+
|
|
|
if (account != null)
|
|
|
{
|
|
|
- _ui.m_inputAccount.text = account;
|
|
|
+ _ui.m_comAccount.m_txtAccount.text = account;
|
|
|
}
|
|
|
+
|
|
|
+ if (password != null)
|
|
|
+ {
|
|
|
+ _ui.m_inputPassword.text = password;
|
|
|
+ }
|
|
|
+
|
|
|
UpdateChannelBox(false);
|
|
|
}
|
|
|
|
|
|
@@ -72,22 +94,34 @@ namespace GFGGame
|
|
|
EventAgent.RemoveEventListener(ConstMessage.LOGIN_FAIL, OnLoginFail);
|
|
|
}
|
|
|
|
|
|
+ private void OnClickBtnOpenZhAccount()
|
|
|
+ {
|
|
|
+ ViewManager.Show<ZhaoHuiAccountView>();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnClickBtnOpenZhUpPassword(EventContext context)
|
|
|
+ {
|
|
|
+ string account = context.data as string;
|
|
|
+ ViewManager.Show<ZhaoHuiPasswordView>(account);
|
|
|
+ }
|
|
|
+
|
|
|
private void OnClickBtnSure()
|
|
|
{
|
|
|
- var account = _ui.m_inputAccount.text;
|
|
|
+ var account = _ui.m_comAccount.m_txtAccount.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();
|
|
|
+ LoginController.Login(account, password).Coroutine();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -105,10 +139,94 @@ namespace GFGGame
|
|
|
ViewManager.Show<RegisterView>();
|
|
|
}
|
|
|
|
|
|
+ private void OnClickOpenAccountListBtn()
|
|
|
+ {
|
|
|
+ if (_accountPasswordList.Count == 0)
|
|
|
+ {
|
|
|
+ _ui.m_comAccount.m_list.selectedIndex = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_ui.m_comAccount.m_c1.selectedIndex == 0)
|
|
|
+ {
|
|
|
+ //显示账号缓存列表
|
|
|
+ OnShowAccountList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //隐藏账号缓存列表
|
|
|
+ OnHideAccountList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //显示账号缓存列表
|
|
|
+ private void OnShowAccountList()
|
|
|
+ {
|
|
|
+ _accountPasswordList = AccountManager.Instance.GetAccounts();
|
|
|
+ _ui.m_comAccount.m_list.numItems = _accountPasswordList.Count;
|
|
|
+ _ui.m_comAccount.m_c1.selectedIndex = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //隐藏账号缓存列表
|
|
|
+ private void OnHideAccountList()
|
|
|
+ {
|
|
|
+ _ui.m_comAccount.m_c1.selectedIndex = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定数据到账号缓存列表
|
|
|
+ private void RenderListItem(int index, GObject obj)
|
|
|
+ {
|
|
|
+ AccountPasswordModel accountPassword = _accountPasswordList[index];
|
|
|
+ UI_ButAccountItem item = UI_ButAccountItem.Proxy(obj);
|
|
|
+ item.m_txtAccountItem.text = accountPassword.Account;
|
|
|
+ item.target.data = accountPassword;
|
|
|
+ item.target.onClick.Add(OnClickSelAccount);
|
|
|
+
|
|
|
+ item.m_btnDel.data = accountPassword.Account;
|
|
|
+ item.m_btnDel.onClick.Add(OnClickDelAccountCache);
|
|
|
+
|
|
|
+ UI_ButAccountItem.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ //从账号缓存列表中选择账号
|
|
|
+ private void OnClickSelAccount(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ AccountPasswordModel accountPassword = obj.data as AccountPasswordModel;
|
|
|
+ _ui.m_comAccount.m_txtAccount.text = accountPassword?.Account;
|
|
|
+ _ui.m_inputPassword.text = accountPassword?.Password;
|
|
|
+ OnHideAccountList();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除账号缓存列表
|
|
|
+ private void OnClickDelAccountCache(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ string account = obj.data.ToString();
|
|
|
+ AccountManager.Instance.DeleteAccount(account);
|
|
|
+ _accountPasswordList = AccountManager.Instance.GetAccounts();
|
|
|
+ _ui.m_comAccount.m_list.numItems = _accountPasswordList.Count;
|
|
|
+ if (_accountPasswordList.Count == 0)
|
|
|
+ {
|
|
|
+ _ui.m_comAccount.m_list.selectedIndex = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_accountPasswordList.Count == 0)
|
|
|
+ {
|
|
|
+ _ui.m_comAccount.m_txtAccount.text = null;
|
|
|
+ _ui.m_inputPassword.text = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _ui.m_comAccount.m_txtAccount.text = _accountPasswordList[0].Account;
|
|
|
+ _ui.m_inputPassword.text = _accountPasswordList[0].Password;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void OnLoginFail(EventContext context)
|
|
|
{
|
|
|
string account = (string)context.data;
|
|
|
- _ui.m_inputAccount.text = account;
|
|
|
+ _ui.m_comAccount.m_txtAccount.text = account;
|
|
|
}
|
|
|
|
|
|
private void InitChanelBox()
|
|
|
@@ -131,11 +249,13 @@ namespace GFGGame
|
|
|
|
|
|
if (fieldInfo != null && Attribute.IsDefined(fieldInfo, typeof(DescriptionAttribute)))
|
|
|
{
|
|
|
- DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute));
|
|
|
+ DescriptionAttribute attribute =
|
|
|
+ (DescriptionAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute));
|
|
|
items.Add(attribute.Description);
|
|
|
numbers.Add(Convert.ToInt32(value).ToString());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
_ui.m_boxChooseCanal.items = items.ToArray();
|
|
|
_ui.m_boxChooseCanal.values = numbers.ToArray();
|
|
|
_ui.m_boxChooseCanal.value = LauncherConfig.ChannelId + "";
|
|
|
@@ -163,8 +283,8 @@ namespace GFGGame
|
|
|
{
|
|
|
GameConfig.LoginAddress = "http://10.108.64.127:10005";
|
|
|
}
|
|
|
+
|
|
|
ET.Log.Debug($"===选择的渠道=== {_ui.m_boxChooseCanal.value} {GameConfig.LoginAddress}");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|