From 4ed4a6076fcebfaf0f3eba5b562d9db9f72a3440 Mon Sep 17 00:00:00 2001 From: huyulong <1838407198@qq.com> Date: Mon, 25 Nov 2024 10:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Scenes/loginscene.unity | 6 +-- .../Assets/Script/loginScripts/LoginPanel.cs | 43 +++++++++++-------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/xiaofang/Assets/Scenes/loginscene.unity b/xiaofang/Assets/Scenes/loginscene.unity index 67065c5d..ae51c1ad 100644 --- a/xiaofang/Assets/Scenes/loginscene.unity +++ b/xiaofang/Assets/Scenes/loginscene.unity @@ -817,7 +817,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 252707970} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: f381a54ea0a90e3448e8ae6e3cf61375, type: 3} m_Name: @@ -836,9 +836,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 764bdc3f3af765b46a38c1133bfcbd2f, type: 3} m_Name: m_EditorClassIdentifier: - pwdLoginBtn: {fileID: 0} - yzmLoginBtn: {fileID: 0} - loginBtn: {fileID: 0} + loginBtn: {fileID: 1493573621} getYzmBtn: {fileID: 1341634595} id: {fileID: 998972941} pwd: {fileID: 1477048540} diff --git a/xiaofang/Assets/Script/loginScripts/LoginPanel.cs b/xiaofang/Assets/Script/loginScripts/LoginPanel.cs index 0bd8771f..3bf5ffb4 100644 --- a/xiaofang/Assets/Script/loginScripts/LoginPanel.cs +++ b/xiaofang/Assets/Script/loginScripts/LoginPanel.cs @@ -1,13 +1,15 @@ +using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; +using Unity.VisualScripting.Antlr3.Runtime; +using UnityEditor.PackageManager; using UnityEngine; using UnityEngine.UI; public class LoginPanel : MonoBehaviour { - public Button pwdLoginBtn; - public Button yzmLoginBtn; + public Button loginBtn; public Button getYzmBtn; public InputField id; @@ -18,8 +20,7 @@ public class LoginPanel : MonoBehaviour // Start is called before the first frame update void Start() { - pwdLoginBtn.onClick.AddListener(OnClickPwdLoginBtn); - yzmLoginBtn.onClick.AddListener(OnClickYzmLoginBtn); + loginBtn.onClick.AddListener(OnClickLoginBtn); getYzmBtn.onClick.AddListener(OnClickGetYzmBtn); } @@ -31,22 +32,26 @@ public class LoginPanel : MonoBehaviour public void OnClickLoginBtn() { + Login(); + } + + //登录逻辑 + public async void Login() + { + auth_login loginBody = new auth_login + { + clientId = id.text, + grantType = pwd.text + }; + //Debug.Log(JsonUtility.ToJson(loginBody)); + string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(loginBody)); + Debug.Log("登录" + response); + // 解析服务器返回的数据 + server serverData = JsonConvert.DeserializeObject(response); + //token = serverData.data.access_token; + Debug.Log(serverData.data.access_token); } - public void OnClickYzmLoginBtn() - { - - } - - public void OnClickPwdLoginBtn() - { - - } - - // Update is called once per frame - void Update() - { - - } + }