2025-03-18 15:28:24 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
using Framework;
|
2024-08-09 13:21:39 +08:00
|
|
|
|
using Gameplay;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
using Gameplay.Net;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
using NLDPB;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
using PhxhSDK;
|
2024-08-09 13:21:39 +08:00
|
|
|
|
using System;
|
2024-08-13 16:11:48 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-08-09 13:21:39 +08:00
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
using UnityEngine.Events;
|
2024-08-09 13:21:39 +08:00
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
using Toggle = UnityEngine.UI.Toggle;
|
2024-09-18 17:51:22 +08:00
|
|
|
|
#if SDK_TAPTAP
|
|
|
|
|
|
using TapSDK.Login;
|
2024-12-23 13:20:40 +08:00
|
|
|
|
#elif SDK_BILIBILI
|
|
|
|
|
|
using PhxhSDK.AOT.Bilibili;
|
2024-09-18 17:51:22 +08:00
|
|
|
|
#endif
|
2024-07-12 14:23:06 +08:00
|
|
|
|
|
|
|
|
|
|
public class UI_StartGameInterfaceController : UIWindow
|
|
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
enum LoginType
|
|
|
|
|
|
{
|
|
|
|
|
|
Account,
|
2024-09-13 17:37:36 +08:00
|
|
|
|
PhoneCode,
|
|
|
|
|
|
TapTap,
|
2024-11-05 18:45:00 +08:00
|
|
|
|
Bilibili,
|
2024-11-14 13:29:20 +08:00
|
|
|
|
#if UNITY_IOS
|
|
|
|
|
|
Apple,
|
|
|
|
|
|
#endif
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region UI_obj
|
|
|
|
|
|
//UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_BgDark;
|
|
|
|
|
|
public Button Button_StartGame;
|
|
|
|
|
|
public Image Image_LoginBg;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public TMP_Text Text_AccountLogin;
|
|
|
|
|
|
public Button Button_AccountLogin;
|
|
|
|
|
|
public Image Image_YellowLine_Account;
|
|
|
|
|
|
public TMP_Text Text_VerifyCodeLogin;
|
|
|
|
|
|
public Button Button_VerifyCodeLogin;
|
|
|
|
|
|
public Image Image_YellowLine_VerifyCode;
|
|
|
|
|
|
public Button Button_Debug;
|
|
|
|
|
|
public TMP_InputField InputField_Account;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_AccountIcon;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public TMP_InputField InputField_Password;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_PasswordIcon;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public Toggle Toggle_RememberPassword;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public TMP_Text Text_RememberPassword;
|
|
|
|
|
|
public Toggle Toggle_Agreement_1;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public TMP_Text Text_Agreement_1;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Button Button_UnLogin_1;
|
|
|
|
|
|
public Button Button_Login_1;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public TMP_InputField InputField_PhoneNumber;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_PhoneIcon;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public TMP_InputField InputField_VerifyCode;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_VerifyCodeIcon;
|
|
|
|
|
|
public Button Button_GetVerifyCode;
|
|
|
|
|
|
public Button Button_GetVerifyCodeCooling;
|
|
|
|
|
|
public Toggle Toggle_Agreement_2;
|
|
|
|
|
|
public TMP_Text Text_Agreement_2;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
public Button Button_UnLogin_2;
|
|
|
|
|
|
public Button Button_Login_2;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public Button Button_AppleClick;
|
|
|
|
|
|
public Button Button_GoogleClick;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_UpdateBg;
|
|
|
|
|
|
public Button Button_Confirm;
|
|
|
|
|
|
public Button Button_Cancle;
|
|
|
|
|
|
public Image Image_BottomLine;
|
|
|
|
|
|
public Button Button_UserCenter;
|
|
|
|
|
|
public Button Button_Notice;
|
|
|
|
|
|
public TMP_Text Text_UID;
|
|
|
|
|
|
public TMP_Text Text_Version;
|
|
|
|
|
|
public Image Image_DarkSide;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public Button Button_AgeTip;
|
|
|
|
|
|
|
|
|
|
|
|
///Auto Gen End///
|
|
|
|
|
|
|
2024-09-13 17:37:36 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// TapTap登录按钮
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button buttonTapTap;
|
2024-11-19 12:49:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Bilibili登录按钮
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Button buttonBilibili;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
#region UI_Class
|
|
|
|
|
|
class LoginWindow : UIGameObjectWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
public GameObject Root;
|
|
|
|
|
|
public GameObject VerifyCodeLoginPanel;
|
|
|
|
|
|
public Toggle Toggle_Agreement;
|
|
|
|
|
|
|
|
|
|
|
|
public TMP_InputField InputField_PhoneNumber;
|
|
|
|
|
|
public TMP_InputField InputField_VerifyCode;
|
|
|
|
|
|
|
|
|
|
|
|
public Button Button_GetVerifyCode;
|
2024-08-13 12:30:13 +08:00
|
|
|
|
public Button Button_GetVerifyCodeCooling;
|
|
|
|
|
|
|
2024-08-13 16:11:48 +08:00
|
|
|
|
public TMP_Text Text_Agreement;
|
|
|
|
|
|
|
2024-08-13 12:30:13 +08:00
|
|
|
|
public bool isTimer;
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
public Button Button_Login;
|
|
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public Button Button_Debug;
|
2024-08-13 12:30:13 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
public Button Button_AccountLogin;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public GameObject Image_line;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
public Button Button_VerifyCodeLogin;
|
|
|
|
|
|
|
|
|
|
|
|
public GameObject AccountLoginPanel;
|
|
|
|
|
|
public TMP_Dropdown ServerSelecter;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public Image Image_YellowLine_Account;
|
|
|
|
|
|
public Image Image_YellowLine_VerifyCode;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
public Toggle Toggle_RememberPassword;
|
|
|
|
|
|
|
|
|
|
|
|
public TMP_InputField InputField_Account;
|
|
|
|
|
|
public TMP_InputField InputField_Password;
|
|
|
|
|
|
|
2024-08-14 12:31:50 +08:00
|
|
|
|
public TMP_Text Text_Agreement_Account;
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
public Button Button_Login_Account;
|
|
|
|
|
|
public Toggle Toggle_Agreement_Account;
|
|
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public Button AppleBtn;
|
|
|
|
|
|
public LoginWindow(GameObject root,
|
|
|
|
|
|
UnityAction<String> PhoneNumberEdit,
|
|
|
|
|
|
UnityAction<String> CodeEdit,
|
|
|
|
|
|
UnityAction<bool> AgreementAccept,
|
|
|
|
|
|
UnityAction PhoneCodeLogin,
|
|
|
|
|
|
UnityAction SendPhoneRequest) : base(root)
|
2024-08-09 12:55:51 +08:00
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
AccountLoginPanel = root.transform.Find("Image_LoginBg/AccountLogin").gameObject;
|
|
|
|
|
|
VerifyCodeLoginPanel = root.transform.Find("Image_LoginBg/VerifyCodeLogin").gameObject;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
ServerSelecter = root.transform.Find("Image_LoginBg/ALDropdown").GetComponent<TMP_Dropdown>();
|
2025-03-18 15:28:24 +08:00
|
|
|
|
|
|
|
|
|
|
Button_Debug = GetComponent<Button>("Image_LoginBg/Top/Button_Debug");
|
|
|
|
|
|
Button_AccountLogin = GetComponent<Button>("Image_LoginBg/Top/ImageBg/AccountLogin/Button_AccountLogin");
|
|
|
|
|
|
Image_line = FindObj("Image_LoginBg/Top/ImageBg/ImageBg (1)");
|
|
|
|
|
|
Button_VerifyCodeLogin = GetComponent<Button>("Image_LoginBg/Top/ImageBg/VerifyCodeLogin/Button_VerifyCodeLogin");
|
|
|
|
|
|
Toggle_Agreement = GetComponent<Toggle>("Image_LoginBg/VerifyCodeLogin/Mid/Info/Agreement/Toggle_Agreement_2");
|
|
|
|
|
|
Toggle_Agreement_Account = GetComponent<Toggle>("Image_LoginBg/AccountLogin/Mid/Info/Agreement/Toggle_Agreement_1");
|
|
|
|
|
|
Image_YellowLine_Account = GetComponent<Image>("Image_LoginBg/Top/ImageBg/AccountLogin/Button_AccountLogin/Image_YellowLine_Account");
|
|
|
|
|
|
Image_YellowLine_VerifyCode = GetComponent<Image>("Image_LoginBg/Top/ImageBg/VerifyCodeLogin/Button_VerifyCodeLogin/Image_YellowLine_VerifyCode");
|
|
|
|
|
|
Toggle_RememberPassword = GetComponent<Toggle>("Image_LoginBg/AccountLogin/Mid/Info/RememberPassword/Toggle_RememberPassword");
|
|
|
|
|
|
InputField_Account = GetComponent<TMP_InputField>("Image_LoginBg/AccountLogin/Mid/Account/InputField_Account");
|
|
|
|
|
|
InputField_Password = GetComponent<TMP_InputField>("Image_LoginBg/AccountLogin/Mid/Password/InputField_Password");
|
|
|
|
|
|
Button_Login_Account = GetComponent<Button>("Image_LoginBg/AccountLogin/Bottom/Button_Login_1");
|
|
|
|
|
|
Button_Login = GetComponent<Button>("Image_LoginBg/VerifyCodeLogin/Bottom/Button_Login_2");
|
|
|
|
|
|
Button_GetVerifyCode = GetComponent<Button>("Image_LoginBg/VerifyCodeLogin/Mid/VerifyCode/Button_GetVerifyCode");
|
|
|
|
|
|
Button_GetVerifyCodeCooling = GetComponent<Button>("Image_LoginBg/VerifyCodeLogin/Mid/VerifyCode/Button_GetVerifyCodeCooling");
|
|
|
|
|
|
InputField_PhoneNumber = GetComponent<TMP_InputField>("Image_LoginBg/VerifyCodeLogin/Mid/Phone/InputField_PhoneNumber");
|
|
|
|
|
|
InputField_VerifyCode = GetComponent<TMP_InputField>("Image_LoginBg/VerifyCodeLogin/Mid/VerifyCode/InputField_VerifyCode");
|
|
|
|
|
|
Text_Agreement = GetComponent<TMP_Text>("Image_LoginBg/VerifyCodeLogin/Mid/Info/Agreement/Text_Agreement_2");
|
|
|
|
|
|
Text_Agreement_Account = GetComponent<TMP_Text>("Image_LoginBg/AccountLogin/Mid/Info/Agreement/Text_Agreement_1");
|
|
|
|
|
|
AppleBtn = GetComponent<Button>("Image_LoginBg/Bottom/LogAccountNode/Button_AppleClick");
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
|
|
|
|
|
|
InputField_PhoneNumber.onValueChanged.AddListener(PhoneNumberEdit);
|
|
|
|
|
|
InputField_VerifyCode.onValueChanged.AddListener(CodeEdit);
|
|
|
|
|
|
Toggle_Agreement.onValueChanged.AddListener(AgreementAccept);
|
|
|
|
|
|
Toggle_Agreement_Account.onValueChanged.AddListener(AgreementAccept);
|
|
|
|
|
|
Button_Login.onClick.AddListener(PhoneCodeLogin);
|
|
|
|
|
|
Button_GetVerifyCode.onClick.AddListener(SendPhoneRequest);
|
|
|
|
|
|
|
2024-11-07 15:16:00 +08:00
|
|
|
|
Button_GetVerifyCode.interactable = false;
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
ServerSelecter = FindObj("Image_LoginBg/ALDropdown").GetComponent<TMP_Dropdown>();
|
|
|
|
|
|
ServerSelecter.options.Clear();
|
|
|
|
|
|
var serverInfo = AppConfig.Instance.GetServerInfo();
|
|
|
|
|
|
if (serverInfo.Count <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in serverInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
ServerSelecter.options.Add(new TMP_Dropdown.OptionData() { text = item.name });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-25 14:44:47 +08:00
|
|
|
|
var index = PlayerPrefs.GetInt("ServerIndex", 0);
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
if (index >= 0 && index < serverInfo.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
ServerSelecter.captionText.text = serverInfo[index].name;
|
|
|
|
|
|
ServerSelecter.value = index;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ServerSelecter.captionText.text = serverInfo[0].name;
|
|
|
|
|
|
ServerSelecter.value = 0;
|
|
|
|
|
|
}
|
2025-03-18 15:28:24 +08:00
|
|
|
|
SetLinkText(Toggle_Agreement, Text_Agreement);
|
|
|
|
|
|
SetLinkText(Toggle_Agreement_Account, Text_Agreement_Account);
|
|
|
|
|
|
|
|
|
|
|
|
#if !UNITY_IOS
|
|
|
|
|
|
AppleBtn.gameObject.SetActive(false);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
bool hasShownBtn = false;
|
|
|
|
|
|
var btnParent = FindObj("Image_LoginBg/Bottom/LogAccountNode").transform;
|
|
|
|
|
|
foreach (Transform child in btnParent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (child.gameObject.activeSelf)
|
|
|
|
|
|
{
|
|
|
|
|
|
hasShownBtn = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
btnParent.parent.gameObject.SetActive(hasShownBtn);
|
|
|
|
|
|
if (!hasShownBtn)
|
|
|
|
|
|
{
|
|
|
|
|
|
AccountLoginPanel.transform.localPosition = new Vector3(0, 0, 0);
|
|
|
|
|
|
VerifyCodeLoginPanel.transform.localPosition = new Vector3(0, 0, 0);
|
|
|
|
|
|
}
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public virtual void SetLoginType(LoginType loginType)
|
2024-08-09 12:55:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
AccountLoginPanel.SetActive(loginType == LoginType.Account);
|
|
|
|
|
|
VerifyCodeLoginPanel.SetActive(loginType == LoginType.PhoneCode);
|
|
|
|
|
|
}
|
2025-03-18 15:28:24 +08:00
|
|
|
|
|
|
|
|
|
|
public virtual void CheckLoginButton(LoginType loginType, bool isToggled)
|
2024-08-09 12:55:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
switch (loginType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case LoginType.Account:
|
|
|
|
|
|
if (InputField_Account.text.Length > 0 && InputField_Password.text.Length > 0 && isToggled)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Login_Account.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Login_Account.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case LoginType.PhoneCode:
|
|
|
|
|
|
if (InputField_PhoneNumber.text.Length > 0 && InputField_VerifyCode.text.Length > 0 && isToggled)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Login.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Login.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public void CheckPhoneCodeButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (InputField_PhoneNumber.text.Length == 11)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_GetVerifyCode.interactable = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_GetVerifyCode.interactable = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public async UniTask CoolingTimer()
|
|
|
|
|
|
{
|
|
|
|
|
|
int duration = 60;
|
|
|
|
|
|
isTimer = true;
|
|
|
|
|
|
|
|
|
|
|
|
Button_GetVerifyCode.gameObject.SetActive(false);
|
|
|
|
|
|
Button_GetVerifyCodeCooling.gameObject.SetActive(true);
|
|
|
|
|
|
while (duration > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!isTimer)
|
|
|
|
|
|
{
|
|
|
|
|
|
duration = 0;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Button_GetVerifyCodeCooling.GetComponentInChildren<TMP_Text>().text = duration + "s";
|
|
|
|
|
|
await UniTask.WaitForSeconds(1);
|
|
|
|
|
|
duration--;
|
|
|
|
|
|
}
|
|
|
|
|
|
Button_GetVerifyCode.gameObject.SetActive(true);
|
|
|
|
|
|
Button_GetVerifyCodeCooling.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void SetLinkText(Toggle agreement, TMP_Text text)
|
2024-08-09 12:55:51 +08:00
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
LinkText linkText = text.GetComponent<LinkText>();
|
2024-08-09 12:55:51 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
if (linkText == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("LinkText is null");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
string url1 = "https://kedrgame.com/user_agreement.txt";
|
|
|
|
|
|
string url2 = "https://kedrgame.com/privacy_agreement.txt";
|
|
|
|
|
|
string url3 = "https://kedrgame.com/children_privacy_agreement.txt";
|
2024-08-13 16:11:48 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
string content = string.Format(CommonUtils.GetLocalizeText("uilogin_AgreementText"), url1, url2, url3);
|
|
|
|
|
|
linkText.SetText(content);
|
|
|
|
|
|
}
|
|
|
|
|
|
linkText.SetOtherAreaClicked(() => agreement.isOn = !agreement.isOn);
|
|
|
|
|
|
}
|
2024-08-09 12:55:51 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
public void SetDebugMode(bool isOn)
|
|
|
|
|
|
{
|
|
|
|
|
|
Image_line.gameObject.SetActive(isOn);
|
|
|
|
|
|
Button_AccountLogin.transform.parent.gameObject.SetActive(isOn);
|
2024-11-07 15:16:00 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
ServerSelecter.gameObject.SetActive(isOn);
|
|
|
|
|
|
Button_Debug.gameObject.SetActive(false);
|
2024-11-07 15:16:00 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
if (IsDevelopmentOrDebug())
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Debug.gameObject.SetActive(!isOn);
|
|
|
|
|
|
}
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查当前构建是否为开发版本或调试版本。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>如果是开发或调试版本,则返回 true;否则返回 false。</returns>
|
|
|
|
|
|
bool IsDevelopmentOrDebug()
|
2024-08-09 12:55:51 +08:00
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
#if DEVELOPMENT_BUILD || DEBUG
|
|
|
|
|
|
return true;
|
|
|
|
|
|
#else
|
|
|
|
|
|
return false;
|
|
|
|
|
|
#endif
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
LoginWindow curShownWindow;
|
|
|
|
|
|
|
2024-07-15 12:20:03 +08:00
|
|
|
|
LoginType loginType;
|
|
|
|
|
|
LoginData loginSaveData;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 确认登录后写入数据 (由于切换账号会清空本地数据,在这里做数据缓存)
|
|
|
|
|
|
/// </summary>
|
2024-07-15 16:08:28 +08:00
|
|
|
|
LoginData tempSaveData;
|
|
|
|
|
|
bool loginOK = false;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-10-25 14:44:47 +08:00
|
|
|
|
int serverIndex = 0;
|
2024-07-17 15:29:10 +08:00
|
|
|
|
|
|
|
|
|
|
// deal with input data
|
|
|
|
|
|
public override void PreLoad(object data = null)
|
2024-07-15 12:20:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
loginSaveData = StorageMgr.Instance.GetStorage<LoginData>("LoginData");
|
|
|
|
|
|
if (loginSaveData == null)
|
|
|
|
|
|
loginSaveData = new();
|
2024-12-09 13:17:55 +08:00
|
|
|
|
AppleLoginManager.Instance.SetCacheLoginInfo(loginSaveData.AppleAccessToken, loginSaveData.AppleID,
|
|
|
|
|
|
loginSaveData.AppleTimestamp);
|
2024-12-06 13:41:38 +08:00
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-19 14:32:17 +08:00
|
|
|
|
public override async UniTask<bool> OnBack(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
await OnBackApp();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public override void OnInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
//bind UI GameObj
|
|
|
|
|
|
UI_StartGameInterfaceBinder.GetComponents(this);
|
2024-09-13 17:37:36 +08:00
|
|
|
|
buttonTapTap = GetComponent<Button>("TapTapBtn");
|
2024-11-19 12:49:28 +08:00
|
|
|
|
buttonBilibili = GetComponent<Button>("BilibiliBtn");
|
2025-03-18 15:28:24 +08:00
|
|
|
|
Button_AppleClick = GetComponent<Button>("UI_LoginWindow/Image_LoginBg/Bottom/LogAccountNode/Button_AppleClick");
|
|
|
|
|
|
curShownWindow = new(FindObj("UI_LoginWindow"), PhoneEdit, PhoneVerifyCodeEdit, OnAgreementAccept, OnPhoneCodeLoginClick, SendPhoneCodeRequest);
|
2024-08-14 12:31:50 +08:00
|
|
|
|
|
2025-03-13 14:58:18 +08:00
|
|
|
|
AudioManager.Instance.PlayAudio("bgm_login", AudioCriManager.EPlayType.Music, null, true);
|
2024-12-04 16:27:22 +08:00
|
|
|
|
var Button_AgeTip = GetComponent<Button>("Button_AgeTip");
|
|
|
|
|
|
|
2025-02-24 20:00:53 +08:00
|
|
|
|
#region EventManager
|
2024-09-03 17:07:34 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.RealNameVerifyCancel, OnCancelCurConnect);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LoginComplete, OnLoginOK);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LoginOut, OnLogoutComplete);
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.PhoneCodeLoginSuc, OnPhoneCodeLoginSuc);
|
|
|
|
|
|
EventManager.Instance.Register<string>(EventManager.EventName.PhoneCodeLoginFail, OnPhoneCodeLoginFailed);
|
|
|
|
|
|
EventManager.Instance.Register<string>(EventManager.EventName.PhoneCodeRequsetFail, OnPhoneCodeRequestFailed);
|
2024-12-06 13:41:38 +08:00
|
|
|
|
EventManager.Instance.Register<AppleLoginManager.AppleLoginInfo>(EventManager.EventName.AppleVerifySuccess, OnNetVerifyAppleLoginSuccess);
|
2024-11-20 17:42:21 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.AppleLoginStateFail, OnCheckAppleLoginStateFail);
|
2025-02-24 20:00:53 +08:00
|
|
|
|
#endregion
|
2024-09-03 17:07:34 +08:00
|
|
|
|
|
2025-02-24 20:00:53 +08:00
|
|
|
|
#if LOGIN_PHONE // 使用手机登录界面
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.SetDebugMode(false);
|
2024-08-20 13:51:43 +08:00
|
|
|
|
#else
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.SetDebugMode(true);
|
2024-08-14 12:31:50 +08:00
|
|
|
|
#endif
|
2024-09-03 17:07:34 +08:00
|
|
|
|
HideLoginPanel();
|
|
|
|
|
|
|
2024-10-15 16:06:43 +08:00
|
|
|
|
var index = PlayerPrefs.GetInt("ServerIndex", 0);
|
2024-08-19 15:01:49 +08:00
|
|
|
|
serverIndex = index;
|
|
|
|
|
|
AppConfig.Instance.Select(index);
|
2025-02-24 20:00:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 开发环境下的特殊处理
|
2024-08-20 13:51:43 +08:00
|
|
|
|
#if DEVELOPMENT_BUILD || DEBUG
|
2025-02-24 20:00:53 +08:00
|
|
|
|
SetupDebugServerSelector();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置开发环境下的服务器选择器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void SetupDebugServerSelector()
|
|
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.ServerSelecter.gameObject.SetActive(true);
|
|
|
|
|
|
curShownWindow.ServerSelecter.onValueChanged.AddListener(OnServerSelected);
|
2025-02-24 20:00:53 +08:00
|
|
|
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 处理服务器选择事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="selectedIndex">选中的服务器索引</param>
|
|
|
|
|
|
void OnServerSelected(int selectedIndex)
|
2024-08-12 19:39:14 +08:00
|
|
|
|
{
|
2025-02-24 20:00:53 +08:00
|
|
|
|
DebugUtil.Log("选择服务器:" + selectedIndex);
|
|
|
|
|
|
AppConfig.Instance.Select(selectedIndex);
|
|
|
|
|
|
serverIndex = selectedIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-17 15:29:10 +08:00
|
|
|
|
|
2025-02-24 20:00:53 +08:00
|
|
|
|
#region BindButton
|
2025-03-18 15:28:24 +08:00
|
|
|
|
BindButton(Button_AppleClick, AppleLogin);
|
2025-02-24 20:00:53 +08:00
|
|
|
|
BindButton(Button_AgeTip, OnAgeTipsClick);
|
2025-03-18 15:28:24 +08:00
|
|
|
|
BindButton(Button_AccountLogin, () => SetLoginType(LoginType.Account));
|
|
|
|
|
|
BindButton(Button_VerifyCodeLogin, () => SetLoginType(LoginType.PhoneCode));
|
2024-08-19 15:01:49 +08:00
|
|
|
|
BindButton(Button_Login_1, OnButtonLogin);
|
2024-09-06 13:54:38 +08:00
|
|
|
|
BindButton(Button_UserCenter, ShowLoginPanel);
|
2024-08-19 15:01:49 +08:00
|
|
|
|
BindButton(Button_Notice, OnNoticeClick);
|
2024-11-19 12:49:28 +08:00
|
|
|
|
BindButton(buttonTapTap, OnTapTapBtnClick);
|
2025-03-21 16:04:17 +08:00
|
|
|
|
//BindButton(buttonBilibili, OnBilibiliClick);
|
2024-08-19 15:01:49 +08:00
|
|
|
|
BindButton(Button_StartGame, OnStartGame);
|
2025-03-18 15:28:24 +08:00
|
|
|
|
#endregion
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.Toggle_RememberPassword.onValueChanged.AddListener(OnRememberPassword);
|
|
|
|
|
|
curShownWindow.InputField_Account.onValueChanged.AddListener(AccountEdit);
|
|
|
|
|
|
curShownWindow.InputField_Password.onValueChanged.AddListener(PasswordEdit);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
Text_Version.text = "version:" + Application.version;
|
2024-08-19 15:01:49 +08:00
|
|
|
|
Text_UID.gameObject.SetActive(false);
|
2025-02-24 20:00:53 +08:00
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2025-02-24 20:00:53 +08:00
|
|
|
|
#if LOGIN_PHONE // 使用手机登录界面
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化登录窗口,根据当前环境选择调试或发布版本的登录窗口。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void InitializeLoginWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsDevelopmentOrDebug())
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeDebugLoginWindow();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow = releaseLoginWindow;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-14 12:31:50 +08:00
|
|
|
|
|
2025-02-24 20:00:53 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查当前构建是否为开发版本或调试版本。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>如果是开发或调试版本,则返回 true;否则返回 false。</returns>
|
|
|
|
|
|
bool IsDevelopmentOrDebug()
|
|
|
|
|
|
{
|
|
|
|
|
|
#if DEVELOPMENT_BUILD || DEBUG
|
|
|
|
|
|
return true;
|
|
|
|
|
|
#else
|
|
|
|
|
|
return false;
|
|
|
|
|
|
#endif
|
2024-08-12 17:34:04 +08:00
|
|
|
|
}
|
2024-07-12 14:23:06 +08:00
|
|
|
|
|
2025-02-24 20:00:53 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化调试登录窗口。设置当前显示窗口为发布登录窗口,并激活调试按钮。
|
|
|
|
|
|
/// 当调试按钮被点击时,切换当前窗口为调试登录窗口,并更新窗口的显示状态。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void InitializeDebugLoginWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow = releaseLoginWindow;
|
|
|
|
|
|
releaseLoginWindow.Button_debug.gameObject.SetActive(true);
|
|
|
|
|
|
releaseLoginWindow.Button_debug.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow.IsScaleShow = false;
|
|
|
|
|
|
curShownWindow = debugLoginWindow;
|
|
|
|
|
|
curShownWindow.IsScaleShow = true;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-07-15 12:20:03 +08:00
|
|
|
|
/// <summary>
|
2024-07-16 15:24:41 +08:00
|
|
|
|
/// 进入账号登录界面
|
2024-07-15 12:20:03 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
|
void SetLoginType(LoginType type)
|
|
|
|
|
|
{
|
|
|
|
|
|
loginType = type;
|
2024-07-16 13:11:18 +08:00
|
|
|
|
|
|
|
|
|
|
Text_UID.gameObject.SetActive(false);
|
|
|
|
|
|
Button_StartGame.gameObject.SetActive(false);
|
2024-08-09 12:55:51 +08:00
|
|
|
|
Button_UserCenter.gameObject.SetActive(false);
|
|
|
|
|
|
Button_Notice.gameObject.SetActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
curShownWindow.SetLoginType(loginType);
|
2024-08-09 13:21:39 +08:00
|
|
|
|
curShownWindow.IsScaleShow = true;
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
Image_LoginBg.gameObject.SetActive(true);
|
|
|
|
|
|
Image_UpdateBg.gameObject.SetActive(false);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
switch (loginType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case LoginType.Account://账号密码登录
|
|
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.Image_YellowLine_Account.gameObject.SetActive(true);
|
|
|
|
|
|
curShownWindow.Image_YellowLine_VerifyCode.gameObject.SetActive(false);
|
|
|
|
|
|
curShownWindow.Toggle_RememberPassword.isOn = loginSaveData.rememberPassword;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.Toggle_Agreement_Account.isOn = loginSaveData.agreement;
|
|
|
|
|
|
curShownWindow.VerifyCodeLoginPanel.SetActive(false);
|
|
|
|
|
|
curShownWindow.AccountLoginPanel.SetActive(true);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
|
|
|
|
|
if (loginSaveData.account != default)
|
|
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.InputField_Account.text = loginSaveData.account;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (loginSaveData.password != default && loginSaveData.rememberPassword)
|
|
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.InputField_Password.text = loginSaveData.password;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.InputField_Password.text = string.Empty;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
case LoginType.PhoneCode://手机号验证码登录
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.Image_YellowLine_Account.gameObject.SetActive(false);
|
|
|
|
|
|
curShownWindow.Image_YellowLine_VerifyCode.gameObject.SetActive(true);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.Toggle_Agreement.isOn = loginSaveData.agreement;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
curShownWindow.CheckPhoneCodeButton();
|
2024-07-15 12:20:03 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
2024-09-13 17:37:36 +08:00
|
|
|
|
case LoginType.TapTap:
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow.IsScaleShow = false;
|
|
|
|
|
|
buttonTapTap.gameObject.IsScaleShow(true);
|
2024-11-19 12:49:28 +08:00
|
|
|
|
buttonBilibili.gameObject.IsScaleShow(false);
|
2024-09-13 17:37:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
2024-11-06 18:27:02 +08:00
|
|
|
|
|
2024-11-05 18:45:00 +08:00
|
|
|
|
case LoginType.Bilibili:
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow.IsScaleShow = false;
|
|
|
|
|
|
buttonTapTap.gameObject.IsScaleShow(false);
|
2024-11-19 12:49:28 +08:00
|
|
|
|
buttonBilibili.gameObject.IsScaleShow(true);
|
2024-11-05 18:45:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
default:
|
|
|
|
|
|
DebugUtil.LogError("SetLoginType error");
|
2024-07-15 12:20:03 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
curShownWindow.CheckLoginButton(loginType, loginSaveData.agreement);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HideLoginPanel()
|
2024-09-13 17:37:36 +08:00
|
|
|
|
{
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//Image_LoginBg.gameObject.SetActive(false);
|
|
|
|
|
|
curShownWindow.IsScaleShow = false;
|
2024-09-13 17:37:36 +08:00
|
|
|
|
buttonTapTap.gameObject.IsScaleShow(false);
|
2024-11-19 12:49:28 +08:00
|
|
|
|
buttonBilibili.gameObject.IsScaleShow(false);
|
2024-07-16 13:11:18 +08:00
|
|
|
|
|
|
|
|
|
|
Button_StartGame.gameObject.SetActive(true);
|
|
|
|
|
|
Button_Notice.gameObject.SetActive(true);
|
2025-03-21 16:04:17 +08:00
|
|
|
|
|
|
|
|
|
|
#if SDK_BILIBILI
|
|
|
|
|
|
Button_UserCenter.gameObject.SetActive(false);
|
|
|
|
|
|
#else
|
2024-09-13 17:37:36 +08:00
|
|
|
|
Button_UserCenter.gameObject.SetActive(true);
|
2025-03-21 16:04:17 +08:00
|
|
|
|
#endif
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-09-13 17:37:36 +08:00
|
|
|
|
|
|
|
|
|
|
//invoke when destroy
|
|
|
|
|
|
public override void OnRelease()
|
2024-07-12 14:23:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
base.OnRelease();
|
2024-09-23 16:00:11 +08:00
|
|
|
|
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.isTimer = false;
|
2024-09-23 16:00:11 +08:00
|
|
|
|
|
2024-08-19 15:38:01 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.RealNameVerifyCancel, OnCancelCurConnect);
|
2024-08-07 15:45:10 +08:00
|
|
|
|
EventManager.Instance.Unregister<string>(EventManager.EventName.PhoneCodeLoginFail, OnPhoneCodeLoginFailed);
|
|
|
|
|
|
EventManager.Instance.Unregister<string>(EventManager.EventName.PhoneCodeRequsetFail, OnPhoneCodeRequestFailed);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.PhoneCodeLoginSuc, OnPhoneCodeLoginSuc);
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LoginComplete, OnLoginOK);
|
2024-08-19 15:38:01 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.LoginOut, OnLogoutComplete);
|
2024-12-06 13:41:38 +08:00
|
|
|
|
EventManager.Instance.Unregister<AppleLoginManager.AppleLoginInfo>(EventManager.EventName.AppleVerifySuccess, OnNetVerifyAppleLoginSuccess);
|
2024-11-20 17:42:21 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.AppleLoginStateFail, OnCheckAppleLoginStateFail);
|
2025-03-13 14:58:18 +08:00
|
|
|
|
|
|
|
|
|
|
AudioManager.Instance.StopAll();
|
|
|
|
|
|
AudioManager.Instance.ReleaseAllAudios();
|
2024-09-09 14:38:47 +08:00
|
|
|
|
//EventManager.Instance.Unregister(EventManager.EventName.NetError, ConnectNetError);
|
2024-08-19 15:38:01 +08:00
|
|
|
|
//EventManager.Instance.Unregister(Framework.EventManager.EventName.NetError, OnCancelCurConnect);
|
|
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-12 17:34:04 +08:00
|
|
|
|
#region Button_Listener
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
|
|
|
|
|
void OnRememberPassword(bool isOn)
|
|
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.rememberPassword = isOn;
|
|
|
|
|
|
}
|
2024-08-09 12:55:51 +08:00
|
|
|
|
void OnAgreementAccept(bool isOn)
|
|
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.agreement = isOn;
|
|
|
|
|
|
curShownWindow.CheckLoginButton(loginType, loginSaveData.agreement);
|
|
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-07-15 19:09:11 +08:00
|
|
|
|
void AccountEdit(string text)
|
2024-07-15 12:20:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.account = text;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.InputField_Password.text = string.Empty;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
curShownWindow.CheckLoginButton(loginType, loginSaveData.agreement);
|
|
|
|
|
|
//CheckLoginButton();
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-07-15 19:09:11 +08:00
|
|
|
|
void PasswordEdit(string text)
|
2024-07-15 12:20:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.password = text;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//CheckLoginButton();
|
|
|
|
|
|
curShownWindow.CheckLoginButton(loginType, loginSaveData.agreement);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-07-30 19:07:27 +08:00
|
|
|
|
void PhoneEdit(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.phoneNumber = text;
|
|
|
|
|
|
//CheckLoginButton();
|
2024-08-09 12:55:51 +08:00
|
|
|
|
curShownWindow.CheckPhoneCodeButton();
|
2024-07-30 19:07:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
void PhoneVerifyCodeEdit(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
//loginSaveData.verifyCode = text;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//CheckLoginButton();
|
|
|
|
|
|
curShownWindow.CheckLoginButton(loginType, loginSaveData.agreement);
|
2024-07-30 19:07:27 +08:00
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-07-15 16:08:28 +08:00
|
|
|
|
/// <summary>
|
2024-07-16 15:24:41 +08:00
|
|
|
|
/// 尝试登录
|
2024-07-15 16:08:28 +08:00
|
|
|
|
/// </summary>
|
2024-07-15 12:20:03 +08:00
|
|
|
|
void OnButtonLogin()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!loginSaveData.rememberPassword)
|
|
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.password = default;
|
|
|
|
|
|
}
|
2024-09-10 11:41:36 +08:00
|
|
|
|
loginSaveData.LoginByAccount = true;
|
2024-07-16 15:24:41 +08:00
|
|
|
|
tempSaveData = new(loginSaveData);//暂存登录数据
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-07-15 16:08:28 +08:00
|
|
|
|
LoginAction();
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("login_check", new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"method",0 }//0表示手动输入登录
|
|
|
|
|
|
});
|
2024-09-03 19:17:08 +08:00
|
|
|
|
DebugUtil.Log("点击登录按钮,拉起加载图标遮挡");
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-09-18 17:51:22 +08:00
|
|
|
|
|
2024-07-30 19:07:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 请求发送验证码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void SendPhoneCodeRequest()
|
|
|
|
|
|
{
|
2024-10-16 18:09:38 +08:00
|
|
|
|
curShownWindow.CoolingTimer().Forget();
|
2024-08-07 15:45:10 +08:00
|
|
|
|
PhoneVerifyTool.Instance.PhoneNumber = loginSaveData.phoneNumber;
|
|
|
|
|
|
PhoneVerifyTool.Instance.PhoneCodeWebRequest();
|
|
|
|
|
|
|
2024-08-13 12:30:13 +08:00
|
|
|
|
//isTimer = true;
|
2024-07-30 19:07:27 +08:00
|
|
|
|
}
|
2024-09-18 17:51:22 +08:00
|
|
|
|
|
2024-07-30 19:07:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 手机验证码登录
|
|
|
|
|
|
/// </summary>
|
2024-08-07 15:45:10 +08:00
|
|
|
|
void OnPhoneCodeLoginClick()
|
2024-07-30 19:07:27 +08:00
|
|
|
|
{
|
2024-08-12 17:34:04 +08:00
|
|
|
|
tempSaveData = new(loginSaveData);//暂存登录数据
|
|
|
|
|
|
|
2024-08-07 15:45:10 +08:00
|
|
|
|
PhoneVerifyTool.Instance.PhoneNumber = loginSaveData.phoneNumber;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
PhoneVerifyTool.Instance.HttpVerifyCode = curShownWindow.InputField_VerifyCode.text;
|
2024-08-07 15:45:10 +08:00
|
|
|
|
|
2024-08-23 13:49:43 +08:00
|
|
|
|
#if DEVELOPMENT_BUILD || DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
PlayerPrefs.SetInt("ServerIndex", serverIndex);
|
|
|
|
|
|
#else
|
|
|
|
|
|
var serverInfos = AppConfig.Instance.GetServerInfo();
|
|
|
|
|
|
AppConfig.Instance.Select(serverIndex);
|
|
|
|
|
|
#endif
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("login_check", new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"method",0 }//0表示手动输入登录
|
|
|
|
|
|
});
|
2024-08-07 15:45:10 +08:00
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.Phxhphone, loginSaveData.phoneNumber);
|
2024-10-14 18:32:25 +08:00
|
|
|
|
DebugUtil.Log("点击登录按钮,拉起加载图标遮挡");
|
2024-07-30 19:07:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-13 17:37:36 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// TapTap登录
|
|
|
|
|
|
/// </summary>
|
2024-11-19 12:49:28 +08:00
|
|
|
|
private void OnTapTapBtnClick()
|
2024-09-13 17:37:36 +08:00
|
|
|
|
{
|
2024-09-25 16:39:30 +08:00
|
|
|
|
#if SDK_TAPTAP
|
2024-10-25 18:43:59 +08:00
|
|
|
|
WaitingForServer.Instance.EventWaiting(WaitingForServer.EventName.TapTapLogin, false, false);
|
2024-09-25 16:39:30 +08:00
|
|
|
|
TapTapLogin.Instance.Logout();
|
2024-09-13 17:37:36 +08:00
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.TapTap, "");
|
2024-09-25 16:39:30 +08:00
|
|
|
|
#endif
|
2024-09-13 17:37:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-19 12:49:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Bilibili登录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnBilibiliClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
#if SDK_BILIBILI
|
2024-12-24 18:26:40 +08:00
|
|
|
|
DebugUtil.Log("点击哔哩哔哩登录");
|
2024-12-26 15:48:21 +08:00
|
|
|
|
GSCSdkInterface.stopHeartbeat();
|
2024-12-24 18:26:40 +08:00
|
|
|
|
GSCSdkInterface.logout();
|
2024-11-19 12:49:28 +08:00
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.BiliBili, "");
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-19 15:01:49 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 服务器登录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void LoginAction()
|
|
|
|
|
|
{
|
2024-08-20 13:51:43 +08:00
|
|
|
|
#if DEVELOPMENT_BUILD || DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
PlayerPrefs.SetInt("ServerIndex", serverIndex);
|
|
|
|
|
|
#else
|
|
|
|
|
|
var serverInfos = AppConfig.Instance.GetServerInfo();
|
|
|
|
|
|
AppConfig.Instance.Select(serverIndex);
|
|
|
|
|
|
#endif
|
2024-07-15 16:08:28 +08:00
|
|
|
|
Gameplay.Net.Actor.Instance.StartLogin(NLDPB.LoginType.Phxh, loginSaveData.account);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-10 11:41:36 +08:00
|
|
|
|
void PhoneAutoLogin()
|
|
|
|
|
|
{
|
|
|
|
|
|
PhoneVerifyTool.Instance.RefreshTokenTime = loginSaveData.AuthCodeUpdateTime;
|
|
|
|
|
|
PhoneVerifyTool.Instance.RefreshToken = loginSaveData.AuthCode;
|
|
|
|
|
|
PhoneVerifyTool.Instance.PhoneNumber = loginSaveData.phoneNumber;
|
|
|
|
|
|
PlayerPrefs.SetInt("ServerIndex", serverIndex);
|
|
|
|
|
|
DebugUtil.Log("已有手机号登录凭证,自动登录");
|
|
|
|
|
|
//OnPhoneCodeLoginClick();
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("login_check", new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"method",1 }//1表示自动登录
|
|
|
|
|
|
});
|
2024-09-10 11:41:36 +08:00
|
|
|
|
PhoneVerifyTool.Instance.RefreshTokenRequest((i, msg) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.Phxhphone, loginSaveData.phoneNumber);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ShowMessageTips(msg);
|
2024-09-23 15:33:58 +08:00
|
|
|
|
loginSaveData.AuthCode = string.Empty;
|
|
|
|
|
|
loginSaveData.AuthCodeUpdateTime = 0;
|
|
|
|
|
|
StorageMgr.Instance.SyncForce = true;
|
2024-09-10 11:41:36 +08:00
|
|
|
|
SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-02-24 20:00:53 +08:00
|
|
|
|
|
|
|
|
|
|
void OnAgeTipsClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
UI_AgeTipController.Open().Forget();
|
|
|
|
|
|
}
|
2024-11-14 13:29:20 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 苹果登录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void AppleLogin()
|
2024-11-19 14:45:17 +08:00
|
|
|
|
{
|
2024-11-27 14:46:55 +08:00
|
|
|
|
if (!loginSaveData.agreement)
|
|
|
|
|
|
{
|
|
|
|
|
|
UITipsManager.ShowConfirmOne("登录提示", "请先勾选同意隐私协议", null);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-11-14 14:49:37 +08:00
|
|
|
|
PlayerPrefs.SetInt("ServerIndex", serverIndex);
|
2024-11-14 13:29:20 +08:00
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.Apple, "");
|
|
|
|
|
|
}
|
2024-09-10 11:41:36 +08:00
|
|
|
|
|
|
|
|
|
|
void ShowLoginPanel()
|
|
|
|
|
|
{
|
2024-11-22 14:15:04 +08:00
|
|
|
|
// 切换账户
|
|
|
|
|
|
AppleLoginManager.Instance.ClearAppleLoginInfo();
|
2024-09-13 17:37:36 +08:00
|
|
|
|
#if SDK_TAPTAP
|
|
|
|
|
|
SetLoginType(LoginType.TapTap);
|
2024-11-05 19:34:28 +08:00
|
|
|
|
#elif SDK_BILIBILI
|
|
|
|
|
|
SetLoginType(LoginType.Bilibili);
|
2024-09-13 17:37:36 +08:00
|
|
|
|
#else
|
|
|
|
|
|
if (loginSaveData.LoginByPhone)
|
2024-09-10 11:41:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.Account);
|
|
|
|
|
|
}
|
2024-09-13 17:37:36 +08:00
|
|
|
|
#endif
|
2024-09-10 11:41:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-13 17:37:36 +08:00
|
|
|
|
async void OnNoticeClick()
|
2024-07-15 16:08:28 +08:00
|
|
|
|
{
|
2024-09-10 11:41:36 +08:00
|
|
|
|
await UI_NoticeController.Open();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-18 17:51:22 +08:00
|
|
|
|
private async void OnStartGame()
|
2024-09-10 11:41:36 +08:00
|
|
|
|
{
|
2024-09-13 17:37:36 +08:00
|
|
|
|
#if SDK_TAPTAP
|
2024-09-18 17:51:22 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
TapTapAccount account = await TapTapLogin.Instance.GetCurrentTapAccount();
|
|
|
|
|
|
if (null == account)
|
|
|
|
|
|
ShowLoginPanel();
|
|
|
|
|
|
else
|
2024-09-25 16:39:30 +08:00
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.TapTap, "");
|
2024-09-18 17:51:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"获取用户信息失败 {e.Message}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-13 17:37:36 +08:00
|
|
|
|
return;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-11-19 19:25:12 +08:00
|
|
|
|
#if SDK_BILIBILI
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2025-03-21 16:04:17 +08:00
|
|
|
|
DebugUtil.Log("点击哔哩哔哩登录");
|
2024-11-19 19:25:12 +08:00
|
|
|
|
GSCSdkInterface.androidCheckLogin();
|
|
|
|
|
|
await UniTask.WaitUntil(() => { return !GSCSdkInterface.CheckLoging; });
|
|
|
|
|
|
if (GSCSdkInterface.IsLogin)
|
2025-03-25 13:58:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("已登录状态,进入游戏");
|
2024-11-19 19:25:12 +08:00
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.BiliBili, "");
|
2025-03-25 13:58:04 +08:00
|
|
|
|
}
|
2024-11-19 19:25:12 +08:00
|
|
|
|
else
|
2025-03-25 13:58:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("未登录状态,拉起登录界面");
|
2025-03-21 16:04:17 +08:00
|
|
|
|
OnBilibiliClick();//ShowLoginPanel();
|
2025-03-25 13:58:04 +08:00
|
|
|
|
}
|
2024-11-19 19:25:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"获取用户信息失败 {e.Message}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
if (loginSaveData.LoginByPhone && loginSaveData.AuthCodeUpdateTime > DateTimeOffset.UtcNow.ToUnixTimeSeconds())//手机号Token自动登录
|
2024-09-10 11:41:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
PhoneAutoLogin();
|
|
|
|
|
|
}
|
|
|
|
|
|
#if !LOGIN_PHONE
|
|
|
|
|
|
else if (loginSaveData.LoginByAccount && loginSaveData.rememberPassword && LoginController.Instance.AutoLogin)//保存有数据且为初次登录时尝试自动登录
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("已有账号密码,自动登录");
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("login_check", new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"method",1 }//1表示自动登录
|
|
|
|
|
|
});
|
2024-09-10 11:41:36 +08:00
|
|
|
|
LoginAction();
|
|
|
|
|
|
DebugUtil.Log("点击登录按钮,拉起加载图标遮挡");
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (loginSaveData.LoginByAccount)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.Account);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2024-12-09 13:17:55 +08:00
|
|
|
|
else if(loginSaveData.AppleLogin && AppleLoginManager.Instance.AppleLoginInfoIsExist() && !AppleLoginManager.Instance.CheckExpirationTime())
|
2024-11-14 13:29:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
AppleLogin();
|
|
|
|
|
|
}
|
2024-09-10 11:41:36 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-13 13:25:41 +08:00
|
|
|
|
#endregion
|
2024-09-10 11:41:36 +08:00
|
|
|
|
|
|
|
|
|
|
#region RegisterEvent
|
|
|
|
|
|
void OnLoginOK()
|
|
|
|
|
|
{
|
2024-09-03 17:07:34 +08:00
|
|
|
|
//loginOK = true;
|
|
|
|
|
|
HideLoginPanel();
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-09-10 11:41:36 +08:00
|
|
|
|
loginSaveData = StorageMgr.Instance.GetStorage<LoginData>("LoginData");
|
|
|
|
|
|
if (loginSaveData == null)
|
|
|
|
|
|
loginSaveData = new();
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-09-10 11:41:36 +08:00
|
|
|
|
if (tempSaveData != null)
|
|
|
|
|
|
loginSaveData.SetData(tempSaveData);
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-09-10 11:41:36 +08:00
|
|
|
|
if (loginSaveData.LoginByAccount)
|
|
|
|
|
|
{
|
|
|
|
|
|
loginSaveData.LoginByPhone = false;
|
|
|
|
|
|
}
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-09-10 11:41:36 +08:00
|
|
|
|
StorageMgr.Instance.SyncForce = true;
|
2024-07-24 19:24:11 +08:00
|
|
|
|
|
2024-09-10 11:41:36 +08:00
|
|
|
|
Text_UID.gameObject.SetActive(true);
|
|
|
|
|
|
Text_UID.text = "UID: " + Actor.Instance.Base.GetProp(ActorProp.ActorId);
|
|
|
|
|
|
|
2025-02-18 13:23:46 +08:00
|
|
|
|
//BIManager.Instance.TrackEvent(BIManager.BI_GameStart, param: new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// {"login_finish" , 1 }
|
|
|
|
|
|
//});
|
2025-01-13 13:25:41 +08:00
|
|
|
|
#if SDK_TAPTAP || SDK_BILIBILI || OverseaDev
|
2024-10-16 14:36:03 +08:00
|
|
|
|
//TAPTAP不走自带实名认证
|
2024-10-16 19:19:32 +08:00
|
|
|
|
CloseWindow();
|
2024-10-16 14:36:03 +08:00
|
|
|
|
Actor.Instance.OnEnterGame();
|
2024-10-16 14:36:03 +08:00
|
|
|
|
#else
|
2024-09-10 11:41:36 +08:00
|
|
|
|
var adultStatus = (int)Actor.Instance.Logic.GetCount((uint)LogicID.AdultAuthStatus);
|
|
|
|
|
|
if (adultStatus == (int)AAStatus.AasNone)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("未实名认证");
|
|
|
|
|
|
UI_NoticeWindowController.Open().Forget();
|
|
|
|
|
|
}
|
2024-11-04 15:22:27 +08:00
|
|
|
|
else if (adultStatus == (int)AAStatus.AasUnderEighteen && !CommonUtils.IsUnderagePlayTimeAllowed())
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("未成年时段限制");
|
|
|
|
|
|
WaitingForServer.Instance.EventClear();
|
|
|
|
|
|
}
|
2024-09-03 17:07:34 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-10-16 19:19:32 +08:00
|
|
|
|
CloseWindow();
|
2024-09-03 17:07:34 +08:00
|
|
|
|
Actor.Instance.OnEnterGame();
|
|
|
|
|
|
}
|
2024-10-16 14:36:03 +08:00
|
|
|
|
#endif
|
2024-09-03 17:07:34 +08:00
|
|
|
|
}
|
2024-08-15 12:51:51 +08:00
|
|
|
|
void OnLogoutComplete()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (loginSaveData.LoginByPhone)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.Account);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-10 11:41:36 +08:00
|
|
|
|
void OnCancelCurConnect()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LoginController.Instance.IsLogin)//需要断开连接
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("登出!断开连接");
|
|
|
|
|
|
Actor.Instance.OnDisConnect();
|
|
|
|
|
|
Actor.Instance.OnLogout();
|
|
|
|
|
|
}
|
|
|
|
|
|
ShowLoginPanel();
|
|
|
|
|
|
}
|
2024-08-07 15:45:10 +08:00
|
|
|
|
void OnPhoneCodeRequestFailed(string errorMsg)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ShowMessageTips(errorMsg);
|
2024-08-13 12:30:13 +08:00
|
|
|
|
//isTimer = false;
|
2025-03-18 15:28:24 +08:00
|
|
|
|
curShownWindow.isTimer = false;
|
2024-08-07 15:45:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
void OnPhoneCodeLoginSuc()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tempSaveData != null)
|
|
|
|
|
|
{
|
2024-08-12 17:34:04 +08:00
|
|
|
|
tempSaveData.AccessToken = PhoneVerifyTool.Instance.AccessTokenCode;
|
2024-09-10 11:41:36 +08:00
|
|
|
|
tempSaveData.AuthCode = PhoneVerifyTool.Instance.RefreshToken;
|
2024-08-09 14:30:52 +08:00
|
|
|
|
tempSaveData.AuthCodeUpdateTime = PhoneVerifyTool.Instance.RefreshTokenTime;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
tempSaveData.ClearAccountLoginData();
|
|
|
|
|
|
tempSaveData.LoginByPhone = true;
|
2024-09-10 11:41:36 +08:00
|
|
|
|
tempSaveData.LoginByAccount = false;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogWarning("暂存登录数据为空!");
|
2024-08-07 15:45:10 +08:00
|
|
|
|
}
|
2024-09-10 11:41:36 +08:00
|
|
|
|
loginSaveData.AuthCode = PhoneVerifyTool.Instance.RefreshToken;
|
2024-08-09 14:30:52 +08:00
|
|
|
|
loginSaveData.AuthCodeUpdateTime = PhoneVerifyTool.Instance.RefreshTokenTime;
|
2024-08-23 13:11:56 +08:00
|
|
|
|
DebugUtil.Log("登录token:" + PhoneVerifyTool.Instance.AccessTokenCode);
|
2024-08-07 15:45:10 +08:00
|
|
|
|
DebugUtil.Log("验证码登录成功!保存登录凭证:" + loginSaveData.AuthCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
void OnPhoneCodeLoginFailed(string errorMsg)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ShowMessageTips(errorMsg);
|
|
|
|
|
|
}
|
2024-12-06 13:41:38 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 服务器验证苹果登录成功
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnNetVerifyAppleLoginSuccess(AppleLoginManager.AppleLoginInfo appleLoginInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tempSaveData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
tempSaveData.ClearAccountLoginData();
|
|
|
|
|
|
tempSaveData.AppleLogin = true;
|
|
|
|
|
|
tempSaveData.AppleID = appleLoginInfo.AppleID;
|
2024-12-06 18:25:59 +08:00
|
|
|
|
tempSaveData.AppleAccessToken = appleLoginInfo.AccessTokenID;
|
2024-12-09 13:17:55 +08:00
|
|
|
|
tempSaveData.AppleTimestamp = appleLoginInfo.Timestamp.ToString();
|
2024-12-06 13:41:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loginSaveData.AppleID = appleLoginInfo.AppleID;
|
2024-12-06 18:25:59 +08:00
|
|
|
|
loginSaveData.AppleAccessToken = appleLoginInfo.AccessTokenID;
|
2024-12-09 13:17:55 +08:00
|
|
|
|
loginSaveData.AppleTimestamp = appleLoginInfo.Timestamp.ToString();
|
2024-12-06 13:41:38 +08:00
|
|
|
|
loginSaveData.AppleLogin = true;
|
|
|
|
|
|
StorageMgr.Instance.SyncForce = true;
|
2024-12-09 13:17:55 +08:00
|
|
|
|
DebugUtil.Log("苹果登录成功, 缓存用户ID:【{0}】, 过期时间:【{1}】, accessToken【{2}】", appleLoginInfo.AppleID,
|
|
|
|
|
|
appleLoginInfo.Timestamp, appleLoginInfo.AccessTokenID);
|
2024-11-20 17:42:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnCheckAppleLoginStateFail()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tempSaveData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
tempSaveData.ClearAppleLoginData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
loginSaveData.ClearAppleLoginData();
|
|
|
|
|
|
StorageMgr.Instance.SyncForce = true;
|
2024-12-09 15:17:35 +08:00
|
|
|
|
DebugUtil.Log("苹果凭证失效, 清除缓存");
|
2024-11-14 13:29:20 +08:00
|
|
|
|
}
|
2024-10-16 14:36:03 +08:00
|
|
|
|
#endregion
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
|
|
|
|
|
class LoginData
|
|
|
|
|
|
{
|
2024-07-15 16:08:28 +08:00
|
|
|
|
/// <summary>
|
2024-07-16 15:24:41 +08:00
|
|
|
|
/// 用账号密码成功登录
|
2024-07-15 16:08:28 +08:00
|
|
|
|
/// </summary>
|
2024-07-15 12:20:03 +08:00
|
|
|
|
public bool LoginByAccount = false;
|
|
|
|
|
|
public string account;
|
|
|
|
|
|
public string password;
|
|
|
|
|
|
public bool rememberPassword;
|
|
|
|
|
|
|
2024-08-12 17:34:04 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用手机验证成功登录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool LoginByPhone = false;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
public string phoneNumber;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
public string AccessToken;
|
2024-09-03 17:07:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 刷新凭证
|
|
|
|
|
|
/// </summary>
|
2024-08-07 15:45:10 +08:00
|
|
|
|
public string AuthCode;
|
2024-08-09 14:30:52 +08:00
|
|
|
|
public long AuthCodeUpdateTime;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-11-20 17:42:21 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 苹果登录数据
|
|
|
|
|
|
/// </summary>
|
2024-11-14 13:29:20 +08:00
|
|
|
|
public bool AppleLogin = false;
|
2024-12-06 13:41:38 +08:00
|
|
|
|
public string AppleAccessToken;
|
2024-11-19 18:05:35 +08:00
|
|
|
|
public string AppleID;
|
2024-12-09 13:17:55 +08:00
|
|
|
|
public string AppleTimestamp;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
|
|
|
|
|
|
public bool agreement;
|
|
|
|
|
|
|
2024-07-15 16:08:28 +08:00
|
|
|
|
public LoginData()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public LoginData(LoginData loginData)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoginByAccount = loginData.LoginByAccount;
|
|
|
|
|
|
this.LoginByPhone = loginData.LoginByPhone;
|
|
|
|
|
|
|
|
|
|
|
|
this.account = loginData.account;
|
|
|
|
|
|
this.password = loginData.password;
|
|
|
|
|
|
this.rememberPassword = loginData.rememberPassword;
|
|
|
|
|
|
this.agreement = loginData.agreement;
|
|
|
|
|
|
this.phoneNumber = loginData.phoneNumber;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
this.AccessToken = loginData.AccessToken;
|
|
|
|
|
|
this.AuthCode = loginData.AuthCode;
|
|
|
|
|
|
this.AuthCodeUpdateTime = loginData.AuthCodeUpdateTime;
|
2024-11-19 14:45:17 +08:00
|
|
|
|
this.AppleLogin = loginData.AppleLogin;
|
2024-12-06 13:41:38 +08:00
|
|
|
|
this.AppleAccessToken = loginData.AppleAccessToken;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetData(LoginData loginData)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoginByAccount = loginData.LoginByAccount;
|
|
|
|
|
|
this.LoginByPhone = loginData.LoginByPhone;
|
|
|
|
|
|
|
|
|
|
|
|
this.account = loginData.account;
|
|
|
|
|
|
this.password = loginData.password;
|
|
|
|
|
|
this.rememberPassword = loginData.rememberPassword;
|
|
|
|
|
|
this.agreement = loginData.agreement;
|
|
|
|
|
|
this.phoneNumber = loginData.phoneNumber;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
this.AccessToken = loginData.AccessToken;
|
|
|
|
|
|
this.AuthCode = loginData.AuthCode;
|
|
|
|
|
|
this.AuthCodeUpdateTime = loginData.AuthCodeUpdateTime;
|
2024-11-19 14:45:17 +08:00
|
|
|
|
this.AppleLogin = loginData.AppleLogin;
|
2024-12-06 13:41:38 +08:00
|
|
|
|
this.AppleAccessToken = loginData.AppleAccessToken;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
public void ClearAccountLoginData()
|
|
|
|
|
|
{
|
|
|
|
|
|
LoginByAccount = false;
|
|
|
|
|
|
account = string.Empty;
|
|
|
|
|
|
password = string.Empty;
|
|
|
|
|
|
rememberPassword = false;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
}
|
2024-11-20 17:42:21 +08:00
|
|
|
|
|
|
|
|
|
|
public void ClearAppleLoginData()
|
|
|
|
|
|
{
|
|
|
|
|
|
AppleLogin = false;
|
2024-12-06 13:41:38 +08:00
|
|
|
|
AppleAccessToken = string.Empty;
|
2024-11-20 17:42:21 +08:00
|
|
|
|
AppleID = string.Empty;
|
|
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-07-12 14:23:06 +08:00
|
|
|
|
}
|
2024-08-15 12:51:51 +08:00
|
|
|
|
|
2024-09-03 17:07:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用于记录登陆状态
|
|
|
|
|
|
/// </summary>
|
2024-08-15 12:51:51 +08:00
|
|
|
|
public class LoginController : Singlenton<LoginController>
|
|
|
|
|
|
{
|
|
|
|
|
|
bool autoLogin = true;//第一次尝试自动登录
|
2024-12-30 17:05:46 +08:00
|
|
|
|
|
2024-08-15 12:51:51 +08:00
|
|
|
|
public bool AutoLogin
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return autoLogin; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool isLogin = false;
|
2024-12-30 17:05:46 +08:00
|
|
|
|
|
2024-08-15 12:51:51 +08:00
|
|
|
|
public bool IsLogin
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return isLogin; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LoginController()
|
|
|
|
|
|
{
|
|
|
|
|
|
autoLogin = true;
|
|
|
|
|
|
isLogin = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnLogout()
|
|
|
|
|
|
{
|
2024-10-22 15:23:19 +08:00
|
|
|
|
//autoLogin = false;
|
2024-08-15 12:51:51 +08:00
|
|
|
|
isLogin = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnLoginOK()
|
|
|
|
|
|
{
|
2024-10-22 15:23:19 +08:00
|
|
|
|
//autoLogin = false;//登录成功后关闭自动登录
|
2024-08-15 12:51:51 +08:00
|
|
|
|
isLogin = true;
|
2024-09-18 15:25:47 +08:00
|
|
|
|
|
|
|
|
|
|
//是否为新注册用户
|
|
|
|
|
|
int completeStepId = (int)Actor.Instance.Logic.GetCount((uint)LogicID.NewGuideProgress);
|
|
|
|
|
|
if (completeStepId == 0)
|
|
|
|
|
|
{
|
2024-12-23 16:15:03 +08:00
|
|
|
|
#if SDK_BILIBILI
|
2024-12-23 16:49:42 +08:00
|
|
|
|
GSCSdkInterface.createRole(Actor.Instance.Base.Nickname, Actor.Instance.Base.AccountID); // 创建角色
|
2024-12-23 16:15:03 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-09-18 15:25:47 +08:00
|
|
|
|
NetHelper.SaveGuideProgress(1);
|
2024-12-23 16:15:03 +08:00
|
|
|
|
|
2024-09-18 18:18:34 +08:00
|
|
|
|
#if SDK_TALKINGDATA
|
2025-02-11 14:40:04 +08:00
|
|
|
|
BIManager.Instance.SetUserProperty(TalkingDataProfileParamName.Name, Actor.Instance.Base.Nickname);
|
|
|
|
|
|
BIManager.Instance.TrackEvent(TalkingDataEventName.Register, null);
|
2024-09-18 18:18:34 +08:00
|
|
|
|
#endif
|
2024-09-18 15:25:47 +08:00
|
|
|
|
}
|
2024-12-23 16:15:03 +08:00
|
|
|
|
|
2025-02-11 14:40:04 +08:00
|
|
|
|
#if SDK_TALKINGDATA
|
|
|
|
|
|
BIManager.Instance.SetUserProperty(TalkingDataProfileParamName.Name, Actor.Instance.Base.Nickname);
|
|
|
|
|
|
BIManager.Instance.TrackEvent(TalkingDataEventName.Login, null);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-12-23 16:15:03 +08:00
|
|
|
|
#if SDK_BILIBILI
|
2024-12-26 15:48:21 +08:00
|
|
|
|
GSCSdkInterface.startHeartbeat();
|
2024-12-23 16:49:42 +08:00
|
|
|
|
GSCSdkInterface.notifyZone(Actor.Instance.Base.AccountID, Actor.Instance.Base.Nickname); // 通知区服
|
2024-12-23 16:15:03 +08:00
|
|
|
|
#endif
|
2024-08-15 12:51:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-19 14:45:17 +08:00
|
|
|
|
|