123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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>().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>().text = j["message"].ToString();
- sb.SetActive(true);
- }
- }catch
- {
- JsonData j =JsonMapper.ToObject(str);
- sb.GetComponentInChildren<Text>().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);
- }
- }
|