Commit 7a7dffe8 authored by 潘梓豪's avatar 潘梓豪

添加忘记密码、记住账号密码功能

parent 71b97fa0
......@@ -36,8 +36,8 @@ MonoBehaviour:
- Cinemachine
- ZeusSQLite
- HighlightingSystem
- RTVoice
- SplineMeshRenderer
- RTVoice
showAdvancedSettings: 0
addMgrToSceneAutomatically: 0
autoUpdateReferences: 1
......
......@@ -55,4 +55,8 @@ MonoBehaviour:
- {fileID: 21300000, guid: 74f73b48a515db8468a56c31d1e39c46, type: 3}
- {fileID: 2800000, guid: 6d58d2dd3d36682488cd0471906a73e2, type: 3}
- {fileID: 21300000, guid: 6d58d2dd3d36682488cd0471906a73e2, type: 3}
_Values: 7b3984e6e3131c3a2e49df665222b669a5d1ff93488b6f208275de66676a6f2a3297fea26c99d37b5f6558d8b0bed82cbea35bd209153c3462a700097cdd197717c4ca9ade77460a16cfbdab362de15b9c3ef3f1bdb1da47792e1234cebd647e7d3db6ff7c40f74678a45b442ff4ca65eb8322b064113c576b3f2ef877e2de5ab8536b930c5f1019eb9a31e79dfa066baa29636123cc2714ae529505ab0dfa0643c4ef012d48034b12eab983bfa43907ec4025594774ad61149bf2acc84f4e40346ea6edacc2804cfea435af0078bf35fa0e8f4f3993417e4c7148f47eab4d03266ad1444771bd4ea8d6dd783747cc2627daa9b6ade36f4f7f786684684780134b95c902679676474753a4b216befe5f67c078c096edfc792264fa94d7c1447c0adfd78de286e13c395a77638d4b653311e995ccf73e542e05846f04dc1d3e02bf1667b8b6fc5f02
- {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3}
- {fileID: 10900, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 11500000, guid: 12ba7b71cc04d744d96cc77fc98361ed, type: 3}
_Values: 7b3984e6e3131c3a2e49df665222b669a5d1ff93488b6f208275de66676a6f2a3297fea26c99d37b5f6558d8b0bed82cbea35bd209153c3462a700097cdd197717c4ca9ade77460a16cfbdab362de15b9c3ef3f1bdb1da47792e1234cebd647e7d3db6ff7c40f74678a45b442ff4ca65eb8322b064113c576b3f2ef877e2de5ab8536b930c5f1019eb9a31e79dfa066baa29636123cc2714ae529505ab0dfa0643c4ef012d48034b12eab983bfa43907ec4025594774ad61149bf2acc84f4e40346ea6edacc2804cfea435af0078bf35fa0e8f4f3993417e4c7148f47eab4d03266ad1444771bd4ea8d6dd783747cc2627daa9b6ade36f4f7f786684684780134b95c902679676474753a4b216befe5f67c078c096edfc792264fa94d7c1447c0adfd78de286e13c395a77638d4b653311e995ccf73e542e05846f04dc1d3e02bf1667b8b6fc5f024563f6801123770fa8dac044943be61ca2cb062f657a432f2f121c9bd4022925
using LitJson;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ButtonComponents : MonoBehaviour
{
// Start is called before the first frame update
public Toggle remember_me;
public Button forget_password;
public TMP_Text username;
public TMP_Text password;
public TMP_Text smscode;
public TMP_Text msg;
public GameObject[] btn_compent;
RequestMethod requestMethod;
ZeusHub_Manager manager;
IEnumerator Start()
{
yield return null;
requestMethod = RequestMethod.requestMethod;
if (!manager)
{
manager = ZeusHub_Manager.manager;
manager.OnReceiveMsg.AddListener(_onReceiveMsg);
}
}
// Update is called once per frame
void Update()
{
}
protected void _onReceiveMsg(object data, string parameter)
{
RequestManager requestManager = (RequestManager)data;
if (requestManager.type.Equals("ValSmsCodde"))
{
if (requestManager.result.Equals("\"Code expire\""))
{
string json = "{\"password\":\"" + TextTool.relacestr(password.GetComponentInParent<TMP_InputField>().text) + "\",\"phone\":\"" + TextTool.relacestr(username.text) + "\"}";
StartCoroutine(requestMethod.PostDataJson(Setting.IP + "/zeus/es3cloud/upUsers", json, 2, "ResetPassword"));
}
else
{
msg.text = "验证码失效";
}
}
if (requestManager.type.Equals("ResetPassword"))
{
Dictionary<string, object> reset_msg = JsonUntily.JsonToDictionary(requestManager.result);
var code = reset_msg.Where(S => S.Key == "code").Select(S => S.Value).First();
if (code.Equals(0))
{
btn_compent[0].SetActive(true);
var input_texts= btn_compent[0].GetComponentsInChildren<TMP_Text>();
if (input_texts != null && input_texts.Length > 0)
{
foreach(var item in input_texts)
{
if (item.GetComponentInParent<TMP_InputField>()!=null)
{
item.GetComponentInParent<TMP_InputField>().text = "";
}
}
}
btn_compent[0].GetComponentInChildren<Toggle>().isOn = false;
msg.text = "重置密码成功";
btn_compent[1].SetActive(false);
}
else if(code.Equals(1))
{
msg.text = "不存在该账号,请先注册";
}
}
}
public void reset_password()
{
if (TextTool.relacestr(username.text) == "")
{
msg.text = "手机号不能为空";
return;
}
var inputfiled = password.GetComponentInParent<TMP_InputField>();
if (TextTool.relacestr(inputfiled.text) == "")
{
msg.text = "密码不能为空";
return;
}
if (TextTool.relacestr(smscode.text) == "")
{
msg.text = "请输入验证码";
return;
}
string json = "{\"phone\":\"" + TextTool.relacestr(username.text) + "\",\"code\":\"" + TextTool.relacestr(smscode.text) + "\"}";
StartCoroutine(requestMethod.PostDataJson(Setting.IP + "/zeus/sms/valsmscode", json, 2, "ValSmsCodde"));
}
}
fileFormatVersion: 2
guid: 12ba7b71cc04d744d96cc77fc98361ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -6,7 +6,7 @@ using System.IO;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class RegisterButton : MonoBehaviour
{
......@@ -16,6 +16,8 @@ public class RegisterButton : MonoBehaviour
public TMP_Text smscode;
public TMP_Text msg;
public Toggle remember_me;
RequestMethod requestMethod;
ZeusHub_Manager manager;
......@@ -28,6 +30,7 @@ public class RegisterButton : MonoBehaviour
{
manager = ZeusHub_Manager.manager;
manager.OnReceiveMsg.AddListener(_onReceiveMsg);
manager.OnReceiveError.AddListener(_onReceiveErrorMsg);
}
}
......@@ -63,7 +66,22 @@ public class RegisterButton : MonoBehaviour
manager.token = (string)token.Where(S => S.Key == "token_type").Select(S => S.Value).First()+" "
+ (string)token.Where(S => S.Key == "access_token").Select(S => S.Value).First();
/* manager.token =(string)token.Where(S => S.Key == "access_token").Select(S => S.Value).First();*/
//判断是否记住
if (remember_me.isOn)
{
PlayerPrefs.SetString("name", username.text);
PlayerPrefs.SetString("password", password.GetComponentInParent<TMP_InputField>().text);
PlayerPrefs.SetInt("ison", remember_me.isOn == true ? 1 : 2);
}
else
{
PlayerPrefs.DeleteKey("name");
PlayerPrefs.DeleteKey("password");
PlayerPrefs.DeleteKey("ison");
}
/* manager.token =(string)token.Where(S => S.Key == "access_token").Select(S => S.Value).First();*/
//跳转页面
startProcess();
......@@ -119,11 +137,17 @@ public class RegisterButton : MonoBehaviour
}
protected void _onReceiveErrorMsg(string error_str)
{
msg.text = "错误";
}
public void registrer()
{
if (TextTool.relacestr(username.text)=="")
{
msg.text = "用户名不能为空";
msg.text = "手机号不能为空";
return;
}
......@@ -166,7 +190,7 @@ public class RegisterButton : MonoBehaviour
formData.AddField("client_secret", Setting.client_secret);
formData.AddField("username", TextTool.relacestr(username.text));
formData.AddField("password", TextTool.relacestr(inputfiled.text));
StartCoroutine(requestMethod.PostDataFormData(Setting.IP + "/oauth/token",formData, "gettoken"));
}
......
......@@ -52,4 +52,22 @@ public class SmsButton : MonoBehaviour
}
}
public void ResetSend(TMP_Text phone)
{
if (TextTool.relacestr(phone.text) != "")
{
StartCoroutine(requestMethod.GetDataJson(Setting.IP + "/zeus/sms/getresetsmscode/" + TextTool.relacestr(phone.text), "SmsCode"));
timer = 60;
}
else
{
while (!manager)
{
manager = ZeusHub_Manager.manager;
}
Debug.Log(manager);
manager.msg.text = "请输入手机号码";
}
}
}
......@@ -5,6 +5,7 @@ using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class ZeusHub_Manager : MonoBehaviour
{
......@@ -24,10 +25,31 @@ public class ZeusHub_Manager : MonoBehaviour
//
public string token = "";
public TMP_Text username;
public TMP_Text password;
public Toggle remember_me;
IEnumerator Start()
{
if (PlayerPrefs.HasKey("name"))
{
//有的话,获取name的值
username.GetComponentInParent<TMP_InputField>().text = PlayerPrefs.GetString("name");
}
if (PlayerPrefs.HasKey("password"))
{
password.GetComponentInParent<TMP_InputField>().text = PlayerPrefs.GetString("password");
}
if (PlayerPrefs.HasKey("ison"))
{
remember_me.isOn = PlayerPrefs.GetInt("ison") == 1 ? true : false;
}
manager = this;
manager.OnReceiveMsg.AddListener(_onReceiveMsg);
requestMethod = RequestMethod.requestMethod;
......
......@@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using ZenFulcrum.EmbeddedBrowser;
public class WelBorews : MonoBehaviour
......@@ -25,9 +26,16 @@ public class WelBorews : MonoBehaviour
public static WelBorews welBorews;
ZeusHub_Manager manager;
private void Start()
{
downloadUntily = new DownloadUntily();
if (!manager)
{
manager = ZeusHub_Manager.manager;
}
downloadUntily = new DownloadUntily();
Dictionary<string, object> param = SceneMgr.ins.ReadSceneData();
token = (string)param.Where(S => S.Key == "token").Select(S => S.Value).First();
string robotcode= (string)param.Where(S => S.Key == "robotcode").Select(S => S.Value).First();
......@@ -108,6 +116,10 @@ public class WelBorews : MonoBehaviour
uploadfile(jk[0].Value + "",jk[1].Value+"");
});
browser.RegisterFunction("loginout", (JSONNode jk) => {
loginout();
});
}
......@@ -192,5 +204,10 @@ public class WelBorews : MonoBehaviour
StartCoroutine(downloadUntily.PutOss(base64,filename));
}
public void loginout()
{
manager.token = null;
SceneManager.LoadScene("MyScene");
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -360,7 +360,7 @@
<a class="dropdown-item d-block" href="#"><span class="badge bg-success float-end mt-1">11</span><i class="ri-settings-2-line align-middle me-1"></i> 设置</a>
<a class="dropdown-item" href="#"><i class="ri-lock-unlock-line align-middle me-1"></i> 锁屏</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="#"><i class="ri-shut-down-line align-middle me-1 text-danger"></i> 登出</a>
<a class="dropdown-item text-danger loginout" href="#"><i class="ri-shut-down-line align-middle me-1 text-danger"></i> 登出</a>
</div>
</div>
......@@ -993,6 +993,9 @@
reader.readAsDataURL(file);
});
$(document).on("click",".loginout",function(){
loginout();
});
</script>
</body>
......
......@@ -360,7 +360,7 @@
<a class="dropdown-item d-block" href="#"><span class="badge bg-success float-end mt-1">11</span><i class="ri-settings-2-line align-middle me-1"></i> 设置</a>
<a class="dropdown-item" href="#"><i class="ri-lock-unlock-line align-middle me-1"></i> 锁屏</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="#"><i class="ri-shut-down-line align-middle me-1 text-danger"></i> 登出</a>
<a class="dropdown-item text-danger loginout" href="#"><i class="ri-shut-down-line align-middle me-1 text-danger "></i> 登出</a>
</div>
</div>
......@@ -1152,6 +1152,10 @@
});
}
$(document).on("click",".loginout",function(){
loginout();
});
</script>
</body>
......
......@@ -7090,3 +7090,13 @@
2022/8/9 9:53:04 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/9 9:54:42 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/9 10:00:31 api:http://192.168.199.127:11011/zeus/sms/register?_format=json HTTP/1.1 500 Internal Server Error
2022/8/11 11:49:26 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 11:56:17 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 11:57:30 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 11:58:39 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 14:05:49 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 14:16:14 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 15:09:52 api:http://192.168.199.127:11011/zeus/es3cloud/upUsers HTTP/1.1 500 Internal Server Error
2022/8/11 15:27:37 api:http://192.168.199.127:11011/zeus/es3cloud/upUsers HTTP/1.1 500 Internal Server Error
2022/8/11 16:42:25 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
2022/8/11 16:43:47 api:http://192.168.199.127:11011/oauth/token HTTP/1.1 401 Unauthorized
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment