RegisterView.cs 4.9 KB

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