createzhanghao.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using LitJson;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using static ChangePass;
  7. public class createzhanghao : MonoBehaviour
  8. {
  9. public GameObject one;
  10. public GameObject cg;
  11. public GameObject sb;
  12. public InputField accinput;
  13. public InputField nameinput;
  14. public InputField deptinput;
  15. public InputField notesinput;
  16. public InputField positioninput;
  17. public InputField inputpass;
  18. public Toggle admintg;
  19. public GameObject error1;
  20. public GameObject error2;
  21. public GameObject error3;
  22. private void OnEnable() {
  23. error1.SetActive(false);
  24. error2.SetActive(false);
  25. error3.SetActive(false);
  26. }
  27. public void createrzh()
  28. {
  29. error1.SetActive(false);
  30. error2.SetActive(false);
  31. error3.SetActive(false);
  32. if(accinput.text=="")
  33. {
  34. error1.SetActive(true);
  35. return;
  36. }
  37. if(nameinput.text=="")
  38. {
  39. error2.SetActive(true);
  40. return;
  41. }
  42. passcheck p = ChangePass.checkpass(inputpass.text);
  43. if(p.ct<3||inputpass.text.Length<8)
  44. {
  45. error3.GetComponent<Text>().text = p.msg;
  46. error3.SetActive(true);
  47. return;
  48. }
  49. JsonData d = new JsonData();
  50. d["account"] = accinput.text;
  51. d["name"] = nameinput.text;
  52. d["dept"] = deptinput.text;
  53. d["notes"] = notesinput.text;
  54. d["position"] = positioninput.text;
  55. d["admin"] = admintg.isOn?1:0;
  56. d["password"] = AesEncryption.Encrypt(inputpass.text);
  57. DataManager.Instance.createzh(d,(str)=>{
  58. try{
  59. JsonData j =JsonMapper.ToObject(str);
  60. if(bool.Parse(j["data"]["result"].ToString()))
  61. {
  62. cg.SetActive(true);
  63. Invoke("cgyc",2f);
  64. }
  65. else
  66. {
  67. sb.SetActive(true);
  68. Invoke("csbyc",2f);
  69. }
  70. }catch
  71. {
  72. sb.SetActive(true);
  73. Invoke("csbyc",2f);
  74. }
  75. });
  76. }
  77. void cgyc()
  78. {
  79. cg.SetActive(false);
  80. this.gameObject.SetActive(false);
  81. one.SetActive(true);
  82. }
  83. void csbyc()
  84. {
  85. sb.SetActive(false);
  86. }
  87. }