using System.Collections; using System.Collections.Generic; using LitJson; using UnityEngine; using UnityEngine.UI; using static Manager; public class UserInfoCheck : MonoBehaviour { public GameObject savesuccess; public GameObject savefail; public Text tacc; public InputField iname; public InputField ibumen; public InputField izhiwu; public InputField ibeizhu; UserInfo uinfo ; private void OnEnable() { if (DataManager.Instance) { DataManager.Instance.getuserinfo((msg) => { uinfo =msg; Invoke("updatedata",0.5f); }); } } void updatedata() { tacc.text = uinfo.count; iname.text = uinfo.name; ibumen.text = uinfo.position; izhiwu.text = uinfo.dept; ibeizhu.text = uinfo.notes; } public void changeInfo() { UserInfo uinfo =new UserInfo(); uinfo.name = iname.text; uinfo.dept = izhiwu.text; uinfo.position = ibumen.text; uinfo.notes = ibeizhu.text; DataManager.Instance.setuserinfo(uinfo,(msg) => { JsonData d = JsonMapper.ToObject(msg); try{ if(d["data"]==null) { savefail.GetComponentInChildren().text = d["message"].ToString(); savefail.SetActive(true); } else { savesuccess.SetActive(true); Invoke("savecloes",2f); } } catch{ savefail.GetComponentInChildren().text = "失败"; savefail.SetActive(true); } }); } void savecloes() { savesuccess.SetActive(false); MainCenterManager.Instance.showMain(); } }