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",
|
2024-12-29 11:15:34 +08:00
|
|
|
|
username = "13051628292",//"ZF16c788632",13699802230,13051628292
|
2024-12-28 16:43:12 +08:00
|
|
|
|
password = "YYL5371!"
|
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-12-18 21:31:25 +08:00
|
|
|
|
|
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-28 21:42:16 +08:00
|
|
|
|
if(GlobalData.ServerData.data.isCreater=="Y")
|
2024-12-25 22:49:02 +08:00
|
|
|
|
{
|
2024-12-28 15:48:01 +08:00
|
|
|
|
Debug.LogError(11);
|
|
|
|
|
ReadRoom.instance.isadministrator=true;
|
2024-12-29 10:41:48 +08:00
|
|
|
|
//ReadRoom.instance.adHead();
|
2024-12-28 16:43:12 +08:00
|
|
|
|
SceneManager.LoadScene("yhj");
|
2024-12-25 22:49:02 +08:00
|
|
|
|
}
|
2024-12-29 11:15:34 +08:00
|
|
|
|
else //if(id.text == "13699802230" && pwd.text == "YYL5371!")
|
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-29 11:15:34 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|