UserInfoCheck.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. UserInfo uinfo ;
  17. private void OnEnable()
  18. {
  19. if (DataManager.Instance)
  20. {
  21. DataManager.Instance.getuserinfo((msg) => {
  22. uinfo =msg;
  23. Invoke("updatedata",0.5f);
  24. });
  25. }
  26. }
  27. void updatedata()
  28. {
  29. tacc.text = uinfo.count;
  30. iname.text = uinfo.name;
  31. ibumen.text = uinfo.position;
  32. izhiwu.text = uinfo.dept;
  33. ibeizhu.text = uinfo.notes;
  34. }
  35. public void changeInfo()
  36. {
  37. UserInfo uinfo =new UserInfo();
  38. uinfo.name = iname.text;
  39. uinfo.dept = izhiwu.text;
  40. uinfo.position = ibumen.text;
  41. uinfo.notes = ibeizhu.text;
  42. DataManager.Instance.setuserinfo(uinfo,(msg) => {
  43. try{
  44. JsonData d = JsonMapper.ToObject(msg);
  45. if(d["data"]==null)
  46. {
  47. savefail.SetActive(true);
  48. Invoke("savefailcloes",2f);
  49. }
  50. else
  51. {
  52. savesuccess.SetActive(true);
  53. Invoke("savecloes",2f);
  54. }
  55. }
  56. catch{
  57. savefail.SetActive(true);
  58. Invoke("savefailcloes",2f);
  59. }
  60. });
  61. }
  62. void savecloes()
  63. {
  64. savesuccess.SetActive(false);
  65. MainCenterManager.Instance.showMain();
  66. }
  67. void savefailcloes()
  68. {
  69. savefail.SetActive(false);
  70. }
  71. }