using System.Collections; using System.Collections.Generic; using LitJson; using UnityEngine; using UnityEngine.UI; using static ChangePass; public class createzhanghao : MonoBehaviour { public GameObject one; public GameObject cg; public GameObject sb; public InputField accinput; public InputField nameinput; public InputField deptinput; public InputField notesinput; public InputField positioninput; public InputField inputpass; public Toggle admintg; public GameObject error1; public GameObject error2; public GameObject error3; private void OnEnable() { error1.SetActive(false); error2.SetActive(false); error3.SetActive(false); } public void createrzh() { error1.SetActive(false); error2.SetActive(false); error3.SetActive(false); if(accinput.text=="") { error1.SetActive(true); return; } if(nameinput.text=="") { error2.SetActive(true); return; } passcheck p = ChangePass.checkpass(inputpass.text); if(p.ct<3||inputpass.text.Length<8) { error3.GetComponent().text = p.msg; error3.SetActive(true); return; } JsonData d = new JsonData(); d["account"] = accinput.text; d["name"] = nameinput.text; d["dept"] = deptinput.text; d["notes"] = notesinput.text; d["position"] = positioninput.text; d["admin"] = admintg.isOn?1:0; d["password"] = AesEncryption.Encrypt(inputpass.text); DataManager.Instance.createzh(d,(str)=>{ try{ JsonData j =JsonMapper.ToObject(str); if(bool.Parse(j["data"]["result"].ToString())) { cg.SetActive(true); Invoke("cgyc",2f); } else { sb.GetComponentInChildren().text = j["message"].ToString(); sb.SetActive(true); } }catch { JsonData j =JsonMapper.ToObject(str); sb.GetComponentInChildren().text = j["message"].ToString(); sb.SetActive(true); } }); } void cgyc() { accinput.text=""; nameinput.text=""; deptinput.text=""; notesinput.text=""; positioninput.text=""; inputpass.text=""; cg.SetActive(false); this.gameObject.SetActive(false); one.SetActive(true); } }