2024-08-09 13:21:39 +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-13 16:11:48 +08:00
|
|
|
|
using UnityEngine.Networking;
|
2024-08-09 13:21:39 +08:00
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
using Toggle = UnityEngine.UI.Toggle;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
|
|
|
|
|
|
public class UI_StartGameInterfaceController : UIWindow
|
|
|
|
|
|
{
|
2024-07-15 12:20:03 +08:00
|
|
|
|
enum LoginType
|
|
|
|
|
|
{
|
|
|
|
|
|
Account,
|
|
|
|
|
|
PhoneCode
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region UI_obj
|
|
|
|
|
|
//UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
|
|
|
|
|
public Image Image_Bg;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_BgDark;
|
|
|
|
|
|
public Button Button_StartGame;
|
|
|
|
|
|
public Image Image_LoginBg;
|
|
|
|
|
|
public Button Button_AccountLogin_1;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//public Image Image_YellowLine_Account_1;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Button Button_VerifyCodeLogin_1;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//public Image Image_YellowLine_VerifyCode_1;
|
|
|
|
|
|
//public TMP_InputField InputField_Account;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_AccountIcon;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//public TMP_InputField InputField_Password;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_PasswordIcon;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//public Toggle Toggle_RememberPassword;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public TMP_Text Text_RememberPassword;
|
|
|
|
|
|
public Toggle Toggle_Agreement_1;
|
2024-08-14 12:31:50 +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;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//public TMP_InputField InputField_PhoneNumber;
|
2024-07-12 14:23:06 +08:00
|
|
|
|
public Image Image_PhoneIcon;
|
2024-08-09 12:55:51 +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;
|
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;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
///Auto Gen End///
|
|
|
|
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
|
|
|
|
public LoginWindow(GameObject root,
|
|
|
|
|
|
UnityAction<String> PhoneNumberEdit,
|
|
|
|
|
|
UnityAction<String> CodeEdit,
|
|
|
|
|
|
UnityAction<bool> AgreementAccept,
|
|
|
|
|
|
UnityAction PhoneCodeLogin,
|
|
|
|
|
|
UnityAction SendPhoneRequest) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void SetLoginType(LoginType loginType)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void CheckLoginButton(LoginType loginType, bool isToggled)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (InputField_PhoneNumber.text.Length > 0 && InputField_VerifyCode.text.Length > 0 && isToggled)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Login.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Login.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void CheckPhoneCodeButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (InputField_PhoneNumber.text.Length == 11)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_GetVerifyCode.interactable = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_GetVerifyCode.interactable = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-13 12:30:13 +08:00
|
|
|
|
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;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
Button_GetVerifyCodeCooling.GetComponentInChildren<TMP_Text>().text = duration + "s";
|
|
|
|
|
|
await UniTask.WaitForSeconds(1);
|
|
|
|
|
|
duration--;
|
|
|
|
|
|
}
|
|
|
|
|
|
Button_GetVerifyCode.gameObject.SetActive(true);
|
|
|
|
|
|
Button_GetVerifyCodeCooling.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
2024-08-13 16:11:48 +08:00
|
|
|
|
|
2024-08-14 17:24:50 +08:00
|
|
|
|
protected void SetLinkText(Toggle agreement, TMP_Text text)
|
2024-08-13 16:11:48 +08:00
|
|
|
|
{
|
2024-08-14 17:24:50 +08:00
|
|
|
|
LinkText linkText = text.GetComponent<LinkText>();
|
|
|
|
|
|
|
2024-08-13 16:11:48 +08:00
|
|
|
|
if (linkText == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("LinkText is null");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
linkText.SetLinkAction(new System.Collections.Generic.List<UnityAction>()
|
|
|
|
|
|
{
|
2024-08-14 17:24:50 +08:00
|
|
|
|
() =>
|
2024-08-13 17:25:16 +08:00
|
|
|
|
{
|
|
|
|
|
|
Application.OpenURL("http://47.94.221.226:8989/user_agreement.txt");
|
|
|
|
|
|
//CallAction(Gameplay.Net.AppConfig.Instance.LoginURL + "agreements");
|
|
|
|
|
|
},
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Application.OpenURL("http://47.94.221.226:8989/privacy_agreement.txt");
|
|
|
|
|
|
//CallAction(Gameplay.Net.AppConfig.Instance.LoginURL + "agreements");
|
|
|
|
|
|
},
|
2024-08-15 15:13:46 +08:00
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Application.OpenURL("http://47.94.221.226:8989/children_privacy_agreement.txt");
|
|
|
|
|
|
//CallAction(Gameplay.Net.AppConfig.Instance.LoginURL + "agreements");
|
|
|
|
|
|
},
|
2024-08-13 16:11:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-08-14 17:24:50 +08:00
|
|
|
|
linkText.SetOtherAreaClicked(() => agreement.isOn = !agreement.isOn);
|
2024-08-13 16:11:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async void CallAction(string url)
|
|
|
|
|
|
{
|
|
|
|
|
|
var headData = PostHeader.PostHeaderInfo(new Dictionary<string, string>
|
2024-08-13 17:25:16 +08:00
|
|
|
|
{
|
|
|
|
|
|
{"timestamp", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() }
|
|
|
|
|
|
});
|
2024-08-13 16:11:48 +08:00
|
|
|
|
|
|
|
|
|
|
UnityWebRequest www = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST)
|
|
|
|
|
|
{
|
|
|
|
|
|
downloadHandler = new DownloadHandlerBuffer(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
www.SetRequestHeader("signature", headData["signature"]);
|
|
|
|
|
|
www.SetRequestHeader("timestamp", headData["timestamp"]);
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
await www.SendWebRequest();
|
|
|
|
|
|
if (www.result != UnityWebRequest.Result.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError(www.downloadHandler.text);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("http消息请求成功!\n返回内容:" + www.downloadHandler.text);
|
|
|
|
|
|
//WebRequestResult result = JsonConvert.DeserializeObject<WebRequestResult>(www.downloadHandler.text);
|
|
|
|
|
|
//if (result.code == 0)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// //send success msg
|
|
|
|
|
|
// DebugUtil.Log("短信验证码请求成功");
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// //send fail msg
|
|
|
|
|
|
// EventManager.Instance.Send(EventManager.EventName.PhoneCodeRequsetFail, "请求失败!" + result.message);
|
|
|
|
|
|
// DebugUtil.LogError("请求失败!" + result.message);
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (UnityWebRequestException e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError(e);
|
|
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.PhoneCodeRequsetFail, "请求失败!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 包含账户登录界面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
class DebugLoginWindow : LoginWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
public Button Button_AccountLogin;
|
|
|
|
|
|
public Button Button_VerifyCodeLogin;
|
|
|
|
|
|
|
|
|
|
|
|
public GameObject AccountLoginPanel;
|
|
|
|
|
|
public TMP_Dropdown ServerSelecter;
|
|
|
|
|
|
public Image Image_YellowLine_Account_1;
|
|
|
|
|
|
public Image Image_YellowLine_VerifyCode_1;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
public DebugLoginWindow(GameObject root, UnityAction<String> PhoneNumberEdit, UnityAction<String> CodeEdit, UnityAction<bool> AgreementAccept, UnityAction PhoneCodeLogin, UnityAction SendPhoneRequest)
|
|
|
|
|
|
: base(root, PhoneNumberEdit, CodeEdit, AgreementAccept, PhoneCodeLogin, SendPhoneRequest)
|
|
|
|
|
|
{
|
|
|
|
|
|
AccountLoginPanel = root.transform.Find("Image_LoginBg/LoginPanel/AccountLogin").gameObject;
|
|
|
|
|
|
VerifyCodeLoginPanel = root.transform.Find("Image_LoginBg/LoginPanel/VerifyCodeLogin").gameObject;
|
|
|
|
|
|
ServerSelecter = root.transform.Find("Image_LoginBg/ALDropdown").GetComponent<TMP_Dropdown>();
|
|
|
|
|
|
Button_AccountLogin = GetComponent<Button>("Image_LoginBg/LoginPanel/Top/AccountLogin/Button_AccountLogin_1");
|
|
|
|
|
|
Button_VerifyCodeLogin = GetComponent<Button>("Image_LoginBg/LoginPanel/Top/VerifyCodeLogin/Button_VerifyCodeLogin_1");
|
|
|
|
|
|
Toggle_Agreement = GetComponent<Toggle>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Mid/Info/Agreement/Toggle_Agreement_2");
|
|
|
|
|
|
Toggle_Agreement_Account = GetComponent<Toggle>("Image_LoginBg/LoginPanel/AccountLogin/Mid/Info/Agreement/Toggle_Agreement_1");
|
|
|
|
|
|
Image_YellowLine_Account_1 = GetComponent<Image>("Image_LoginBg/LoginPanel/Top/AccountLogin/Button_AccountLogin_1/Image_YellowLine_Account_1");
|
|
|
|
|
|
Image_YellowLine_VerifyCode_1 = GetComponent<Image>("Image_LoginBg/LoginPanel/Top/VerifyCodeLogin/Button_VerifyCodeLogin_1/Image_YellowLine_VerifyCode_1");
|
|
|
|
|
|
Toggle_RememberPassword = GetComponent<Toggle>("Image_LoginBg/LoginPanel/AccountLogin/Mid/Info/RememberPassword/Toggle_RememberPassword");
|
|
|
|
|
|
InputField_Account = GetComponent<TMP_InputField>("Image_LoginBg/LoginPanel/AccountLogin/Mid/Account/InputField_Account");
|
|
|
|
|
|
InputField_Password = GetComponent<TMP_InputField>("Image_LoginBg/LoginPanel/AccountLogin/Mid/Password/InputField_Password");
|
|
|
|
|
|
Button_Login_Account = GetComponent<Button>("Image_LoginBg/LoginPanel/AccountLogin/Bottom/Button_Login_1");
|
|
|
|
|
|
Button_Login = GetComponent<Button>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Bottom/Button_Login_2");
|
|
|
|
|
|
Button_GetVerifyCode = GetComponent<Button>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Mid/VerifyCode/Button_GetVerifyCode");
|
2024-08-13 12:30:13 +08:00
|
|
|
|
Button_GetVerifyCodeCooling = GetComponent<Button>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Mid/VerifyCode/Button_GetVerifyCodeCooling");
|
2024-08-09 12:55:51 +08:00
|
|
|
|
InputField_PhoneNumber = GetComponent<TMP_InputField>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Mid/Phone/InputField_PhoneNumber");
|
|
|
|
|
|
InputField_VerifyCode = GetComponent<TMP_InputField>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Mid/VerifyCode/InputField_VerifyCode");
|
2024-08-13 16:11:48 +08:00
|
|
|
|
Text_Agreement = GetComponent<TMP_Text>("Image_LoginBg/LoginPanel/VerifyCodeLogin/Mid/Info/Agreement/Text_Agreement_2");
|
2024-08-14 12:31:50 +08:00
|
|
|
|
Text_Agreement_Account = GetComponent<TMP_Text>("Image_LoginBg/LoginPanel/AccountLogin/Mid/Info/Agreement/Text_Agreement_1");
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
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 });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var index = PlayerPrefs.GetInt("ServerIndex", 1);
|
|
|
|
|
|
//serverIndex = index;
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
2024-08-14 17:24:50 +08:00
|
|
|
|
base.SetLinkText(Toggle_Agreement, Text_Agreement);
|
|
|
|
|
|
base.SetLinkText(Toggle_Agreement_Account, Text_Agreement_Account);
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetLoginType(LoginType loginType)
|
|
|
|
|
|
{
|
|
|
|
|
|
AccountLoginPanel.SetActive(loginType == LoginType.Account);
|
|
|
|
|
|
VerifyCodeLoginPanel.SetActive(loginType == LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void CheckLoginButton(LoginType loginType, bool isToggled)
|
|
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 正式界面,仅支持手机号登录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
class ReleaseLoginWindow : LoginWindow
|
|
|
|
|
|
{
|
2024-08-12 17:34:04 +08:00
|
|
|
|
public Button Button_debug;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
public ReleaseLoginWindow(GameObject root, UnityAction<String> PhoneNumberEdit, UnityAction<String> CodeEdit, UnityAction<bool> AgreementAccept, UnityAction PhoneCodeLogin, UnityAction SendPhoneRequest)
|
|
|
|
|
|
: base(root, PhoneNumberEdit, CodeEdit, AgreementAccept, PhoneCodeLogin, SendPhoneRequest)
|
|
|
|
|
|
{
|
|
|
|
|
|
VerifyCodeLoginPanel = root.transform.Find("Image_Bg/VerifyCodeLogin").gameObject;
|
|
|
|
|
|
|
|
|
|
|
|
InputField_PhoneNumber = GetComponent<TMP_InputField>("Image_Bg/VerifyCodeLogin/Mid/Phone/InputField_PhoneNumber");
|
|
|
|
|
|
InputField_VerifyCode = GetComponent<TMP_InputField>("Image_Bg/VerifyCodeLogin/Mid/VerifyCode/InputField_VerifyCode");
|
|
|
|
|
|
Button_Login = GetComponent<Button>("Image_Bg/VerifyCodeLogin/Bottom/Button_Login");
|
|
|
|
|
|
Button_GetVerifyCode = GetComponent<Button>("Image_Bg/VerifyCodeLogin/Mid/VerifyCode/Button_GetVerifyCode");
|
2024-08-13 12:30:13 +08:00
|
|
|
|
Button_GetVerifyCodeCooling = GetComponent<Button>("Image_Bg/VerifyCodeLogin/Mid/VerifyCode/Button_GetVerifyCodeCooling");
|
2024-08-09 12:55:51 +08:00
|
|
|
|
Toggle_Agreement = GetComponent<Toggle>("Image_Bg/VerifyCodeLogin/Mid/Info/Agreement/Toggle_Agreement");
|
2024-08-12 17:34:04 +08:00
|
|
|
|
Button_debug = GetComponent<Button>("Image_Bg/VerifyCodeLogin/Top/AccountLogin/Button_Debug");
|
2024-08-13 16:11:48 +08:00
|
|
|
|
Text_Agreement = GetComponent<TMP_Text>("Image_Bg/VerifyCodeLogin/Mid/Info/Agreement/Text_Agreement");
|
|
|
|
|
|
|
2024-08-12 17:34:04 +08:00
|
|
|
|
Button_debug.gameObject.SetActive(false);
|
2024-08-09 12:55:51 +08:00
|
|
|
|
|
|
|
|
|
|
InputField_PhoneNumber.onValueChanged.AddListener(PhoneNumberEdit);
|
|
|
|
|
|
InputField_VerifyCode.onValueChanged.AddListener(CodeEdit);
|
|
|
|
|
|
Toggle_Agreement.onValueChanged.AddListener(AgreementAccept);
|
|
|
|
|
|
Button_Login.onClick.AddListener(PhoneCodeLogin);
|
|
|
|
|
|
Button_GetVerifyCode.onClick.AddListener(SendPhoneRequest);
|
2024-08-14 17:24:50 +08:00
|
|
|
|
base.SetLinkText(Toggle_Agreement, Text_Agreement);
|
2024-08-09 12:55:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetLoginType(LoginType loginType)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
LoginWindow curShownWindow;
|
|
|
|
|
|
DebugLoginWindow debugLoginWindow;
|
|
|
|
|
|
ReleaseLoginWindow releaseLoginWindow;
|
|
|
|
|
|
|
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-07-30 19:07:27 +08:00
|
|
|
|
int serverIndex = 1;
|
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-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-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow = new(FindObj("UI_LoginWindow"), PhoneEdit, PhoneVerifyCodeEdit, OnAgreementAccept, OnPhoneCodeLoginClick, SendPhoneCodeRequest);
|
|
|
|
|
|
releaseLoginWindow = new(FindObj("UI_LoginWindowNew"), PhoneEdit, PhoneVerifyCodeEdit, OnAgreementAccept, OnPhoneCodeLoginClick, SendPhoneCodeRequest);
|
2024-08-14 12:31:50 +08:00
|
|
|
|
|
|
|
|
|
|
#if LOGIN_PHONE
|
|
|
|
|
|
|
|
|
|
|
|
//使用手机登录界面
|
2024-08-12 19:39:14 +08:00
|
|
|
|
if (Debug.isDebugBuild)
|
2024-08-12 17:34:04 +08:00
|
|
|
|
{
|
2024-08-13 12:17:37 +08:00
|
|
|
|
curShownWindow = releaseLoginWindow;//debugLoginWindow;//
|
2024-08-12 19:39:14 +08:00
|
|
|
|
releaseLoginWindow.Button_debug.gameObject.SetActive(true);
|
|
|
|
|
|
releaseLoginWindow.Button_debug.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow.IsScaleShow = false;
|
|
|
|
|
|
curShownWindow = debugLoginWindow;
|
|
|
|
|
|
curShownWindow.IsScaleShow = true;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownWindow = releaseLoginWindow;
|
|
|
|
|
|
}
|
2024-08-14 12:31:50 +08:00
|
|
|
|
#else
|
|
|
|
|
|
//使用账号登录界面
|
|
|
|
|
|
curShownWindow = debugLoginWindow;
|
2024-08-15 14:56:28 +08:00
|
|
|
|
if (Debug.isDebugBuild)//测试环境
|
2024-08-14 12:31:50 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (loginSaveData.LoginByPhone)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.Account);
|
|
|
|
|
|
}
|
2024-08-15 14:56:28 +08:00
|
|
|
|
if (loginSaveData.LoginByAccount && loginSaveData.rememberPassword && LoginController.Instance.AutoLogin)//保存有数据且为初次登录时尝试自动登录
|
2024-08-14 12:31:50 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("已有账号密码,自动登录");
|
|
|
|
|
|
LoginAction();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2024-08-09 12:55:51 +08:00
|
|
|
|
curShownWindow.IsScaleShow = true;
|
2024-07-17 15:29:10 +08:00
|
|
|
|
|
2024-08-12 19:39:14 +08:00
|
|
|
|
if (Debug.isDebugBuild)
|
2024-08-09 12:55:51 +08:00
|
|
|
|
{
|
2024-08-12 19:39:14 +08:00
|
|
|
|
var index = PlayerPrefs.GetInt("ServerIndex", 1);
|
2024-08-09 12:55:51 +08:00
|
|
|
|
serverIndex = index;
|
2024-08-12 19:39:14 +08:00
|
|
|
|
AppConfig.Instance.Select(index);
|
|
|
|
|
|
|
|
|
|
|
|
debugLoginWindow.ServerSelecter.gameObject.SetActive(true);
|
|
|
|
|
|
debugLoginWindow.ServerSelecter.onValueChanged.AddListener((int index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("选择服务器:" + index);
|
|
|
|
|
|
AppConfig.Instance.Select(index);
|
|
|
|
|
|
serverIndex = index;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-07-17 15:29:10 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
BindButton(Button_AccountLogin_1, () => SetLoginType(LoginType.Account));
|
2024-07-15 12:20:03 +08:00
|
|
|
|
BindButton(Button_VerifyCodeLogin_1, () => SetLoginType(LoginType.PhoneCode));
|
|
|
|
|
|
BindButton(Button_Login_1, OnButtonLogin);
|
2024-07-24 19:24:11 +08:00
|
|
|
|
BindButton(Button_UserCenter, OnCancelCurConnect);
|
2024-07-16 13:11:18 +08:00
|
|
|
|
BindButton(Button_Notice, OnNoticeClick);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
|
|
|
|
|
BindButton(Button_StartGame, OnStartGame);
|
|
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.Toggle_RememberPassword.onValueChanged.AddListener(OnRememberPassword);
|
|
|
|
|
|
debugLoginWindow.InputField_Account.onValueChanged.AddListener(AccountEdit);
|
|
|
|
|
|
debugLoginWindow.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-07-17 15:29:10 +08:00
|
|
|
|
Text_UID.gameObject.SetActive(false);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-19 15:38:01 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.RealNameVerifyCancel, OnCancelCurConnect);
|
2024-07-17 15:29:10 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LoginComplete, OnLoginOK);
|
2024-08-15 12:51:51 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.LoginOut, OnLogoutComplete);
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//EventManager.Instance.Register(Framework.EventManager.EventName.NetError, OnCancelCurConnect);
|
2024-08-07 15:45:10 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.PhoneCodeLoginSuc, OnPhoneCodeLoginSuc);
|
|
|
|
|
|
EventManager.Instance.Register<string>(EventManager.EventName.PhoneCodeLoginFail, OnPhoneCodeLoginFailed);
|
|
|
|
|
|
EventManager.Instance.Register<string>(EventManager.EventName.PhoneCodeRequsetFail, OnPhoneCodeRequestFailed);
|
2024-08-14 12:31:50 +08:00
|
|
|
|
|
2024-08-12 17:34:04 +08:00
|
|
|
|
//if (loginSaveData.LoginByPhone)//手机号Token自动登录
|
|
|
|
|
|
//{
|
|
|
|
|
|
// PhoneVerifyTool.Instance.RefreshToken = loginSaveData.AuthCode;
|
2024-08-15 12:51:51 +08:00
|
|
|
|
// PhoneVerifyTool.Instance.AccessTokenCode = string.Empty;
|
|
|
|
|
|
// PhoneVerifyTool.Instance.RefreshTokenRequest();
|
|
|
|
|
|
//
|
|
|
|
|
|
// //Actor.Instance.StartLogin(NLDPB.LoginType.Phxhphone, loginSaveData.phoneNumber);
|
2024-08-12 17:34:04 +08:00
|
|
|
|
//}
|
|
|
|
|
|
}
|
2024-07-12 14:23:06 +08:00
|
|
|
|
|
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://账号密码登录
|
|
|
|
|
|
|
|
|
|
|
|
debugLoginWindow.Image_YellowLine_Account_1.gameObject.SetActive(true);
|
|
|
|
|
|
debugLoginWindow.Image_YellowLine_VerifyCode_1.gameObject.SetActive(false);
|
|
|
|
|
|
debugLoginWindow.Toggle_RememberPassword.isOn = loginSaveData.rememberPassword;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.Toggle_Agreement_Account.isOn = loginSaveData.agreement;
|
|
|
|
|
|
debugLoginWindow.VerifyCodeLoginPanel.SetActive(false);
|
|
|
|
|
|
debugLoginWindow.AccountLoginPanel.SetActive(true);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
|
|
|
|
|
if (loginSaveData.account != default)
|
|
|
|
|
|
{
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.InputField_Account.text = loginSaveData.account;
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (loginSaveData.password != default && loginSaveData.rememberPassword)
|
|
|
|
|
|
{
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.InputField_Password.text = loginSaveData.password;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
debugLoginWindow.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
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.Image_YellowLine_Account_1.gameObject.SetActive(false);
|
|
|
|
|
|
debugLoginWindow.Image_YellowLine_VerifyCode_1.gameObject.SetActive(true);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.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-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-07-12 14:23:06 +08:00
|
|
|
|
{
|
2024-08-09 12:55:51 +08:00
|
|
|
|
//Image_LoginBg.gameObject.SetActive(false);
|
|
|
|
|
|
curShownWindow.IsScaleShow = false;
|
2024-07-16 13:11:18 +08:00
|
|
|
|
|
|
|
|
|
|
Button_StartGame.gameObject.SetActive(true);
|
|
|
|
|
|
Button_Notice.gameObject.SetActive(true);
|
|
|
|
|
|
Button_UserCenter.gameObject.SetActive(true);
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-07-12 14:23:06 +08:00
|
|
|
|
|
|
|
|
|
|
//invoke when destroy
|
|
|
|
|
|
public override void OnRelease()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnRelease();
|
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);
|
|
|
|
|
|
//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;
|
2024-08-09 12:55:51 +08:00
|
|
|
|
debugLoginWindow.InputField_Password.text = string.Empty;
|
|
|
|
|
|
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-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-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-07-30 19:07:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 请求发送验证码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void SendPhoneCodeRequest()
|
|
|
|
|
|
{
|
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;
|
|
|
|
|
|
curShownWindow.CoolingTimer().Forget();
|
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
|
|
|
|
|
|
|
|
|
|
Actor.Instance.StartLogin(NLDPB.LoginType.Phxhphone, loginSaveData.phoneNumber);
|
2024-07-30 19:07:27 +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>
|
|
|
|
|
|
void LoginAction()
|
|
|
|
|
|
{
|
2024-07-17 15:29:10 +08:00
|
|
|
|
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
|
|
|
|
|
PlayerPrefs.SetInt("ServerIndex", serverIndex);
|
|
|
|
|
|
#else
|
2024-07-16 15:24:41 +08:00
|
|
|
|
DebugUtil.Log("尝试登录测试服,在此处修改登录逻辑,连接超时以及登录失败请后续补充");
|
2024-07-15 16:08:28 +08:00
|
|
|
|
var serverInfos = AppConfig.Instance.GetServerInfo();
|
2024-07-16 15:24:41 +08:00
|
|
|
|
AppConfig.Instance.Select(1);
|
2024-07-15 16:08:28 +08:00
|
|
|
|
for (int i = 0; i < serverInfos.Count; i++)
|
|
|
|
|
|
{
|
2024-07-16 15:24:41 +08:00
|
|
|
|
if (serverInfos[i].name == "测试服1")
|
2024-07-30 19:07:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
AppConfig.Instance.Select(i);
|
|
|
|
|
|
DebugUtil.Log("登录测试服");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-07-15 16:08:28 +08:00
|
|
|
|
}
|
2024-07-17 15:29:10 +08:00
|
|
|
|
#endif
|
2024-07-15 16:08:28 +08:00
|
|
|
|
Gameplay.Net.Actor.Instance.StartLogin(NLDPB.LoginType.Phxh, loginSaveData.account);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnLoginOK()
|
|
|
|
|
|
{
|
2024-08-15 12:51:51 +08:00
|
|
|
|
//loginOK = true;
|
2024-07-24 19:24:11 +08:00
|
|
|
|
HideLoginPanel();
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-07-24 19:24:11 +08:00
|
|
|
|
loginSaveData = StorageMgr.Instance.GetStorage<LoginData>("LoginData");
|
|
|
|
|
|
if (loginSaveData == null)
|
|
|
|
|
|
loginSaveData = new();
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-07-15 17:07:49 +08:00
|
|
|
|
if (tempSaveData != null)
|
|
|
|
|
|
loginSaveData.SetData(tempSaveData);
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
|
|
|
|
|
loginSaveData.LoginByAccount = true;
|
2024-07-24 19:24:11 +08:00
|
|
|
|
StorageMgr.Instance.SyncForce = true;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
2024-07-24 19:24:11 +08:00
|
|
|
|
Text_UID.gameObject.SetActive(true);
|
|
|
|
|
|
Text_UID.text = "UID: " + Actor.Instance.Base.GetProp(ActorProp.ActorId);
|
|
|
|
|
|
|
2024-07-25 12:18:07 +08:00
|
|
|
|
//return;
|
2024-07-24 19:24:11 +08:00
|
|
|
|
var adultStatus = (int)Actor.Instance.Logic.GetCount((uint)LogicID.AdultAuthStatus);
|
|
|
|
|
|
if (adultStatus == (int)AAStatus.AasNone)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("未实名认证");
|
2024-07-25 13:29:16 +08:00
|
|
|
|
//UI_RealNameIdentifyController.Open().Forget();
|
|
|
|
|
|
UI_NoticeWindowController.Open().Forget();
|
2024-07-24 19:24:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-15 12:51:51 +08:00
|
|
|
|
void OnLogoutComplete()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (loginSaveData.LoginByPhone)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetLoginType(LoginType.Account);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-15 16:08:28 +08:00
|
|
|
|
|
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;
|
|
|
|
|
|
debugLoginWindow.isTimer = false;
|
|
|
|
|
|
releaseLoginWindow.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-08-09 14:30:52 +08:00
|
|
|
|
tempSaveData.AuthCode = PhoneVerifyTool.Instance.RefreshToken;//HttpReturnCode;
|
|
|
|
|
|
tempSaveData.AuthCodeUpdateTime = PhoneVerifyTool.Instance.RefreshTokenTime;
|
2024-08-12 17:34:04 +08:00
|
|
|
|
tempSaveData.ClearAccountLoginData();
|
|
|
|
|
|
tempSaveData.LoginByPhone = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogWarning("暂存登录数据为空!");
|
2024-08-07 15:45:10 +08:00
|
|
|
|
}
|
2024-08-09 14:30:52 +08:00
|
|
|
|
loginSaveData.AuthCode = PhoneVerifyTool.Instance.RefreshToken;//HttpReturnCode;
|
|
|
|
|
|
loginSaveData.AuthCodeUpdateTime = PhoneVerifyTool.Instance.RefreshTokenTime;
|
|
|
|
|
|
|
2024-08-07 15:45:10 +08:00
|
|
|
|
DebugUtil.Log("验证码登录成功!保存登录凭证:" + loginSaveData.AuthCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
void OnPhoneCodeLoginFailed(string errorMsg)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ShowMessageTips(errorMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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-24 19:24:11 +08:00
|
|
|
|
void OnCancelCurConnect()
|
2024-07-15 12:20:03 +08:00
|
|
|
|
{
|
2024-08-15 12:51:51 +08:00
|
|
|
|
if (LoginController.Instance.IsLogin)//TODO 点开用户中心退出原先账号是否需要断开连接
|
2024-07-15 18:59:46 +08:00
|
|
|
|
{
|
2024-07-16 15:24:41 +08:00
|
|
|
|
DebugUtil.Log("登出!断开连接");
|
2024-07-15 16:08:28 +08:00
|
|
|
|
Actor.Instance.OnLogout();
|
2024-08-15 12:51:51 +08:00
|
|
|
|
//NetManager.Instance.CloseClient();
|
|
|
|
|
|
//loginOK = false;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
}
|
2024-08-15 12:51:51 +08:00
|
|
|
|
//if (loginSaveData.LoginByPhone)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// SetLoginType(LoginType.PhoneCode);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// SetLoginType(LoginType.Account);
|
|
|
|
|
|
//}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-16 13:11:18 +08:00
|
|
|
|
async void OnNoticeClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
await UI_NoticeController.Open();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-15 12:20:03 +08:00
|
|
|
|
void OnStartGame()
|
|
|
|
|
|
{
|
2024-07-15 16:08:28 +08:00
|
|
|
|
Actor.Instance.OnEnterGame();
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-12 17:34:04 +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-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-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-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;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void ClearAccountLoginData()
|
|
|
|
|
|
{
|
|
|
|
|
|
LoginByAccount = false;
|
|
|
|
|
|
account = string.Empty;
|
|
|
|
|
|
password = string.Empty;
|
|
|
|
|
|
rememberPassword = false;
|
2024-07-15 16:08:28 +08:00
|
|
|
|
}
|
2024-07-15 12:20:03 +08:00
|
|
|
|
}
|
2024-07-12 14:23:06 +08:00
|
|
|
|
}
|
2024-08-15 12:51:51 +08:00
|
|
|
|
|
|
|
|
|
|
public class LoginController : Singlenton<LoginController>
|
|
|
|
|
|
{
|
|
|
|
|
|
bool autoLogin = true;//第一次尝试自动登录
|
|
|
|
|
|
public bool AutoLogin
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return autoLogin; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool isLogin = false;
|
|
|
|
|
|
public bool IsLogin
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return isLogin; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LoginController()
|
|
|
|
|
|
{
|
|
|
|
|
|
autoLogin = true;
|
|
|
|
|
|
isLogin = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnLogout()
|
|
|
|
|
|
{
|
|
|
|
|
|
autoLogin = false;
|
|
|
|
|
|
isLogin = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnLoginOK()
|
|
|
|
|
|
{
|
|
|
|
|
|
autoLogin = false;
|
|
|
|
|
|
isLogin = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|