using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting.Antlr3.Runtime; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class LoginPanel : Base { public Button loginBtn; public Button getYzmBtn; public InputField id; public InputField pwd; public InputField sjh; public InputField yzm; // Start is called before the first frame update void Start() { loginBtn.onClick.AddListener(OnClickLoginBtn); getYzmBtn.onClick.AddListener(OnClickGetYzmBtn); } public void OnClickGetYzmBtn() { } public void OnClickLoginBtn() { Login(); } //登录逻辑 public async void Login() { // 创建登录请求的 body auth_login loginBody = new auth_login { 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); // 将登录响应数据保存到静态变量中 GlobalData.ServerData = serverData; // 打印 access_token Debug.Log(serverData.data.access_token); // 跳转场景 ReadRoom.instance.head(); //如果是管理员账号就跳预定演练 //if (loginBody.userType == "company_user") // SceneManager.LoadScene(1); ////如果是玩家账号就跳转到加入房间界面 //if (loginBody.userType == "Player") // SceneManager.LoadScene(2); } }