RegisterView.cs 5.1 KB

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