Ver código fonte

修改密码框

“hujiajun” 1 mês atrás
pai
commit
2e6b66b0d8

+ 26 - 11
Assets/ChangePass.cs

@@ -23,17 +23,15 @@ public class ChangePass : MonoBehaviour
         terror2.SetActive(false);
         terror3.SetActive(false);
     }
-    public void changepass()
+
+    public static passcheck checkpass(string pass)
     {
-        terror.SetActive(false);
-        terror2.SetActive(false);
-        terror3.SetActive(false);
-     
+
         int ct =0;
         string msg = "密码格式缺少:";
         var pwdRegex1 = "(?=.*[0-9])"; // 数字
         Regex reg1 = new Regex(pwdRegex1);
-        bool isMatch1 = reg1.IsMatch(inputnew1.text);
+        bool isMatch1 = reg1.IsMatch(pass);
         if(!isMatch1)
         {
             msg += "数字 ";
@@ -44,7 +42,7 @@ public class ChangePass : MonoBehaviour
         }
         var pwdRegex2 = "(?=.*[a-z])"; // 小写字母
         Regex reg2 = new Regex(pwdRegex2);
-        bool isMatch2 = reg2.IsMatch(inputnew1.text);
+        bool isMatch2 = reg2.IsMatch(pass);
         if(!isMatch2)
         {
 
@@ -56,7 +54,7 @@ public class ChangePass : MonoBehaviour
         }
         var pwdRegex3 = "(?=.*[A-Z])"; // 大写字母
         Regex reg3= new Regex(pwdRegex3);
-        bool isMatch3 = reg3.IsMatch(inputnew1.text);
+        bool isMatch3 = reg3.IsMatch(pass);
         if(!isMatch3)
         {
             msg += "大写字母 ";
@@ -67,7 +65,7 @@ public class ChangePass : MonoBehaviour
         }
         var pwdRegex4 = "[!@#$%^&*(),.?\\\":{}|<>]"; // 特殊字符
         Regex reg4= new Regex(pwdRegex4);
-        bool isMatch4 = reg4.IsMatch(inputnew1.text);
+        bool isMatch4 = reg4.IsMatch(pass);
         if(!isMatch4)
         {
 
@@ -78,10 +76,27 @@ public class ChangePass : MonoBehaviour
             ct++;
         }
         msg+="中"+(3-ct)+"个";
-        if(inputnew1.text.Length<8)
+        if(pass.Length<8)
         {
             msg = "密码必须大于8位";
         }
+      passcheck p=  new passcheck();
+      p.ct = ct;
+      p.msg=msg;
+      return p;
+    }
+
+    public class passcheck
+    {
+        public int ct;
+        public string msg;
+    }
+    public void changepass()
+    {
+        terror.SetActive(false);
+        terror2.SetActive(false);
+        terror3.SetActive(false);
+        int ct = checkpass(inputnew1.text).ct;
         if(ct>=3&&inputnew1.text.Length>=8)
         {   
             string oldpass = AesEncryption.Encrypt(inputold.text);
@@ -112,7 +127,7 @@ public class ChangePass : MonoBehaviour
         }
         else
         {
-            terror3.GetComponent<Text>().text = msg;
+            terror3.GetComponent<Text>().text = checkpass(inputnew1.text).msg;
             terror3.SetActive(true);
         }
      

+ 11 - 1
Assets/LoginManager.cs

@@ -21,7 +21,7 @@ public class LoginManager : MonoBehaviour
     public GameObject error;
     public GameObject erroracct;
     public GameObject errorpass;
-    private void Start()
+    private void OnEnable()
     {
         if(!isinit)
         {
@@ -29,13 +29,23 @@ public class LoginManager : MonoBehaviour
             this.gameObject.SetActive(true);
             Main.SetActive(false);
         }
+         rembpassToggle.isOn=false;
+        inputacct.text = "";
+        inputpass.text = "";
+        Invoke("InitData",0.5f);
+    }
+    void InitData()
+    {
+
         int i= PlayerPrefs.GetInt("remb");
         if(i==1)
         {
             inputacct.text = PlayerPrefs.GetString("acc");
             inputpass.text = PlayerPrefs.GetString("pass");
         }
+        Debug.Log("PlayerPrefs==>"+i);
         passToggle.isOn = false;
+        rembpassToggle.isOn = i==1?true:false;
         inputacct.onEndEdit.AddListener((str) => {
 
             if (str == "")

Diferenças do arquivo suprimidas por serem muito extensas
+ 2 - 44
Assets/Scenes/Main.unity


+ 34 - 0
Assets/createzhanghao.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using LitJson;
 using UnityEngine;
 using UnityEngine.UI;
+using static ChangePass;
 
 public class createzhanghao : MonoBehaviour
 {
@@ -16,8 +17,41 @@ public class createzhanghao : MonoBehaviour
    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;

BIN
test2/test/Build/test.data.unityweb


BIN
test2/test/Build/test.framework.js.unityweb


BIN
test2/test/Build/test.symbols.json.unityweb


BIN
test2/test/Build/test.wasm.unityweb


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff