Exemplo n.º 1
0
        /// <summary>
        /// 修改密码
        /// </summary>
        private async void OnChangePwd()
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);
            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.ModifyPasswordNotRepeatTip);
                return;
            }

            OnEndEditOldPwdInputField(_oldPwdInput.text);
            OnEndEditNewPwdInputField(_newPwdInput.text);
            OnEndEditConfirmPwdInputField(_confirmPwdInput.text);

            if (!_oldPwdVertify || !_newPwdVertify || !_confirmPwdVertify)
            {
                return;
            }

            try
            {
                Game.PopupComponent.ShowLoadingLockUI();
                _isRequest = true;

                var response = (G2C_ResetPassword_Res)await SessionComponent.Instance.Session.Call(
                    new C2G_ResetPassword_Req()
                {
                    UserId      = GamePrefs.GetUserId(),
                    OldPassword = _oldPwdInput.text,
                    NewPassword = _newPwdInput.text
                });

                if (response.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(response.Message);
                    _isRequest = false;
                    Game.PopupComponent.CloseLoadingLockUI();
                    return;
                }

                GamePrefs.SetUserPwd(_confirmPwdInput.text);

                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyPasswordSuccTip);

                OnCloseMask();
                Game.PopupComponent.CloseLoadingLockUI();
            }
            catch (Exception e)
            {
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ModifyPasswordFailTip);
                Debug.LogError("修改密码失败: " + e.Message);
                Game.PopupComponent.CloseLoadingLockUI();
                throw;
            }
            finally
            {
                _isRequest = false;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 点击注册按钮
        /// </summary>
        private async void OnRegisterButton()
        {
            ETModel.Game.Scene.GetComponent <SoundComponent>().PlayClip(DataCenterComponent.Instance.soundInfo.click);
            if (_isRequest)
            {
                Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.IsLoadingTip);
                return;
            }

            OnEndEditAccountInputField(accoutIF.text);
            OnEndEditPasswordInputField(passIF.text);
            OnEndEditCaptchaInputField(repeatIF.text);

            if (!_accountVertify || !_passwordVertify || !_captchaVertify)
            {
                return;
            }

            Game.PopupComponent.ShowLoadingLockUI();
            _isRequest = true;
            try
            {
                // 创建一个ETModel层的Session
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>()
                                          .Create(GlobalConfigComponent.Instance.GlobalProto.Address);

                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                Session realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                // 发送注册请求
                R2C_Register_Res r2CRegisterRes = (R2C_Register_Res)await realmSession.Call(
                    new C2R_Register_Req()
                {
                    Account  = this.accoutIF.text,
                    Password = this.passIF.text
                });

                if (r2CRegisterRes.Error != 0)
                {
                    Game.PopupComponent.ShowMessageBox(r2CRegisterRes.Message);
                    //                    GameHelper.ShowMessageBox(r2CRegisterRes.Message);
                }
                else if (r2CRegisterRes.Error == 0)
                {
                    //注册上报
                    var openInstall = ETModel.Game.Scene.GetComponent <OpenInstallComponent>();
                    openInstall.reportRegister();

                    // 登录
                    GamePrefs.SetUserAccount(accoutIF.text);
                    GamePrefs.SetUserPwd(passIF.text);
                    //                    OnBackButton();
                    //this.GetParent<UILoginCpt>().RegisterLogin();
                }
                Game.PopupComponent.CloseLoadingLockUI();
            }
            catch (Exception e)
            {
                Game.PopupComponent.CloseLoadingLockUI();
                Debug.LogError("无法连接到服务器: " + e.Message);
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ConnectServerFailTip);
            }
            finally
            {
                Game.PopupComponent.CloseLoadingLockUI();
                _isRequest = false;
            }
        }