123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using LitJson;
- using Newtonsoft.Json.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- public class LoginManager : MonoSingleton<LoginManager>
- {
-
- [HideInInspector]
- public GameObject bigLoginItem;
- [HideInInspector]
- public GameObject smallLoginItem;
- public GameObject itemRoot;
- [HideInInspector]
- public List<GameObject> biglistItem = new List<GameObject>();
- [HideInInspector]
- public List<GameObject> smalllistItem = new List<GameObject>();
-
- [HideInInspector]
- public GameObject bigOftenUseLoginItem;
- [HideInInspector]
- public List<GameObject> OftenUsesmalllistItem = new List<GameObject>();
- [HideInInspector]
- public List<GameObject> OftenUsebiglistItem = new List<GameObject>();
- public GameObject OftenUseitemRoot;
- private void Start()
- {
- bigLoginItem = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.Login,"bigLoginItem");
- smallLoginItem = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.Login, "smallLoginItem");
- bigOftenUseLoginItem = WindowsManager.Instance.GetPrefab(WindowConfig.windowType.Login, "bigOftenUseLoginItem");
- Instance.removeAll();
- Instance.InitPlayer();
- Instance.initOftenUse();
- }
- public void ExitUser()
- {
- removeAll();
- InitPlayer();
- initOftenUse();
- }
- public void GotoLogin()
- {
- if(isTongxun)
- {
- return;
- }
- if (UserManager.Instance.NowChoose != null)
- {
- if (LoginPassWordManager.Instance.tmpField.text.Length > 4)
- {
-
-
-
-
-
-
-
-
- JsonData data = new JsonData();
- if (WindowsManager.Instance.isTest)
- {
- data["account"] = "dgj2";
- data["password"] = "00000000";
- }
- else
- {
- data["account"] = UserManager.Instance.NowChoose.number;
- data["password"] = LoginPassWordManager.Instance.tmpField.text;
- }
- Debug.Log("DGJ ==> Login " + data.ToJson());
- HttpTool.Instance.PostLogin(HttpEdustryAction.Login, data.ToJson(), LogingCallBack);
- }
- else
- {
- LoginPassWordManager.Instance.toError();
- }
- }
- else
- {
- WindowsManager.Instance.show(WindowConfig.windowType.Tip2, false, "请选择账号");
- }
- }
- public void initOftenUse()
- {
-
- LoginDataManager.Instance.GetOftenUseLoginData((List<AccountData> adata) => {
- GameObject smallitem;
- GameObject bigitem;
-
- bigitem = GameObject.Instantiate(bigOftenUseLoginItem, OftenUseitemRoot.transform);
- OftenUsebiglistItem.Add(bigitem);
-
- for (int j = 3; j >=0; j--)
- {
- if(adata.Count>j)
- {
- smallitem = GameObject.Instantiate(smallLoginItem, bigitem.transform);
- SmallLoginItem slitem = smallitem.GetComponent<SmallLoginItem>();
- slitem.setData(adata[j],false);
- OftenUsebiglistItem.Add(smallitem);
- }
- else
- {
- break;
- }
- }
- });
- }
- public void InitPlayer()
- {
- LoginDataManager.Instance.GetLoginData((List<AccountData> adata) => {
- GameObject smallitem;
- GameObject bigitem;
-
- for (int i = 0; i < (adata.Count / 10 + 1); i++)
- {
- bigitem = GameObject.Instantiate(bigLoginItem, itemRoot.transform);
- biglistItem.Add(bigitem);
-
- int max = i * 10;
- for (int j = max; j < max + 10; j++)
- {
- if (adata.Count > j)
- {
- smallitem = GameObject.Instantiate(smallLoginItem, bigitem.transform);
- SmallLoginItem slitem = smallitem.GetComponent<SmallLoginItem>();
- slitem.setData(adata[j],true);
- smalllistItem.Add(smallitem);
- }
- else
- {
- break;
- }
- }
- }
- });
- }
- public void testOk()
- {
- isTongxun = false;
- ShowInfoTipManager.Instance.closeTip();
- WindowsManager.Instance.show(WindowConfig.windowType.ProjectMain);
- WindowsManager.Instance.show(WindowConfig.windowType.Top, false);
- }
- bool isTongxun;
- public void LogingCallBack(string msg)
- {
- Debug.Log(msg);
- JObject obj = JObject.Parse(msg);
- if (obj["code"].ToString() == "200")
- {
- string token = obj["data"]["token"].ToString();
- login.UserInfo.Instance.Token = token;
- HttpEdustryAction.Token = token;
- TimerMgr.Instance.CreateTimer(() => { testOk(); }, 1f);
- isTongxun = true;
- ShowInfoTipManager.Instance.showTip("正在登录,请稍后");
- }
- else
- {
- WindowsManager.Instance.show(WindowConfig.windowType.Tip2, false, obj["code"].ToString());
- }
- }
- public void RTCTestLoginCallBack(string msg)
- {
- isTongxun = false;
- ShowInfoTipManager.Instance.closeTip();
- Debug.Log(msg);
- JObject obj = JObject.Parse(msg);
- if (obj["code"].ToString() == "200")
- {
- string token = obj["data"]["token"].ToString();
- login.UserInfo.Instance.Token = token;
- WindowsManager.Instance.show(WindowConfig.windowType.ProjectMain);
- WindowsManager.Instance.show(WindowConfig.windowType.Top, false);
- }
- else
- {
- WindowsManager.Instance.show(WindowConfig.windowType.Tip2, false, obj["code"].ToString());
- }
- }
- public void removeAll()
- {
-
- for (int i = 0; i < biglistItem.Count; i++)
- {
- Destroy(biglistItem[i]);
- }
- for (int i = 0; i < OftenUsebiglistItem.Count; i++)
- {
- Destroy(OftenUsebiglistItem[i]);
- }
- smalllistItem.Clear();
- biglistItem.Clear();
- OftenUsebiglistItem.Clear();
- OftenUsesmalllistItem.Clear();
- }
- }
|