using System.Text.RegularExpressions; using ET; using UI.Login; using UnityEngine; using FairyGUI; namespace GFGGame { public class RegisterView : BaseWindow { private UI_RegisterUI _ui; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_RegisterUI.PACKAGE_NAME; _ui = UI_RegisterUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; _ui.m_btnSubmit.onClick.Add(OnClickBtnSubmit); // _ui.m_richTextAgree.onClickLink.Add(OnClickRichTextAgreeLink); _ui.m_loaEventa.onClick.Add(() => { FullScreenTextController.Show("event:a"); }); _ui.m_loaEventb.onClick.Add(() => { FullScreenTextController.Show("event:b"); }); _ui.m_loaEventc.onClick.Add(() => { FullScreenTextController.Show("event:c"); }); _ui.m_btnSendCode.onClick.Add(() => { if (!Regex.IsMatch(_ui.m_inputPhone.text.Trim(), // 匹配所有中国大陆手机号(11 位,包括物联网和卫星电话) @"^(?:\+86)?1(?:3\d{3}|4[5-9]\d{2}|5[0-35-9]\d{2}|6[2567]\d{2}|7[0-8]\d{2}|8\d{3}|9[0-35-9]\d{2})\d{6}$")) { PromptController.Instance.ShowFloatTextPrompt("输入的手机号格式有误"); return; } _ui.m_btnSendCode.enabled = false; //在此发送验证码 SecurityHelper.GetMobileVerificationCode(_ui.m_inputPhone.text, SendCodeType.RegisterAccount) .Coroutine(); float endTime = Time.time + 60; Timers.inst.Add(1, 0, timerCallback, endTime); timerCallback(endTime); }); //输入限制 _ui.m_inputAccount.restrict = "[0-9A-Za-z_]"; _ui.m_inputPassword2.restrict = _ui.m_inputPassword.restrict = "[0-9A-Za-z_]"; _ui.m_inputName.restrict = "[\u4e00-\u9fa5a-zA-Z]"; _ui.m_inputIDNumber.restrict = "[a-zA-Z0-9]"; } private void timerCallback(object param) { float endTime = (float)param; float remainTime = endTime - Time.time; if (remainTime <= 0) { _ui.m_btnSendCode.text = "发送验证码"; _ui.m_btnSendCode.enabled = true; Timers.inst.Remove(timerCallback); } else { _ui.m_btnSendCode.text = (int)remainTime + "s后重发"; } } protected override void OnShown() { base.OnShown(); LogServerHelperHttp.SendNodeLog((int)LogNode.ShowRegister); } protected override void OnHide() { base.OnHide(); Timers.inst.Remove(timerCallback); } private void OnClickBtnSubmit() { CheckToSubmit(); } private void CheckToSubmit() { string account = _ui.m_inputAccount.text.Trim(); string password = _ui.m_inputPassword.text; string passwordSure = _ui.m_inputPassword2.text; string realName = _ui.m_inputName.text; string idNumberStr = _ui.m_inputIDNumber.text; string phoneNumber = _ui.m_inputPhone.text; string code = _ui.m_inputCode.text; if (string.IsNullOrEmpty(account)) { PromptController.Instance.ShowFloatTextPrompt("请输入账号"); return; } if (account.Length < 8) //最长输入在UI编辑器中做了限制 { PromptController.Instance.ShowFloatTextPrompt("账号长度最少需要8位"); return; } if (string.IsNullOrEmpty(password)) { PromptController.Instance.ShowFloatTextPrompt("请输入密码"); return; } if (password.Length < 8) //最长输入在UI编辑器中做了限制 { PromptController.Instance.ShowFloatTextPrompt("密码长度最少需要8位"); return; } if (passwordSure != password) { PromptController.Instance.ShowFloatTextPrompt("确认密码不一致"); return; } GameController.CheckSpecialAccount(account); if (GameGlobal.antiAddiction) { if (realName.Length <= 0) { PromptController.Instance.ShowFloatTextPrompt("请输入真实姓名"); return; } if (idNumberStr.Length <= 0) { PromptController.Instance.ShowFloatTextPrompt("请输入身份证号"); return; } if (!_ui.m_btnAgree.selected) { PromptController.Instance.ShowFloatTextPrompt("请仔细阅读并同意服务协议、隐私政策、保护规则"); return; } } LoginController.Register(account, password, realName, idNumberStr, code, phoneNumber).Coroutine(); } } }