123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using rtc;
- using SC.XR.Unity;
- using System;
- using System.Text;
- using TMPro;
- using UnityEngine;
- using UnityEngine.UI;
- using static ScenesManager;
- using static ShowLogin;
- public class UserSystem : RemoteSingleton<UserSystem>
- {
- public RawImage texIcon;
- public TextMeshProUGUI userSNName;
- public SCInputField userName;
- public TextMeshProUGUI userAccount;
- public TextMeshProUGUI accountManager;
- public GameObject AvatarListPop;
- // public SCInputField inputName;
- public static Action<Texture> swithAvatarAction;
- public AvatarList avatarList;
- public TextMeshProUGUI nameRemind;
- public Image inputKuangImage;
- public GameObject AccountInfo;
- public GameObject LimitObj;
- public GameObject ActivityObj;
- public Button activityBtn;
- public TextMeshProUGUI activityText;
- public Button btnAccountNumber;
- public override void initShow()
- {
- base.initShow();
- if (UserInfo.textIcon == null)
- {
- texIcon.texture = UserInfo.defaulttextIcon;
- }
- else
- {
- texIcon.texture = UserInfo.textIcon;
- }
- userAccount.text = "当前账号: " + UserInfo.Account;
- nameRemind.gameObject.SetActive(false);
- inputKuangImage.color = Color.white;
- if (UserInfo.userName=="")
- {
- userName.text = "YCKJ" + UserInfo.Account.Substring(UserInfo.Account.Length-4);
- }
- else
- {
- userName.text = UserInfo.userName;
- }
-
- if (UserInfo.isSN)
- {
- accountManager.text = "该账号为设备SN号";
- userSNName.gameObject.SetActive(true);
- userName.gameObject.SetActive(false);
- userSNName.text = UserInfo.Account;
- activityBtn.gameObject.SetActive(false);
- }
- else
- {
- activityBtn.gameObject.SetActive(true);
- userSNName.gameObject.SetActive(false);
- userName.gameObject.SetActive(true);
- switch (UserInfo.activateType)
- {
- case 1:
- accountManager.text = "未激活账号";
- activityText.text = "激活";
- break;
- case 2:
- string indate = UserInfo.indate.ToString();
- if (indate == "0")
- {
- accountManager.text = "未激活账号";
- activityText.text = "激活";
- }
- else
- {
- string ti = GetTime(UserInfo.indate);
- accountManager.text = "账号已激活 有效期至" + ti;
- activityText.text = "续费";
- }
- break;
- case 3:
- accountManager.text = "账号永久激活";
- activityBtn.gameObject.SetActive(false);
- break;
- }
- }
- LimitObj.SetActive(false);
- ActivityObj.SetActive(false);
- accountManager.gameObject.SetActive(false);
- btnAccountNumber.gameObject.SetActive(false);
- }
- public void showOffice()
- {
- SaveNameandAvatar();
- ScenesManager.Instance.showOffice(SceneType.OfficeWindow);
- }
- public void gotoLogin()
- {
- SaveNameandAvatar();
- WSHandler.clientClosed();
- ShowLogin.Instance.loginType = LoginType.INIT;
- ScenesManager.Instance.showWindow(SceneType.ShowLogin);
- }
- private void SaveNameandAvatar()
- {
- if (!nameRemind.gameObject.activeSelf)
- {
- if (userName.text != "")
- {
- UserInfo.userName = userName.text;
- }
- }
- NetWorkHeaders.SetUserInfo();
- }
- private Action loginOutAction;
- private void Start()
- {
- loginOutAction += gotoLogin;
- swithAvatarAction += OnSwithAvatar;
- avatarList.Init();
- userName.onValueChanged.AddListener(NameValueChanged);
- userName.onEndEdit.AddListener(NameEndEdit);
- }
- private void NameEndEdit(string name)
- {
- int namecount = Encoding.GetEncoding("gb2312").GetByteCount(name);
- if (name == "" || name.Contains(" ") || namecount > 16)
- {
- nameRemind.gameObject.SetActive(true);
- nameRemind.text = RtcStrConfig.namenolegal;
- inputKuangImage.color = Color.red;
- }
- else
- {
- inputKuangImage.color = Color.white;
- }
- }
- private void NameValueChanged(string name)
- {
- nameRemind.gameObject.SetActive(false);
- inputKuangImage.color = Color.white;
- }
- private void OnSwithAvatar(Texture tex)
- {
- texIcon.texture = tex;
- }
- private void OnDestroy()
- {
- loginOutAction -= gotoLogin;
- swithAvatarAction -= OnSwithAvatar;
- }
- public void ShowLoginOutPop()
- {
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Pop, RtcStrConfig.outLoginmsg, "确定", loginOutAction);
- }
- public void ShowAvatarListPop()
- {
- if (!UserInfo.isSN)
- {
- AvatarListPop.SetActive(true);
- }
- }
- public void CloseAvatarListPop()
- {
- AvatarListPop.SetActive(false);
- }
- public void ShowLimitObj()
- {
- AccountInfo.SetActive(false);
- LimitObj.SetActive(true);
- }
- public void HeidLimitObj()
- {
- LimitObj.SetActive(false);
- AccountInfo.SetActive(true);
- }
- public void ShowActivityObj()
- {
- ActivityObj.SetActive(true);
- }
- public string GetTime(double timechu)
- {
- DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
- DateTime dt = startTime.AddSeconds(timechu);
- string t = dt.ToString("yyyy-MM-dd HH:mm:ss");
- string[] arr = t.Split(' ');
- return arr[0];
- }
- private void OnDisable()
- {
- }
- }
|