RegisterView.cs 5.0 KB

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