RegisterView.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using UI.Login;
  2. using UnityEngine;
  3. using FairyGUI;
  4. namespace GFGGame
  5. {
  6. public class RegisterView : BaseWindow
  7. {
  8. private UI_RegisterUI _ui;
  9. private const string CODE = "";
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. _ui = null;
  16. }
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_RegisterUI.PACKAGE_NAME;
  23. _ui = UI_RegisterUI.Create();
  24. this.viewCom = _ui.target;
  25. this.viewCom.Center();
  26. this.modal = true;
  27. _ui.m_btnSubmit.onClick.Add(OnClickBtnSubmit);
  28. // _ui.m_richTextAgree.onClickLink.Add(OnClickRichTextAgreeLink);
  29. _ui.m_loaEventa.onClick.Add(() => { FullScreenTextController.Show("event:a"); });
  30. _ui.m_loaEventb.onClick.Add(() => { FullScreenTextController.Show("event:b"); });
  31. _ui.m_loaEventc.onClick.Add(() => { FullScreenTextController.Show("event:c"); });
  32. // _ui.m_btnSendCode.onClick.Add(() => {
  33. //
  34. // _ui.m_btnSendCode.enabled = false;
  35. // _ui.m_inputCode.text = CODE;
  36. // float endTime = Time.time + 60;
  37. // Timers.inst.Add(1,0, timerCallback, endTime);
  38. // timerCallback(endTime);
  39. // });
  40. //输入限制
  41. _ui.m_inputAccount.restrict = "[0-9A-Za-z_]";
  42. _ui.m_inputPassword2.restrict = _ui.m_inputPassword.restrict = "[0-9A-Za-z_]";
  43. _ui.m_inputName.restrict = "[\u4e00-\u9fa5a-zA-Z]";
  44. _ui.m_inputIDNumber.restrict = "[a-zA-Z0-9]";
  45. }
  46. private void timerCallback(object param)
  47. {
  48. float endTime = (float)param;
  49. float remainTime = endTime - Time.time;
  50. if (remainTime <= 0)
  51. {
  52. // _ui.m_btnSendCode.text = "发送验证码";
  53. // _ui.m_btnSendCode.enabled = true;
  54. Timers.inst.Remove(timerCallback);
  55. }
  56. else
  57. {
  58. // _ui.m_btnSendCode.text = (int)remainTime + "s后重发";
  59. }
  60. }
  61. protected override void OnShown()
  62. {
  63. base.OnShown();
  64. LogServerHelperHttp.SendNodeLog((int)LogNode.ShowRegister);
  65. }
  66. protected override void OnHide()
  67. {
  68. base.OnHide();
  69. }
  70. private void OnClickBtnSubmit()
  71. {
  72. CheckToSubmit();
  73. }
  74. private void CheckToSubmit()
  75. {
  76. string account = _ui.m_inputAccount.text.Trim();
  77. string password = _ui.m_inputPassword.text;
  78. string passwordSure = _ui.m_inputPassword2.text;
  79. string realName = _ui.m_inputName.text;
  80. string idNumberStr = _ui.m_inputIDNumber.text;
  81. if (string.IsNullOrEmpty(account))
  82. {
  83. PromptController.Instance.ShowFloatTextPrompt("请输入账号");
  84. return;
  85. }
  86. if(account.Length < 8)//最长输入在UI编辑器中做了限制
  87. {
  88. PromptController.Instance.ShowFloatTextPrompt("账号长度最少需要8位");
  89. return;
  90. }
  91. if (string.IsNullOrEmpty(password))
  92. {
  93. PromptController.Instance.ShowFloatTextPrompt("请输入密码");
  94. return;
  95. }
  96. if (password.Length < 8)//最长输入在UI编辑器中做了限制
  97. {
  98. PromptController.Instance.ShowFloatTextPrompt("密码长度最少需要8位");
  99. return;
  100. }
  101. if (passwordSure != password)
  102. {
  103. PromptController.Instance.ShowFloatTextPrompt("确认密码不一致");
  104. return;
  105. }
  106. GameController.CheckSpecialAccount(account);
  107. if (GameGlobal.antiAddiction)
  108. {
  109. if (realName.Length <= 0)
  110. {
  111. PromptController.Instance.ShowFloatTextPrompt("请输入真实姓名");
  112. return;
  113. }
  114. if (idNumberStr.Length <= 0)
  115. {
  116. PromptController.Instance.ShowFloatTextPrompt("请输入身份证号");
  117. return;
  118. }
  119. if (!_ui.m_btnAgree.selected)
  120. {
  121. PromptController.Instance.ShowFloatTextPrompt("请仔细阅读并同意服务协议、隐私政策、保护规则");
  122. return;
  123. }
  124. }
  125. LoginController.Register(account, password, realName, idNumberStr, CODE).Coroutine();
  126. }
  127. }
  128. }