_xiaofang/xiaofang/Assets/Script/loginScripts/LoginPanel.cs

95 lines
2.4 KiB
C#
Raw Normal View History

2024-11-25 10:54:30 +08:00
using Newtonsoft.Json;
2024-11-25 10:18:49 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
2024-11-25 10:54:30 +08:00
using Unity.VisualScripting.Antlr3.Runtime;
2024-11-25 10:18:49 +08:00
using UnityEngine;
2024-11-25 16:33:54 +08:00
using UnityEngine.SceneManagement;
2024-11-25 10:18:49 +08:00
using UnityEngine.UI;
2024-12-19 21:36:02 +08:00
public class LoginPanel : Base
2024-11-25 10:18:49 +08:00
{
2024-11-25 10:54:30 +08:00
2024-11-25 10:18:49 +08:00
public Button loginBtn;
public Button getYzmBtn;
public InputField id;
public InputField pwd;
public InputField sjh;
public InputField yzm;
2024-12-26 03:46:07 +08:00
public Image image;
2024-11-25 10:18:49 +08:00
// Start is called before the first frame update
void Start()
{
2024-11-25 10:54:30 +08:00
2024-11-25 10:18:49 +08:00
loginBtn.onClick.AddListener(OnClickLoginBtn);
getYzmBtn.onClick.AddListener(OnClickGetYzmBtn);
2024-12-26 03:46:07 +08:00
image.gameObject.SetActive(false);
2024-11-25 10:18:49 +08:00
}
public void OnClickGetYzmBtn()
{
}
public void OnClickLoginBtn()
{
2024-11-25 10:54:30 +08:00
Login();
2024-11-25 10:18:49 +08:00
}
2024-11-25 10:54:30 +08:00
//<2F><>¼<EFBFBD>߼<EFBFBD>
public async void Login()
2024-11-25 10:18:49 +08:00
{
2024-12-11 11:14:47 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> body
2024-11-25 10:54:30 +08:00
auth_login loginBody = new auth_login
{
2024-12-11 11:14:47 +08:00
grantType = "password",
clientId = "e5cd7e4891bf95d1d19206ce24a7b32e",
userType = "company_user",
username = "13006065371",
password = "YYL5371!",
phonenumber = "",
smsCode = ""
2024-11-25 10:54:30 +08:00
};
2024-12-26 03:46:07 +08:00
image.gameObject.SetActive (true);
2024-12-11 11:14:47 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-11 21:28:05 +08:00
Debug.Log("<22><>½<EFBFBD><C2BD><EFBFBD><EFBFBD>"+ JsonUtility.ToJson(loginBody));
2024-11-25 10:54:30 +08:00
string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(loginBody));
Debug.Log("<22><>¼" + response);
2024-11-25 10:54:30 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
2024-11-29 20:05:55 +08:00
loginResponse serverData = JsonConvert.DeserializeObject<loginResponse>(response);
2024-12-11 11:14:47 +08:00
// <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>Ӧ<EFBFBD><D3A6><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><E6B5BD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GlobalData.ServerData = serverData;
// <20><>ӡ access_token
2024-11-25 10:54:30 +08:00
Debug.Log(serverData.data.access_token);
2024-12-25 22:49:02 +08:00
2024-12-23 11:42:24 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD>Ա<EFBFBD>˺ž<CBBA><C5BE><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-25 22:10:20 +08:00
//if (loginBody.userType == "company_user")
2024-12-25 22:49:02 +08:00
if(loginBody.username == id.text && loginBody.password == pwd.text)
{
SceneManager.LoadScene(1);
}
2024-12-26 03:46:07 +08:00
else if(id.text == "13051628292" && pwd.text == "ZF16c788632")
2024-12-25 22:49:02 +08:00
{
2024-12-27 23:12:22 +08:00
//SceneManager.LoadScene("yhj");
2024-12-25 22:49:02 +08:00
ReadRoom.instance.head();
}
2024-12-26 03:46:07 +08:00
else
{
SceneManager.LoadScene("Tmap 1");
}
2024-12-23 11:42:24 +08:00
2024-12-25 22:10:20 +08:00
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺ž<CBBA><C5BE><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>뷿<EFBFBD><EBB7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//if (loginBody.userType == "Player")
2024-12-25 22:49:02 +08:00
// SceneManager.LoadScene(5);
2024-12-23 11:42:24 +08:00
2024-12-25 22:49:02 +08:00
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
//ReadRoom.instance.head();
2024-12-23 11:42:24 +08:00
2024-11-25 10:18:49 +08:00
}
}