using UnityEngine; using UnityEngine.UI; using Kill.Managers; using Kill.UI.Components; namespace Kill.UI.Pages { /// /// 第三方登录绑定页面 /// public class ThirdPartyBindPanel : LoginSubPageBase { [Header("登录按钮")] public Button wechatBtn; public Button qqBtn; public Button appleBtn; public Button googleBtn; // 谷歌登录按钮 [Header("返回")] public Button backBtn; protected override void OnInitialize() { if (wechatBtn != null) wechatBtn.onClick.AddListener(() => OnThirdPartyLogin("wechat")); if (qqBtn != null) qqBtn.onClick.AddListener(() => OnThirdPartyLogin("qq")); if (appleBtn != null) appleBtn.onClick.AddListener(() => OnThirdPartyLogin("apple")); if (googleBtn != null) googleBtn.onClick.AddListener(OnGoogleLogin); if (backBtn != null) backBtn.onClick.AddListener(GoBack); // Android 平台显示谷歌登录按钮 #if UNITY_ANDROID && !UNITY_EDITOR if (googleBtn != null) googleBtn.gameObject.SetActive(true); #else if (googleBtn != null) googleBtn.gameObject.SetActive(false); #endif } /// /// 谷歌登录 /// private void OnGoogleLogin() { Debug.Log("开始谷歌登录..."); LoadingUI.Show(); FirebaseAuthManager.Instance.SignInWithGoogle( onSuccess: (result) => { LoadingUI.Hide(); Debug.Log($"谷歌登录成功: {result.DisplayName}, FirebaseID: {result.FirebaseUserId}"); // 调用后端绑定接口 BindGoogleAccount(result); }, onError: (error) => { LoadingUI.Hide(); Debug.LogError($"谷歌登录失败: {error}"); ToastUI.Show("100036"); // 登录失败提示 } ); } /// /// 绑定谷歌账号到本系统 /// private void BindGoogleAccount(GoogleLoginResult googleResult) { string email = LoginPageCtrl.Instance.GetCurrentEmail(); } private void OnThirdPartyLogin(string platform) { Debug.Log($"第三方登录: {platform}"); // TODO: 调用对应平台的SDK switch (platform) { case "wechat": // 微信登录 break; case "qq": // QQ登录 break; case "apple": // Apple登录 break; } } } }