| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using UI.Login;
- using FairyGUI;
- using UnityEngine;
- using System.ComponentModel;
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using ET;
- namespace GFGGame
- {
- public class ZhaoHuiPasswordView : BaseWindow
- {
- private UI_ZhaoHuiPasswordUI _ui;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_ZhaoHuiPasswordUI.PACKAGE_NAME;
- _ui = UI_ZhaoHuiPasswordUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- _ui.m_btnSendCode.onClick.Add(() =>
- {
- if (!Regex.IsMatch(_ui.m_txtPhone.text.Trim(), // 匹配所有中国大陆手机号(11 位,包括物联网和卫星电话)
- @"^(?:\+86)?1(?:3\d{3}|4[5-9]\d{2}|5[0-35-9]\d{2}|6[2567]\d{2}|7[0-8]\d{2}|8\d{3}|9[0-35-9]\d{2})\d{6}$"))
- {
- PromptController.Instance.ShowFloatTextPrompt("输入的手机号格式有误");
- return;
- }
- _ui.m_btnSendCode.enabled = false;
- //在此发送验证码
- SecurityHelper.GetMobileVerificationCode(_ui.m_txtPhone.text, SendCodeType.ChangePassword)
- .Coroutine();
- float endTime = Time.time + 60;
- Timers.inst.Add(1, 0, timerCallback, endTime);
- timerCallback(endTime);
- });
- _ui.m_btnSubmit.onClick.Add(OnClickBtnSubmit);
- }
- private async void OnClickBtnSubmit()
- {
- if (!Regex.IsMatch(_ui.m_txtPhone.text.Trim(), // 匹配所有中国大陆手机号(11 位,包括物联网和卫星电话)
- @"^(?:\+86)?1(?:3\d{3}|4[5-9]\d{2}|5[0-35-9]\d{2}|6[2567]\d{2}|7[0-8]\d{2}|8\d{3}|9[0-35-9]\d{2})\d{6}$"))
- {
- PromptController.Instance.ShowFloatTextPrompt("输入的手机号格式有误");
- return;
- }
- string code = _ui.m_txtCode.text.Trim();
- string phoneNumber = _ui.m_txtPhone.text.Trim();
- string account = _ui.m_txtAccount.text.Trim();
- string password = _ui.m_txtPasword.text.Trim();
- string password2 = _ui.m_txtPaswrod2.text.Trim();
- if (password != password2)
- {
- PromptController.Instance.ShowFloatTextPrompt("两次输入的密码不一致");
- }
- A2C_UpPassword res = await SecurityHelper.UpPassword(code, phoneNumber, account, password);
- if (res is { Error: ErrorCode.ERR_Success })
- {
- LoginController.Login(account, password).Coroutine();
- Hide();
- }
- else
- {
- ErrorCodeController.Handler(res.Error);
- }
- }
- private void timerCallback(object param)
- {
- float endTime = (float)param;
- float remainTime = endTime - Time.time;
- if (remainTime <= 0)
- {
- _ui.m_btnSendCode.text = "发送验证码";
- _ui.m_btnSendCode.enabled = true;
- Timers.inst.Remove(timerCallback);
- }
- else
- {
- _ui.m_btnSendCode.text = (int)remainTime + "s后重发";
- }
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_txtAccount.editable = true;
- if (viewData != null)
- {
- _ui.m_txtAccount.text = (string)viewData;
- _ui.m_txtAccount.editable = false;
- }
- }
- protected override void OnHide()
- {
- base.OnHide();
- Timers.inst.Remove(timerCallback);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- }
- }
|