RegisterView.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using UnityEngine.SceneManagement;
  7. using UnityEngine.Networking;
  8. using System.Text.RegularExpressions;
  9. using DG.Tweening;
  10. using Newtonsoft.Json;
  11. using JCUnityLib;
  12. using JCUnityLib.UI;
  13. using Newtonsoft.Json.Linq;
  14. /* 注册界面 */
  15. public class RegisterView : MonoBehaviour
  16. {
  17. [SerializeField] GameObject registerInUser;
  18. [SerializeField] GameObject registerInPWD1;
  19. [SerializeField] GameObject registerInPWD2;
  20. [SerializeField] GameObject registerInEmail;
  21. [SerializeField] GameObject registerInPhone;
  22. [SerializeField] GameObject registerInCaptcha;
  23. [SerializeField] GameObject registerInNickname;
  24. [SerializeField] GameObject registerInGender;
  25. [SerializeField] GameObject registerInBirthday;
  26. [SerializeField] GameObject registerInLocation;
  27. [SerializeField] GameObject btnNext;
  28. [SerializeField] GameObject btnSave;
  29. [SerializeField] GameObject lineTip;
  30. InputField _inputRelateAccount;
  31. InputField _inputValidateCode;
  32. //状态记录
  33. public int captcha_Register = -222222222;
  34. void OnEnable()
  35. {
  36. InitPage();
  37. //弹出协议,不同意则退出注册
  38. AgreementPopup agreementPopup = transform.parent.Find("AgreementPopup").GetComponent<AgreementPopup>();
  39. agreementPopup.onDisagree = () => {
  40. agreementPopup.onDisagree = null;
  41. GameObject.FindObjectOfType<LoginMgr>().showLoginView();
  42. };
  43. agreementPopup.gameObject.SetActive(true);
  44. }
  45. void Start()
  46. {
  47. InitInputLimit();
  48. //把账户视为手机号或者邮箱
  49. _inputRelateAccount = GetInputField(registerInUser);
  50. _inputValidateCode = GetGameObjectInputField(registerInPhone);
  51. if (CommonConfig.serverIndex == 0)
  52. {
  53. //国内使用手机注册
  54. SetLoginValidateType(LoginValidateType.Phone);
  55. }
  56. else
  57. {
  58. //国外使用邮箱注册
  59. SetLoginValidateType(LoginValidateType.Email);
  60. }
  61. }
  62. void InitInputLimit() {
  63. GameObject[] inputNodes = {registerInUser, registerInPWD1, registerInPWD2};
  64. foreach (var inputNode in inputNodes) {
  65. InputField inputField = GetInputField(inputNode);
  66. inputField.onValueChanged.AddListener(delegate(string text) {
  67. Match match = new Regex("[^A-Za-z0-9]").Match(text);
  68. if (match.Success) {
  69. inputField.text = text.Replace(match.Value, "");
  70. }
  71. });
  72. }
  73. }
  74. void InitPage(bool isNext = false) {
  75. registerInUser.SetActive(!isNext);
  76. registerInPWD1.SetActive(!isNext);
  77. registerInPWD2.SetActive(!isNext);
  78. registerInPhone.SetActive(!isNext);
  79. //registerInEmail.SetActive(!isNext && CommonConfig.serverIndex == 1);
  80. //registerInPhone.SetActive(!isNext && CommonConfig.serverIndex == 0);
  81. //if (CommonConfig.banBindRelateAccount)
  82. //{
  83. // registerInEmail.SetActive(false);
  84. // registerInPhone.SetActive(false);
  85. //}
  86. //lineTip.SetActive(registerInEmail.activeSelf && registerInPhone.activeSelf);
  87. registerInCaptcha.SetActive(!isNext);
  88. btnNext.SetActive(!isNext);
  89. var btnNextTF = btnNext.transform as RectTransform;
  90. var btnNextAP = btnNextTF.anchoredPosition;
  91. btnNextAP.y = -540;
  92. //if (registerInEmail.activeSelf) btnNextAP.y -= 14;
  93. //if (registerInPhone.activeSelf) btnNextAP.y -= 14;
  94. btnNextTF.anchoredPosition = btnNextAP;
  95. registerInNickname.SetActive(isNext);
  96. registerInGender.SetActive(isNext);
  97. registerInBirthday.SetActive(isNext);
  98. registerInLocation.SetActive(isNext);
  99. btnSave.SetActive(isNext);
  100. if (isNext) {
  101. GetLocation();
  102. } else {
  103. ChnageCaptcha();
  104. }
  105. }
  106. InputField GetInputField(GameObject inputNode) {
  107. return inputNode.transform.Find("InputField").GetComponent<InputField>();
  108. }
  109. InputField GetGameObjectInputField(GameObject inputNode)
  110. {
  111. return inputNode.transform.Find("GameObject/InputField").GetComponent<InputField>();
  112. }
  113. public void ChnageCaptcha() {
  114. StartCoroutine(CaptchaController.Instance.GetCaptcha(
  115. registerInCaptcha.transform.Find("GameObject/CodeImage").GetComponent<Image>(),
  116. (code) => { captcha_Register = code; }
  117. ));
  118. }
  119. string _bindingEmail = "";
  120. public void OnClick_BindEmail()
  121. {
  122. RelateValidateView relateValidateView =
  123. Instantiate(SceneResourceManager.Instance.GetPrefab("RelateValidateView"))
  124. .GetComponent<RelateValidateView>();
  125. CanvasUtils.PlusSortOrder(gameObject.GetComponentInParent<Canvas>().gameObject, relateValidateView.gameObject, 1);
  126. relateValidateView.InitForEmail2();
  127. relateValidateView.onValidateSuccess = (a, b, c) => {
  128. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-pass1"));
  129. relateValidateView.CloseView();
  130. GetInputField(registerInEmail).text = _bindingEmail = a;
  131. };
  132. }
  133. string _bindingPhone = "";
  134. public void OnClick_BindPhone()
  135. {
  136. RelateValidateView relateValidateView =
  137. Instantiate(SceneResourceManager.Instance.GetPrefab("RelateValidateView"))
  138. .GetComponent<RelateValidateView>();
  139. CanvasUtils.PlusSortOrder(gameObject.GetComponentInParent<Canvas>().gameObject, relateValidateView.gameObject, 1);
  140. relateValidateView.InitForPhone2();
  141. relateValidateView.onValidateSuccess = (a, b, c) => {
  142. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-pass1"));
  143. relateValidateView.CloseView();
  144. GetInputField(registerInPhone).text = _bindingPhone = a;
  145. };
  146. }
  147. public enum LoginValidateType { Email, Phone }
  148. private LoginValidateType _LoginValidateType = LoginValidateType.Email;
  149. public void SetLoginValidateType(LoginValidateType _loginValidateType)
  150. {
  151. _LoginValidateType = _loginValidateType;
  152. if (_LoginValidateType == LoginValidateType.Email)
  153. {
  154. _inputRelateAccount.contentType = InputField.ContentType.EmailAddress;
  155. _inputRelateAccount.characterLimit = 32;
  156. registerInUser.transform.Find("Text").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("register_email");
  157. _inputRelateAccount.transform.Find("Placeholder").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-email1");
  158. //输入框文案
  159. registerInPhone.transform.Find("Text").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-email0");
  160. //输入框提示
  161. _inputValidateCode.transform.Find("Placeholder").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-email2");
  162. //发送按钮
  163. registerInPhone.transform.Find("GameObject/Send/Text").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-email3");
  164. }
  165. else if (_LoginValidateType == LoginValidateType.Phone)
  166. {
  167. _inputRelateAccount.contentType = InputField.ContentType.IntegerNumber;
  168. _inputRelateAccount.characterLimit = 11;
  169. registerInUser.transform.Find("Text").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("register_phone");
  170. _inputRelateAccount.transform.Find("Placeholder").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-phone1");
  171. registerInPhone.transform.Find("Text").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-phone0");
  172. _inputValidateCode.transform.Find("Placeholder").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-phone2");
  173. registerInPhone.transform.Find("GameObject/Send/Text").GetComponent<Text>().text = TextAutoLanguage2.GetTextByKey("RelateValidateView-phone3");
  174. }
  175. }
  176. [SerializeField] GameObject _prefabValidateJigsawView;
  177. static long _throttlerBtnSend_phone_reg = 0;
  178. long _throttlerBtnSend_reg
  179. {
  180. get
  181. {
  182. return _throttlerBtnSend_phone_reg;
  183. }
  184. set
  185. {
  186. _throttlerBtnSend_phone_reg = value;
  187. }
  188. }
  189. public void OnClick_SendCode() {
  190. if (_LoginValidateType == LoginValidateType.Email)
  191. {
  192. string email = _inputRelateAccount.text;
  193. if (!ValidateHelper.IsEmail(email))
  194. {
  195. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-a0"));
  196. return;
  197. }
  198. }
  199. else if (_LoginValidateType == LoginValidateType.Phone)
  200. {
  201. string phone = _inputRelateAccount.text;
  202. if (!ValidateHelper.IsMobilePhone(phone))
  203. {
  204. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-a1"));
  205. return;
  206. }
  207. }
  208. //验证码再次发送需要间隔60秒
  209. long gapTime = TimeUtils.GetTimestamp() - _throttlerBtnSend_reg;
  210. long maxTime = 60 * 1000;
  211. if (gapTime < maxTime)
  212. {
  213. long second = (maxTime - gapTime) / 1000;
  214. if (second <= 0) second = 1;
  215. PopupMgr.ins.ShowTip(string.Format(TextAutoLanguage2.GetTextByKey("RelateValidateView-a2"), second));
  216. return;
  217. }
  218. //打开拼图验证
  219. GameObject gameObjectValidateJigsawView = Instantiate(_prefabValidateJigsawView);
  220. //CanvasUtils.PlusSortOrder(gameObject, gameObjectValidateJigsawView, 1);
  221. ValidateJigsawView validateJigsawView = gameObjectValidateJigsawView.GetComponent<ValidateJigsawView>();
  222. validateJigsawView.onComplete = RequestSendValidateCode;
  223. validateJigsawView.SetTextLabel(TextAutoLanguage2.GetTextByKey("ValidateJigsawView_label"));
  224. validateJigsawView.SetTextTip(TextAutoLanguage2.GetTextByKey("ValidateJigsawView_tip"));
  225. validateJigsawView.SetTextOK(TextAutoLanguage2.GetTextByKey("ValidateJigsawView_ok"));
  226. }
  227. void RequestSendValidateCode()
  228. {
  229. //限流时间点记录
  230. _throttlerBtnSend_reg = TimeUtils.GetTimestamp();
  231. //请求服务端接口
  232. if (_LoginValidateType == LoginValidateType.Email)
  233. {
  234. string email = _inputRelateAccount.text;
  235. StartCoroutine(EmailValidateController.Instance.SendEmailValidateCode(email, (res) => {
  236. if (res.code == 0) PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("RelateValidateView-b0"));
  237. else PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("RelateValidateView-b1"));
  238. }));
  239. }
  240. else if (_LoginValidateType == LoginValidateType.Phone)
  241. {
  242. string phone = _inputRelateAccount.text;
  243. StartCoroutine(PhoneValidateController.Instance.SendPhoneValidateCode(phone, (res) => {
  244. if (res.code == 0) PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("RelateValidateView-b2"));
  245. else PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("RelateValidateView-b3"));
  246. }));
  247. }
  248. }
  249. Throttler _throttlerBtnSubmit = new Throttler(3000);
  250. public void OnClick_BtnSubmit()
  251. {
  252. if (_LoginValidateType == LoginValidateType.Email)
  253. {
  254. string email = _inputRelateAccount.text;
  255. if (!ValidateHelper.IsEmail(email))
  256. {
  257. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-a0"));
  258. return;
  259. }
  260. }
  261. else if (_LoginValidateType == LoginValidateType.Phone)
  262. {
  263. string phone = _inputRelateAccount.text;
  264. if (!ValidateHelper.IsMobilePhone(phone))
  265. {
  266. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-a1"));
  267. return;
  268. }
  269. }
  270. string code = _inputValidateCode.text;
  271. if (code.Length != 6)
  272. {
  273. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-a3"));
  274. return;
  275. }
  276. if (!_throttlerBtnSubmit.CanPass())
  277. {
  278. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("操作过于频繁"));
  279. return;
  280. }
  281. RequestSubmit();
  282. }
  283. void RequestSubmit()
  284. {
  285. if (_LoginValidateType == LoginValidateType.Email)
  286. {
  287. string email = _inputRelateAccount.text;
  288. string code = _inputValidateCode.text;
  289. StartCoroutine(EmailValidateController.Instance.ValidateEmail(email, code, (res) => {
  290. if (res.code == 0)
  291. {
  292. JObject data = res.data as JObject;
  293. string arg0 = data.Value<string>("email");
  294. long arg1 = data.Value<long>("timestamp");
  295. string arg2 = data.Value<string>("sign");
  296. Debug.Log($"邮箱验证成功 {arg0} {arg1} {arg2}");
  297. _bindingEmail = arg0;
  298. RegisterNext();
  299. }
  300. else PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-c0"));
  301. }));
  302. }
  303. else if (_LoginValidateType == LoginValidateType.Phone)
  304. {
  305. string phone = _inputRelateAccount.text;
  306. string code = _inputValidateCode.text;
  307. StartCoroutine(PhoneValidateController.Instance.ValidatePhone(phone, code, (res) => {
  308. if (res.code == 0)
  309. {
  310. JObject data = res.data as JObject;
  311. string arg0 = data.Value<string>("phone");
  312. long arg1 = data.Value<long>("timestamp");
  313. string arg2 = data.Value<string>("sign");
  314. Debug.Log($"手机验证成功 {arg0} {arg1} {arg2}");
  315. _bindingPhone = arg0;
  316. RegisterNext();
  317. }
  318. else PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByKey("RelateValidateView-c1"));
  319. }));
  320. }
  321. }
  322. private string usrRecord = "";
  323. private string pwdRecord = "";
  324. JCUnityLib.Throttler throttlerRegisterNext = new JCUnityLib.Throttler(2000);
  325. void TestNav() {
  326. InputField user = GetInputField(registerInUser);
  327. InputField pwd1 = GetInputField(registerInPWD1);
  328. usrRecord = user.text;
  329. pwdRecord = pwd1.text;
  330. InitPage(true); //前往完善用户信息
  331. LoginView.ins.FillLoginInput(usrRecord, pwdRecord);
  332. }
  333. public void RegisterNext()
  334. {
  335. //TestNav();
  336. //return;
  337. //检测是否绑定手机号和邮箱号,没有进行绑定。绑定后再调用此流程
  338. if (!CommonConfig.banBindRelateAccount)
  339. {
  340. if (string.IsNullOrEmpty(_bindingEmail) && string.IsNullOrEmpty(_bindingPhone))
  341. {
  342. OnClick_BtnSubmit();
  343. return;
  344. }
  345. }
  346. //这里变成手机号或者邮箱号了
  347. InputField user = GetInputField(registerInUser);
  348. //if (user.text.Length < 6) {
  349. // PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("账号长度至少6位"));
  350. // return;
  351. //}
  352. InputField pwd1 = GetInputField(registerInPWD1);
  353. if (pwd1.text.Length < 6) {
  354. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("密码长度至少6位"));
  355. return;
  356. }
  357. InputField pwd2 = GetInputField(registerInPWD2);
  358. if (pwd1.text != pwd2.text) {
  359. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("两次输入的密码不一致"));
  360. return;
  361. }
  362. // if (!CommonConfig.banBindRelateAccount)
  363. // {
  364. // if (string.IsNullOrEmpty(_bindingEmail) && string.IsNullOrEmpty(_bindingPhone)) {
  365. // if (CommonConfig.serverIndex == 0) PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("至少需要绑定邮箱号或者手机号"));
  366. // else PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("尚未绑定邮箱号"));
  367. // return;
  368. // }
  369. // }
  370. //if (registerInEmail.activeSelf && string.IsNullOrEmpty(_bindingEmail)) {
  371. // PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("尚未绑定邮箱号"));
  372. // return;
  373. //}
  374. //if (registerInPhone.activeSelf && string.IsNullOrEmpty(_bindingPhone)) {
  375. // PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("尚未绑定手机号"));
  376. // return;
  377. //}
  378. InputField captcha = GetGameObjectInputField(registerInCaptcha);
  379. if (!captcha.text.Equals(captcha_Register.ToString())) {
  380. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("验证码错误"));
  381. return;
  382. }
  383. if (!AgreenmentOption.ins.IsAgreementChecked()) {
  384. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("请阅读并同意App协议"));
  385. return;
  386. }
  387. if (throttlerRegisterNext.CanPass() == false) {
  388. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("操作过于频繁"));
  389. return;
  390. }
  391. usrRecord = user.text;
  392. pwdRecord = pwd1.text;
  393. if (CommonConfig.banBindRelateAccount)
  394. {
  395. StartCoroutine(LoginController.Instance.Register(
  396. usrRecord, pwdRecord, (res) => {
  397. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey(res.msg));
  398. if (res.code == 0) {
  399. //设置默认名字,为当前注册的账户信息
  400. InputField nickname = GetInputField(registerInNickname);
  401. nickname.text = usrRecord;
  402. InitPage(true); //前往完善用户信息
  403. LoginView.ins.FillLoginInput(usrRecord, pwdRecord);
  404. }
  405. }
  406. ));
  407. return;
  408. }
  409. StartCoroutine(LoginController.Instance.Register2(
  410. usrRecord, pwdRecord, _bindingEmail, _bindingPhone, (res) => {
  411. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey(res.msg));
  412. if (res.code == 0) {
  413. //设置默认名字,为当前注册的账户信息
  414. InputField nickname = GetInputField(registerInNickname);
  415. nickname.text = usrRecord;
  416. InitPage(true); //前往完善用户信息
  417. LoginView.ins.FillLoginInput(usrRecord, pwdRecord);
  418. }
  419. }
  420. ));
  421. }
  422. JCUnityLib.Throttler throttlerRegisterSave = new JCUnityLib.Throttler(2000);
  423. public void RegisterSave() {
  424. InputField nickname = GetInputField(registerInNickname);
  425. string text_nickname = nickname.text.Trim();
  426. if (text_nickname.Length == 0) {
  427. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("请输入游戏昵称"));
  428. return;
  429. }
  430. int gender = 0;
  431. Transform toggleGroup = registerInGender.transform.Find("ToggleGroup");
  432. for (int i = 0; i < toggleGroup.childCount; i++) {
  433. if (toggleGroup.GetChild(i).GetComponent<Toggle>().isOn) {
  434. gender = i == 0 ? 1 : 2;
  435. break;
  436. }
  437. }
  438. InputField birthday = GetInputField(registerInBirthday);
  439. string text_birthday = birthday.text;
  440. if (text_birthday.Length != 10) {
  441. text_birthday = "2000-01-01";
  442. // PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("未填写出生日期"));
  443. // return;
  444. }
  445. InputField location = GetInputField(registerInLocation);
  446. if (location.text.Length == 0) {
  447. countryCode = "";
  448. stateCode = "";
  449. cityCode = "";
  450. // PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("未填写所在地区"));
  451. // return;
  452. }
  453. if (!AgreenmentOption.ins.IsAgreementChecked()) {
  454. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("请阅读并同意App协议"));
  455. return;
  456. }
  457. if (throttlerRegisterSave.CanPass() == false) {
  458. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey("操作过于频繁"));
  459. return;
  460. }
  461. StartCoroutine(LoginController.Instance.CompleteUserInfo(
  462. usrRecord, pwdRecord, text_nickname, gender, text_birthday,
  463. countryCode, stateCode, cityCode
  464. ,(res) => {
  465. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey(res.msg));
  466. if (res.code == 0) {
  467. GameObject.FindObjectOfType<LoginMgr>().showLoginView();
  468. }
  469. }
  470. ));
  471. }
  472. #region Picker
  473. [SerializeField] GameObject datePickerPrefab;
  474. public void OpenDatePicker() {
  475. GameObject o = GameObject.Instantiate(datePickerPrefab);
  476. o.GetComponentInChildren<JC.Unity.Picker.DatePickerGroup>().onEnter += (JC.Unity.Picker.DatePickerGroup picker) => {
  477. GetInputField(registerInBirthday).text = picker.GetSelectDateStr();
  478. };
  479. }
  480. [SerializeField] GameObject locationPickerPrefab;
  481. private string countryCode = "", stateCode = "", cityCode = "";
  482. public void OpenLocationPicker() {
  483. // GameObject o = GameObject.Instantiate(locationPickerPrefab);
  484. // o.GetComponentInChildren<JC.Unity.Picker.LocationPickerGroup>().onEnter += (JC.Unity.Picker.LocationInfo info) => {
  485. // countryCode = info.GetCountryRegion().Item2;
  486. // stateCode = info.GetState().Item2;
  487. // cityCode = info.GetCity().Item2;
  488. // GetInputField(registerInLocation).text =
  489. // info.GetCountryRegion().Item1 + " " +
  490. // info.GetState().Item1 + " " +
  491. // info.GetCity().Item1;
  492. // };
  493. //2022-12-6 gps获取地理位置
  494. GetLocation();
  495. }
  496. void GetLocation()
  497. {
  498. try
  499. {
  500. System.Action eOnAgree = () => {
  501. GPSTool.GetAddress((address) => {
  502. if (address != null) {
  503. countryCode = address[0];
  504. stateCode = address[1];
  505. cityCode = address[2];
  506. GetInputField(registerInLocation).text =
  507. countryCode + " " +
  508. stateCode + " " +
  509. cityCode;
  510. }
  511. });
  512. };
  513. if (!HomeView.ShowProminentBeforeConnectBLE(eOnAgree)) eOnAgree.Invoke();
  514. }
  515. catch (System.Exception e) { Debug.LogError(e); }
  516. }
  517. #endregion
  518. }