RegisterView.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. }
  58. protected override void OnHide()
  59. {
  60. base.OnHide();
  61. }
  62. private void OnClickBtnSubmit()
  63. {
  64. CheckToSubmit();
  65. }
  66. private void CheckToSubmit()
  67. {
  68. string account = _ui.m_inputAccount.text.Trim();
  69. string password = _ui.m_inputPassword.text;
  70. string passwordSure = _ui.m_inputPassword2.text;
  71. string realName = _ui.m_inputName.text;
  72. string idNumberStr = _ui.m_inputIDNumber.text;
  73. if (string.IsNullOrEmpty(account))
  74. {
  75. PromptController.Instance.ShowFloatTextPrompt("请输入账号");
  76. return;
  77. }
  78. if (string.IsNullOrEmpty(password))
  79. {
  80. PromptController.Instance.ShowFloatTextPrompt("请输入密码");
  81. return;
  82. }
  83. if (passwordSure != password)
  84. {
  85. PromptController.Instance.ShowFloatTextPrompt("确认密码不一致");
  86. return;
  87. }
  88. GameController.CheckSpecialAccount(account);
  89. if (GameGlobal.antiAddiction)
  90. {
  91. if (realName.Length <= 0)
  92. {
  93. PromptController.Instance.ShowFloatTextPrompt("请输入真实姓名");
  94. return;
  95. }
  96. if (idNumberStr.Length <= 0)
  97. {
  98. PromptController.Instance.ShowFloatTextPrompt("请输入身份证号");
  99. return;
  100. }
  101. if (!_ui.m_btnAgree.selected)
  102. {
  103. PromptController.Instance.ShowFloatTextPrompt("请仔细阅读并同意服务协议、隐私政策、保护规则");
  104. return;
  105. }
  106. }
  107. LoginController.Register(account, password, realName, idNumberStr, CODE).Coroutine();
  108. }
  109. private void OnClickRichTextAgreeLink(string eventname)
  110. {
  111. Debug.Log("link target " + eventname);
  112. string content = null;
  113. switch (eventname)
  114. {
  115. case "event:a":
  116. content = GFGAsset.Load<TextAsset>(ResPathUtil.GetTxtPath("serviceProtocal")).text;
  117. break;
  118. case "event:b":
  119. content = GFGAsset.Load<TextAsset>(ResPathUtil.GetTxtPath("privacyPolicy")).text;
  120. break;
  121. case "event:c":
  122. content = GFGAsset.Load<TextAsset>(ResPathUtil.GetTxtPath("privacyPolicyChildren")).text;
  123. break;
  124. }
  125. if (!string.IsNullOrEmpty(content))
  126. {
  127. ViewManager.Show<FullScreenTextView>(content);
  128. }
  129. }
  130. }
  131. }