UserInfoCheck.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using LitJson;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using static Manager;
  7. public class UserInfoCheck : MonoBehaviour
  8. {
  9. public GameObject savesuccess;
  10. public GameObject savefail;
  11. public Text tacc;
  12. public InputField iname;
  13. public InputField ibumen;
  14. public InputField izhiwu;
  15. public InputField ibeizhu;
  16. private void OnEnable()
  17. {
  18. if (DataManager.Instance)
  19. {
  20. DataManager.Instance.getuserinfo((msg) => {
  21. tacc.text = msg.count;
  22. iname.text = msg.name;
  23. ibumen.text = msg.dept;
  24. izhiwu.text = msg.position;
  25. ibeizhu.text = msg.notes;
  26. });
  27. }
  28. }
  29. public void changeInfo()
  30. {
  31. UserInfo uinfo =new UserInfo();
  32. uinfo.name = iname.text;
  33. uinfo.dept = ibumen.text;
  34. uinfo.position = izhiwu.text;
  35. uinfo.notes = ibeizhu.text;
  36. DataManager.Instance.setuserinfo(uinfo,(msg) => {
  37. try{
  38. JsonData d = JsonMapper.ToObject(msg);
  39. if(d["data"]==null)
  40. {
  41. savefail.SetActive(true);
  42. Invoke("savefailcloes",2f);
  43. }
  44. else
  45. {
  46. savesuccess.SetActive(true);
  47. Invoke("savecloes",2f);
  48. }
  49. }
  50. catch{
  51. savefail.SetActive(true);
  52. Invoke("savefailcloes",2f);
  53. }
  54. });
  55. }
  56. void savecloes()
  57. {
  58. savesuccess.SetActive(false);
  59. MainCenterManager.Instance.showMain();
  60. }
  61. void savefailcloes()
  62. {
  63. savefail.SetActive(false);
  64. }
  65. }