178 lines
4.9 KiB
C#
178 lines
4.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UIElements;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
using Toggle = UnityEngine.UI.Toggle;
|
|
using ScrollView = PhxhSDK.PhxhScrollView;
|
|
using Framework;
|
|
using Cysharp.Threading.Tasks;
|
|
using Gameplay.Net;
|
|
using NLDPB;
|
|
using DG.Tweening;
|
|
using Gameplay;
|
|
|
|
public class UI_RealNameIdentifyController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Image Image_Bg;
|
|
public TMP_Text Text_Title;
|
|
public TMP_Text Text_Info;
|
|
public TMP_InputField InputField_Name;
|
|
public TMP_InputField InputField_ID;
|
|
public Button Button_Confirm;
|
|
|
|
GameObject UI_ShortTip;
|
|
TMP_Text shortTipText;
|
|
|
|
///Auto Gen End///
|
|
|
|
// deal with input data
|
|
public override void PreLoad(object data = null)
|
|
{
|
|
|
|
}
|
|
public static async UniTask<UIWindow> Open()
|
|
{
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_RealNameIdentify);
|
|
}
|
|
|
|
// Use this for initialization
|
|
public override void OnInit()
|
|
{
|
|
//bind UI GameObj
|
|
UI_RealNameIdentifyBinder.GetComponents(this);
|
|
UI_ShortTip = FindObj("UI_ShortTip");
|
|
if (UI_ShortTip != null)
|
|
shortTipText = UI_ShortTip.GetComponentInChildren<TMP_Text>();
|
|
|
|
BindButton(Button_Confirm, OnClickButton_Confirm);
|
|
EventManager.Instance.Register(EventManager.EventName.AdultAuthResult, CheckAdultAuthResult);
|
|
}
|
|
//invoke when open window
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnHideWindow()
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when destroy
|
|
public override void OnRelease()
|
|
{
|
|
base.OnRelease();
|
|
}
|
|
|
|
public override UniTask<bool> OnBack(object data = null)
|
|
{
|
|
EventManager.Instance.Send(EventManager.EventName.RealNameVerifyCancel);
|
|
return base.OnBack(data);
|
|
}
|
|
|
|
void OnClickButton_Confirm()
|
|
{
|
|
string name = InputField_Name.text;
|
|
string idCode = InputField_ID.text;
|
|
|
|
#if !UNITY_EDITOR
|
|
string IdCodePattern = @"^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$";
|
|
string NamePattern = @"^[\u4e00-\u9fa5]+$";
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
{
|
|
DebugUtil.Log("姓名输入为空");
|
|
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("Identify_ErrorName"));
|
|
return;
|
|
}
|
|
if (!System.Text.RegularExpressions.Regex.IsMatch(idCode, IdCodePattern))
|
|
{
|
|
DebugUtil.Log("身份证号码格式错误");
|
|
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("Identify_ErrorIdCode"));
|
|
return;
|
|
}
|
|
if (!System.Text.RegularExpressions.Regex.IsMatch(name, NamePattern))
|
|
{
|
|
DebugUtil.Log("姓名格式错误");
|
|
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("Identify_ErrorName"));
|
|
return;
|
|
}
|
|
|
|
DebugUtil.Log("发送请求,实名认证中...");
|
|
Button_Confirm.interactable = false;
|
|
|
|
|
|
//======校验是否满18周岁 临时处理========
|
|
var birthdate = idCode.Substring(6, 8);
|
|
var year = birthdate.Substring(0, 4);
|
|
var age = System.DateTime.Now - System.DateTime.Parse(year + "-" + birthdate.Substring(4, 2) + "-" + birthdate.Substring(6, 2));
|
|
if (age.TotalDays < 18 * 365)
|
|
{
|
|
DebugUtil.Log("未满18周岁");
|
|
shortTipText.text = CommonUtils.GetLocalizeText("Identify_Limited");
|
|
|
|
UI_ShortTip.SetActive(true);
|
|
|
|
Sequence se = DOTween.Sequence();
|
|
se.AppendInterval(2.0f);
|
|
se.AppendCallback(() =>
|
|
{
|
|
UI_ShortTip.SetActive(false);
|
|
CloseWindow();
|
|
});
|
|
return;
|
|
}
|
|
//=======================================
|
|
#endif
|
|
NetHelper.SendAdultAuth(name, idCode);
|
|
}
|
|
void CheckAdultAuthResult()
|
|
{
|
|
var status = (int)Actor.Instance.Logic.GetCount((uint)LogicID.AdultAuthStatus);
|
|
if (status != (int)AAStatus.AasNone)
|
|
{
|
|
DebugUtil.Log("实名认证成功,当前用户身份状态:" + status);
|
|
EventManager.Instance.Unregister(EventManager.EventName.AdultAuthResult, CheckAdultAuthResult);
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_RealNameIdentify);
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_StartGameInterface);
|
|
if (status == (int)AAStatus.AasUnderEighteen && !CommonUtils.IsUnderagePlayTimeAllowed())
|
|
{
|
|
DebugUtil.Log("未成年人限制游玩时间段内");
|
|
WaitingForServer.Instance.EventClear();
|
|
return;
|
|
}
|
|
Actor.Instance.OnEnterGame();
|
|
}
|
|
else
|
|
{
|
|
DebugUtil.Log("实名认证失败");
|
|
|
|
shortTipText.text = CommonUtils.GetLocalizeText("Identify_Error");
|
|
UI_ShortTip.SetActive(true);
|
|
//EventManager.Instance.Unregister(EventManager.EventName.ActorLogicDataUpdate, CheckAdultAuthResult);
|
|
Sequence se = DOTween.Sequence();
|
|
se.AppendInterval(2.0f);
|
|
se.AppendCallback(() => {
|
|
UI_ShortTip.SetActive(false);
|
|
Button_Confirm.interactable = true;
|
|
});
|
|
}
|
|
}
|
|
}
|