killapp/Assets/Scripts/UI/Pages/Login/SubPages/ThirdPartyBindPanel.cs

78 lines
2.4 KiB
C#
Raw Normal View History

2026-04-16 14:57:19 +08:00
using UnityEngine;
using UnityEngine.UI;
using Kill.Managers;
using Kill.UI.Components;
2026-04-20 08:31:41 +08:00
using Kill.Utils;
2026-04-16 14:57:19 +08:00
namespace Kill.UI.Pages
{
/// <summary>
/// 第三方登录绑定页面
/// </summary>
public class ThirdPartyBindPanel : LoginSubPageBase
{
2026-04-20 08:31:41 +08:00
[Header("输入组件")]
public InputField emailInput;
[Header("显示组件")]
public Text errorText;
2026-04-16 14:57:19 +08:00
2026-04-20 08:31:41 +08:00
[Header("按钮")]
public Button nextBtn;
2026-04-16 14:57:19 +08:00
protected override void OnInitialize()
{
2026-04-20 08:31:41 +08:00
// 绑定按钮事件
if (nextBtn != null)
nextBtn.onClick.AddListener(OnGetCodeAsync);
2026-04-16 14:57:19 +08:00
}
2026-04-20 08:31:41 +08:00
protected override void OnShow()
2026-04-16 14:57:19 +08:00
{
2026-04-20 08:31:41 +08:00
errorText.text = "";
emailInput.text = "";
}
2026-04-16 14:57:19 +08:00
2026-04-20 08:31:41 +08:00
private async void OnGetCodeAsync()
{
string email = emailInput != null ? emailInput.text : "";
if (string.IsNullOrEmpty(email) || !ValidationUtils.IsValidEmailStrict(email))
{
errorText.text = LanguageManager.Instance.GetLanguage("100006");
return;
}
await LoginPageCtrl.Instance.CheckEmailRegisteredFireBase(email,
onSuccess: async (data) =>
2026-04-16 14:57:19 +08:00
{
2026-04-20 08:31:41 +08:00
if (data)
{
errorText.text = LanguageManager.Instance.GetLanguage("100041");
return;
}
else
{
LoginPageCtrl.Instance.SetCurrentEmail(email);
await LoginPageCtrl.Instance.SendCode(email, () =>
{
// 设置验证码页面为注册场景
var verifyPanel = GetSubPage(LoginPageCtrl.SubPageType.VerificationCode) as VerificationCodePanel;
if (verifyPanel != null)
{
verifyPanel.SetSceneType(VerificationCodePanel.CodeSceneType.bindThirdParty);
}
ShowPage(LoginPageCtrl.SubPageType.VerificationCode);
});
}
2026-04-16 14:57:19 +08:00
},
2026-04-20 08:31:41 +08:00
onError: (code, message) =>
2026-04-16 14:57:19 +08:00
{
2026-04-20 08:31:41 +08:00
errorText.text = message;
return;
2026-04-16 14:57:19 +08:00
}
);
}
}
}