using Cysharp.Threading.Tasks; using Framework; using Gameplay; using Gameplay.Net; using NLDPB; using PhxhSDK; using System; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using Button = UnityEngine.UI.Button; using Image = UnityEngine.UI.Image; using Toggle = UnityEngine.UI.Toggle; public class UI_StartGameInterfaceController : UIWindow { enum LoginType { Account, PhoneCode } #region UI_obj //UI GameObj ///Auto Gen Start/// public Image Image_Bg; public Image Image_BgDark; public Button Button_StartGame; public Image Image_LoginBg; public Button Button_AccountLogin_1; //public Image Image_YellowLine_Account_1; public Button Button_VerifyCodeLogin_1; //public Image Image_YellowLine_VerifyCode_1; //public TMP_InputField InputField_Account; public Image Image_AccountIcon; //public TMP_InputField InputField_Password; public Image Image_PasswordIcon; //public Toggle Toggle_RememberPassword; public TMP_Text Text_RememberPassword; public Toggle Toggle_Agreement_1; public TMP_Text Text_Agreement_1; public Button Button_UnLogin_1; public Button Button_Login_1; //public TMP_InputField InputField_PhoneNumber; public Image Image_PhoneIcon; //public TMP_InputField InputField_VerifyCode; public Image Image_VerifyCodeIcon; public Button Button_GetVerifyCode; public Button Button_GetVerifyCodeCooling; public Toggle Toggle_Agreement_2; public TMP_Text Text_Agreement_2; public Button Button_UnLogin_2; public Button Button_Login_2; 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; ///Auto Gen End/// #endregion #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; public Button Button_GetVerifyCodeCooling; public TMP_Text Text_Agreement; public bool isTimer; public Button Button_Login; public LoginWindow(GameObject root, UnityAction PhoneNumberEdit, UnityAction CodeEdit, UnityAction 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; } } 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().text = duration + "s"; await UniTask.WaitForSeconds(1); duration--; } Button_GetVerifyCode.gameObject.SetActive(true); Button_GetVerifyCodeCooling.gameObject.SetActive(false); } protected void SetLinkText() { LinkText linkText = Text_Agreement.GetComponent(); if (linkText == null) { DebugUtil.Log("LinkText is null"); } else { linkText.SetLinkAction(new System.Collections.Generic.List() { () => { 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"); }, }); } } async void CallAction(string url) { var headData = PostHeader.PostHeaderInfo(new Dictionary { {"timestamp", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() } }); 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(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); //} //callback?.Invoke(result.code, result.message); } } catch (UnityWebRequestException e) { DebugUtil.LogError(e); EventManager.Instance.Send(EventManager.EventName.PhoneCodeRequsetFail, "请求失败!"); //callback?.Invoke(-1, e.Message); } } } /// /// 包含账户登录界面 /// 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; public Button Button_Login_Account; public Toggle Toggle_Agreement_Account; public DebugLoginWindow(GameObject root, UnityAction PhoneNumberEdit, UnityAction CodeEdit, UnityAction 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(); Button_AccountLogin = GetComponent