createzhanghao.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using LitJson;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class createzhanghao : MonoBehaviour
  7. {
  8. public GameObject one;
  9. public GameObject cg;
  10. public GameObject sb;
  11. public InputField accinput;
  12. public InputField nameinput;
  13. public InputField deptinput;
  14. public InputField notesinput;
  15. public InputField positioninput;
  16. public InputField inputpass;
  17. public Toggle admintg;
  18. public void createrzh()
  19. {
  20. JsonData d = new JsonData();
  21. d["account"] = accinput.text;
  22. d["name"] = nameinput.text;
  23. d["dept"] = deptinput.text;
  24. d["notes"] = notesinput.text;
  25. d["position"] = positioninput.text;
  26. d["admin"] = admintg.isOn?1:0;
  27. d["password"] = AesEncryption.Encrypt(inputpass.text);
  28. DataManager.Instance.createzh(d,(str)=>{
  29. try{
  30. JsonData j =JsonMapper.ToObject(str);
  31. if(bool.Parse(j["data"]["result"].ToString()))
  32. {
  33. cg.SetActive(true);
  34. Invoke("cgyc",2f);
  35. }
  36. else
  37. {
  38. sb.SetActive(true);
  39. Invoke("csbyc",2f);
  40. }
  41. }catch
  42. {
  43. sb.SetActive(true);
  44. Invoke("csbyc",2f);
  45. }
  46. });
  47. }
  48. void cgyc()
  49. {
  50. cg.SetActive(false);
  51. this.gameObject.SetActive(false);
  52. one.SetActive(true);
  53. }
  54. void csbyc()
  55. {
  56. sb.SetActive(false);
  57. }
  58. }