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;
|
|
|
|
|
using UnityEditor.PackageManager;
|
2024-11-25 10:18:49 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
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-11-25 10:54:30 +08:00
|
|
|
|
auth_login loginBody = new auth_login
|
|
|
|
|
{
|
|
|
|
|
clientId = id.text,
|
|
|
|
|
grantType = pwd.text
|
|
|
|
|
};
|
|
|
|
|
//Debug.Log(JsonUtility.ToJson(loginBody));
|
|
|
|
|
string response = await web.SendRequest(web.URL + "/auth/login", "POST", JsonUtility.ToJson(loginBody));
|
|
|
|
|
Debug.Log("<22><>¼" + response);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
server serverData = JsonConvert.DeserializeObject<server>(response);
|
|
|
|
|
//token = serverData.data.access_token;
|
|
|
|
|
Debug.Log(serverData.data.access_token);
|
2024-11-25 10:18:49 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-25 10:54:30 +08:00
|
|
|
|
|
2024-11-25 10:18:49 +08:00
|
|
|
|
}
|