From b5e67fdb51678e9cd5c308afa8d96b93f1bfc977 Mon Sep 17 00:00:00 2001 From: HuangZiBo <1278481331@qq.com> Date: Wed, 11 Dec 2024 11:14:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Script/login/login.cs | 11 ++++++-- .../Assets/Script/loginScripts/LoginPanel.cs | 25 +++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/xiaofang/Assets/Script/login/login.cs b/xiaofang/Assets/Script/login/login.cs index 09b09bfc..b6d93a4b 100644 --- a/xiaofang/Assets/Script/login/login.cs +++ b/xiaofang/Assets/Script/login/login.cs @@ -8,8 +8,15 @@ using JetBrains.Annotations; using System.Data; public class auth_login { - public string clientId = "e5cd7e4891bf95d1d19206ce24a7b32e"; - public string grantType = "password"; + //public string clientId = "e5cd7e4891bf95d1d19206ce24a7b32e"; + //public string grantType = "password"; + public string grantType; + public string clientId; + public string userType; + public string username; + public string password; + public string phonenumber; + public string smsCode; } //public class auth_createTemplate //{ diff --git a/xiaofang/Assets/Script/loginScripts/LoginPanel.cs b/xiaofang/Assets/Script/loginScripts/LoginPanel.cs index 356e0ba2..e16a5763 100644 --- a/xiaofang/Assets/Script/loginScripts/LoginPanel.cs +++ b/xiaofang/Assets/Script/loginScripts/LoginPanel.cs @@ -38,22 +38,33 @@ public class LoginPanel : MonoBehaviour //登录逻辑 public async void Login() { + // 创建登录请求的 body auth_login loginBody = new auth_login { - clientId = id.text, - grantType = pwd.text + grantType = "password", + clientId = "e5cd7e4891bf95d1d19206ce24a7b32e", + userType = "company_user", + username = "13006065371", + password = "YYL5371!", + phonenumber = "", + smsCode = "" }; - //Debug.Log(JsonUtility.ToJson(loginBody)); + + // 发送请求 string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(loginBody)); Debug.Log("登录" + response); + // 解析服务器返回的数据 loginResponse serverData = JsonConvert.DeserializeObject(response); - //token = serverData.data.access_token; + + // 将登录响应数据保存到静态变量中 + GlobalData.ServerData = serverData; + + // 打印 access_token Debug.Log(serverData.data.access_token); - //跳转场景写这里 - SceneManager.LoadScene("scheduled_exercise"); + // 跳转场景 + SceneManager.LoadScene(1); } - }