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;
|
|
|
|
|
|
|
|
|
|
public class LoginPanel : MonoBehaviour
|
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-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-11 11:14:47 +08:00
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|
|
|
|
SceneManager.LoadScene(1);
|
2024-11-25 10:18:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|