123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- using LitJson;
- using SC.XR.Unity;
- using ShadowStudio.Mgr;
- using Studio.Scripts.HttpMessage;
- using Studio.WebSocket.Message;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using XRTool.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- namespace ShadowStudio.UI
- {
- [RequireComponent(typeof(WorldDlg))]
-
-
-
- public class LoginDlg : UnitySingleton<LoginDlg>
- {
- private string session;
- private SCInputField userInputField;
- private SCInputField passwordInputField;
- private Button loginBtn;
- private Button setBtn;
- private Toggle remberToggle;
- private GameObject verifyObj;
- private SCInputField verifyInputField;
- private RawImage verifyTexture;
- private Button verifyTextureBtn;
-
- private Text userRemind;
- private Text passwordRemind;
- private Text vcodeRemind;
- private Button phoneNumLoginBtn;
- private Button SNLoginBtn;
- WorldDlg dlg;
- private void Start()
- {
- CommonMethod.IsReceive = false;
- dlg = GetComponent<WorldDlg>();
- userInputField = dlg.GetChild<SCInputField>("UIRoot/UserInputField");
-
- passwordInputField = dlg.GetChild<SCInputField>("UIRoot/PasswordInputField");
- loginBtn = dlg.GetChild<Button>("FullUIRoot/LoginBtn");
- setBtn = dlg.GetChild<Button>("UIRoot/SetBtn");
- remberToggle = dlg.GetChild<Toggle>("UIRoot/RemberToggle_CheckBox");
- remberToggle.isOn = LoginProxy.Instance.IsRemberUserAndPass; ;
- remberToggle.onValueChanged.AddListener(ClickOnToggle);
- verifyObj = dlg.GetChild<Transform>("UIRoot/VerifyObj").gameObject;
- verifyInputField = dlg.GetChild<SCInputField>("UIRoot/VerifyObj/VerifyInputField");
- verifyTexture = dlg.GetChild<RawImage>("UIRoot/VerifyObj/VerifyTexture");
- verifyTextureBtn = dlg.GetBreadthChild<Button>("VerifyTextureBtn");
- verifyTextureBtn.onClick.AddListener(OnClickChangeTex);
- if (LoginMgr.Instance.UserInfo != null && LoginProxy.Instance.IsRemberUserAndPass && !string.IsNullOrEmpty(LoginMgr.Instance.UserInfo.UserID) && LoginMgr.Instance.UserInfo.UserID != "null")
- {
- userInputField.text = LoginMgr.Instance.UserInfo.UserID;
- passwordInputField.text = LoginMgr.Instance.UserInfo.Password;
- }
- else
- {
- userInputField.text = "";
- passwordInputField.text = "";
- }
- loginBtn.onClick.AddListener(OnClickLogin);
- setBtn.onClick.AddListener(OnClickSet);
- userInputField.onEndEdit.AddListener(InputUserEnd);
- userInputField.onValueChanged.AddListener(UserValueChanged);
- passwordInputField.onEndEdit.AddListener(InputPassEnd);
- passwordInputField.onValueChanged.AddListener(PassValueChanged);
- verifyInputField.onEndEdit.AddListener(InputVerifyEnd);
- verifyInputField.onValueChanged.AddListener(VerifyValueChanged);
- userRemind = dlg.GetChild<Text>("UIRoot/ErrorRemind/UserRemind");
- passwordRemind = dlg.GetChild<Text>("UIRoot/ErrorRemind/PasswordRemind");
- vcodeRemind = dlg.GetChild<Text>("UIRoot/VerifyObj/VcodeRemind");
- phoneNumLoginBtn = dlg.GetChild<Button>("UIRoot/PhoneNumLoginBtn");
- SNLoginBtn = dlg.GetChild<Button>("UIRoot/SNLoginBtn");
- phoneNumLoginBtn.onClick.AddListener(OnClickPhoneLogin);
- SNLoginBtn.onClick.AddListener(OnClickSNLogin);
- Debug.Log("startOnInit。。。");
- WSHandler.User.OnInit -= onInit;
- WSHandler.User.OnInit += onInit;
- if(CommonMethod.isZiDong)
- Invoke("loginzidong",1f);
-
- LoginProxy.Instance.AccountLoginAction += AccountLoginHandler;
- LoginProxy.Instance.SNLoginAction += SNLoginHandler;
- LoginProxy.Instance.LoginErrorAction += LoginErrorHandler;
- LoginProxy.Instance.CaptchaCodeAction += CaptchaCodeHandler;
- }
- void loginzidong()
- {
-
- LoginProxy.Instance.RequestAccountPasswordLogin("15821993590", "123qweqwe");
- }
- public void clearUserF()
- {
- userInputField.text = "";
- }
- public void clearPassWord()
- {
- passwordInputField.text = "";
- }
- private void OnClickChangeTex()
- {
- LoginProxy.Instance.RequestCaptchaVerificationCode();
- }
- private void UserValueChanged(string user)
- {
- userRemind.gameObject.SetActive(false);
- }
- private void InputUserEnd(string user)
- {
- if (user == "")
- {
- userRemind.gameObject.SetActive(true);
- userRemind.text = LanguageMgr.Instance.GetMessage("1011").Message;
- }
-
-
-
-
-
-
-
-
-
-
-
- }
- private void PassValueChanged(string password)
- {
- passwordRemind.gameObject.SetActive(false);
- }
- private void InputPassEnd(string password)
- {
- if (password == "")
- {
- passwordRemind.gameObject.SetActive(true);
- passwordRemind.text = LanguageMgr.Instance.GetMessage("1013").Message;
- }
- else
- {
- if (password.Contains(" "))
- {
- passwordRemind.gameObject.SetActive(true);
- passwordRemind.text = LanguageMgr.Instance.GetMessage("1014").Message;
- }
- }
- }
- private void VerifyValueChanged(string verifyNum)
- {
- vcodeRemind.gameObject.SetActive(false);
- }
- private void InputVerifyEnd(string verifyNum)
- {
- if (verifyNum == "")
- {
- vcodeRemind.gameObject.SetActive(true);
- vcodeRemind.text = LanguageMgr.Instance.GetMessage("1015").Message;
- }
- }
- private void ClickOnToggle(bool ison)
- {
- LoginProxy.Instance.RemberUserAndPass(ison);
- }
- private void OnClickLogin()
- {
-
-
- userInputField.text = "ycst0008";
- passwordInputField.text = "yc123456";
- if (userInputField.text == "" || passwordInputField.text == "")
- {
- if (userInputField.text == "")
- {
- userRemind.gameObject.SetActive(true);
- userRemind.text = LanguageMgr.Instance.GetMessage("1011").Message;
- }
- else if (passwordInputField.text == "")
- {
- passwordRemind.gameObject.SetActive(true);
- passwordRemind.text = LanguageMgr.Instance.GetMessage("1013").Message;
- }
- }
-
-
-
-
- else
- {
- if (!verifyObj.activeSelf)
- {
- loginBtn.enabled = false;
- Invoke("ReLoginBtn", 1f);
- LoginProxy.Instance.RequestAccountPasswordLogin(userInputField.text, passwordInputField.text);
- }
- else
- {
- if (verifyInputField.text != "")
- {
- loginBtn.enabled = false;
- Invoke("ReLoginBtn", 1f);
- LoginProxy.Instance.RequestAccountPasswordLogin(userInputField.text, passwordInputField.text, verifyInputField.text);
- }
- else
- {
- vcodeRemind.gameObject.SetActive(true);
- vcodeRemind.text = LanguageMgr.Instance.GetMessage("1015").Message;
- }
- }
- }
- }
- private void ReLoginBtn()
- {
- loginBtn.enabled = true;
- }
- public void ClickBreakLoginBtn()
- {
-
-
- if (!string.IsNullOrEmpty(CommonMethod.tempToken))
- {
- LoginProxy.Instance.RequestBreakLogin(CommonMethod.tempToken);
- CommonMethod.tempToken = "";
- }
- }
- private void onWebErrorClose(string data)
- {
- CommonMethod.ShowTextTusi();
- if (TuSi.Instance)
- {
- TuSi.Instance.ShowTextContent("大厅链接失败,请重新尝试!");
- }
- WSHandler._client.CloseWebSocket();
- }
- private void onInit(ConnectNotificationMessage message)
- {
- dlg.hideDlg(() => {
- CommonMethod.selfHomepeerId = message.data.peerId;
- if (UserInfoMgr.Instance.userConfig.Login_type == "3")
- {
- LoginViewMgr.Instance.LoadSence();
- }
- else
- {
- if (UserInfoMgr.Instance.userConfig.Nick_name == "" || UserInfoMgr.Instance.userConfig.Avatar == "")
- {
- LoginViewMgr.Instance.ShowView(LoginViewMgr.USERINITSETDLG);
- }
- else
- {
- LoginViewMgr.Instance.LoadSence();
- }
- }
- });
- }
-
-
-
- void chongfudenglu()
- {
- ClickBreakLoginBtn();
- }
- private void GetSucess(Texture tex)
- {
- verifyTexture.texture = tex;
- }
- private void OnClickSet()
- {
- LoginViewMgr.Instance.ShowView(LoginViewMgr.SYSTEMSETDLG);
- }
- private void OnClickPhoneLogin()
- {
- LoginViewMgr.Instance.ShowView(LoginViewMgr.VERIFYLOGINDLG);
- }
-
- private void OnClickSNLogin()
- {
- SNLoginBtn.enabled = false;
- Invoke("ReSNLoginBtn", 1f);
- LoginProxy.Instance.RequestSNLogin();
- }
- private void ReSNLoginBtn()
- {
- SNLoginBtn.enabled = true;
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- if (LoginProxy.Instance)
- {
- LoginProxy.Instance.AccountLoginAction -= AccountLoginHandler;
- LoginProxy.Instance.SNLoginAction -= SNLoginHandler;
- LoginProxy.Instance.LoginErrorAction -= LoginErrorHandler;
- LoginProxy.Instance.CaptchaCodeAction -= CaptchaCodeHandler;
- }
- WSHandler.User.OnInit -= onInit;
- }
-
-
-
-
-
-
- private void CaptchaCodeHandler(string captchaID, string bs64)
- {
- verifyTexture.texture = UnityUtil.Base642Tex2d(bs64);
- }
- private void LoginErrorHandler(MessageType messageType, int code, string codeMessage)
- {
- if (messageType == MessageType.AccountLoginType)
- {
- switch (code.ToString())
- {
- case "6006":
- CommonMethod.ShowLoginAbnormalPop();
- if (CommonMethod.isZiDong)
- Invoke("chongfudenglu", 2f);
- break;
- case "9002":
- CommonMethod.ShowTextTusi();
- TuSi.Instance.ShowTextContent("服务器异常,请稍后重试");
- if (LoginProxy.Instance.LoginNum > 5)
- {
- this.verifyObj.SetActive(true);
- LoginProxy.Instance.RequestCaptchaVerificationCode();
- }
- break;
- case "5010":
- passwordRemind.gameObject.SetActive(true);
- passwordRemind.text = "账号和密码不匹配";
- if (LoginProxy.Instance.LoginNum > 5)
- {
- this.verifyObj.SetActive(true);
- LoginProxy.Instance.RequestCaptchaVerificationCode();
- }
- break;
- case "5006":
- vcodeRemind.gameObject.SetActive(true);
- vcodeRemind.text = "验证码输入错误";
- this.verifyObj.SetActive(true);
- LoginProxy.Instance.RequestCaptchaVerificationCode();
- break;
- case "6004":
- vcodeRemind.gameObject.SetActive(true);
- vcodeRemind.text = "请输入右侧验证码";
- this.verifyObj.SetActive(true);
- LoginProxy.Instance.RequestCaptchaVerificationCode();
- break;
- case "5070":
- vcodeRemind.gameObject.SetActive(true);
- vcodeRemind.text = "验证码输入错误";
- this.verifyObj.SetActive(true);
- LoginProxy.Instance.RequestCaptchaVerificationCode();
- break;
- default:
- CommonMethod.ShowTextTusi();
- TuSi.Instance.ShowTextContent(codeMessage);
- break;
- }
- }
- }
- private void SNLoginHandler()
- {
- dlg.hideDlg();
- }
- private void AccountLoginHandler()
- {
- verifyObj.SetActive(false);
- if (!LoginProxy.Instance.IsRemberUserAndPass)
- {
- userInputField.text = string.Empty;
- passwordInputField.text = string.Empty;
- }
- }
- }
- }
|