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; public Image image; // Start is called before the first frame update void Start() { loginBtn.onClick.AddListener(OnClickLoginBtn); getYzmBtn.onClick.AddListener(OnClickGetYzmBtn); image.gameObject.SetActive(false); } 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 = "13699802230",//"ZF16c788632",13699802230,13051628292 password = "YYL5371!" }; image.gameObject.SetActive (true); // 发送请求 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); //如果是管理员账号就跳预定演练 //if (loginBody.userType == "company_user") if(GlobalData.ServerData.data.isCreater=="Y") { Debug.LogError(11); ReadRoom.instance.isadministrator=true; //ReadRoom.instance.adHead(); SceneManager.LoadScene("yhj"); } else //if(id.text == "13699802230" && pwd.text == "YYL5371!") { //SceneManager.LoadScene("yhj"); ReadRoom.instance.head(); } //else //{ // SceneManager.LoadScene("Tmap 1"); //} ////如果是玩家账号就跳转到加入房间界面 //if (loginBody.userType == "Player") // SceneManager.LoadScene(5); // 跳转场景 //ReadRoom.instance.head(); } }