Exemplo n.º 1
0
 public void OnLogin()
 {
     LoginHelper.OnLoginAsync(this.account.GetComponent <InputField>().text).Coroutine();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 登录请求
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <param name="isGuest"></param>
        private async Task <int> LoginRequest(string account, string password, bool isGuest = false)
        {
            int isScuess = -1;

            Game.PopupComponent.ShowLoadingLockUI();
            _isRequest = true;
            try
            {
                //登录网关服务器
                if (isGuest)
                {
                    isScuess = await LoginHelper.OnLoginAsync(account, password, isGuest);
                }
                else
                {
                    isScuess = await LoginHelper.OnLoginAsyncToken(account, password);
                }
                if (isScuess != 0)
                {
                    _isRequest = false;
                    if (isGuest && isScuess == ErrorCode.ERR_AccountDoesnExist)
                    {
                        AccountIsNotExist();
                        Log.Debug(DataCenterComponent.Instance.tipInfo.AccountNotExistTip);
                        OnVisitorLoginButton();
                        return(isScuess);
                    }
                    Game.PopupComponent.CloseLoadingLockUI();
                    if (isScuess == 210006)
                    {
                        //账号不存在,删除本地存储的账号
                        PlayerPrefs.DeleteKey($"Account0{_CurrChooseAccountIndex}");
                        _ChooseDialog.SetActive(false);
                    }
                    if (isScuess == 210005)
                    {
                        _LoginDialog.SetActive(true);
                        SetLoginDialog(true);
                        _MobileInputField.text = account;
                        _CodeInputField.text   = "";
                        PlayerPrefs.DeleteKey($"Account0{_CurrChooseAccountIndex}");
                        _ChooseDialog.SetActive(false);
                    }
                    return(isScuess);
                }
                var openInstall = ETModel.Game.Scene.GetComponent <OpenInstallComponent>();
                openInstall.getInstall();

                //G2C_ActivityIsOpenReturn_Res resp = (G2C_ActivityIsOpenReturn_Res)await SessionComponent.Instance.Session.Call(new C2G_ActivityIsOpenAsk_Req());

                Game.EventSystem.Run(EventIdType.LoginPokerFinish);
                Game.EventSystem.Run(EventIdType.CreateGameLobby);
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
                return(isScuess);
            }
            catch (Exception e)
            {
                _isRequest = false;
                Log.Error("无法连接到服务器: " + e.Message);
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ConnectServerFailTip);
                return(isScuess);
            }
            finally
            {
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
            }
        }