2024-11-11 19:48:32 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using UnityEngine.Networking;
|
2024-11-13 23:15:46 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2024-11-11 19:48:32 +08:00
|
|
|
|
using static LoginAndGetToken;
|
2024-11-15 23:31:54 +08:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-11-11 19:48:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-25 23:58:19 +08:00
|
|
|
|
public class logoPanel : Base
|
2024-11-11 19:48:32 +08:00
|
|
|
|
{
|
2024-11-11 21:03:06 +08:00
|
|
|
|
public InputField userNameField;
|
|
|
|
|
public InputField passwordField;
|
|
|
|
|
public InputField verifyCodeField;
|
2024-11-13 10:28:08 +08:00
|
|
|
|
public InputField mmField;
|
|
|
|
|
public InputField qrmmField;
|
|
|
|
|
public InputField yqmField;
|
2024-11-15 23:31:54 +08:00
|
|
|
|
|
2024-11-11 19:48:32 +08:00
|
|
|
|
public Button pwdBtn;
|
|
|
|
|
public Button yzmBtn;
|
2024-11-12 11:06:38 +08:00
|
|
|
|
public Image regImg;
|
2024-11-15 23:31:54 +08:00
|
|
|
|
|
2024-11-11 19:48:32 +08:00
|
|
|
|
public GameObject yzm;
|
|
|
|
|
public GameObject mm;
|
2024-11-12 11:06:38 +08:00
|
|
|
|
public GameObject qrmm;
|
|
|
|
|
public GameObject yqm;
|
|
|
|
|
|
|
|
|
|
public GameObject logBtn;
|
2024-11-11 19:48:32 +08:00
|
|
|
|
public Button loginBtn;
|
2024-11-12 11:06:38 +08:00
|
|
|
|
public GameObject regbtn;
|
2024-11-11 19:48:32 +08:00
|
|
|
|
public Button rigistBtn;
|
2024-11-12 11:06:38 +08:00
|
|
|
|
|
2024-11-13 10:28:08 +08:00
|
|
|
|
public Button rigBtn;
|
|
|
|
|
|
2024-11-11 19:48:32 +08:00
|
|
|
|
public delegate void TokenReceivedDelegate(string token);
|
|
|
|
|
public static event TokenReceivedDelegate OnTokenReceived;
|
|
|
|
|
|
2024-11-16 16:06:26 +08:00
|
|
|
|
private bool isOpenYzm = true;
|
|
|
|
|
private bool isOpenPwd = false;
|
|
|
|
|
|
2024-11-11 19:48:32 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
yzmBtn.onClick.AddListener(OnClickYzmBtn);
|
|
|
|
|
pwdBtn.onClick.AddListener(OnClickPwdBtn);
|
|
|
|
|
rigistBtn.onClick.AddListener(OnClickRigistBtn);
|
2024-11-13 10:28:08 +08:00
|
|
|
|
rigBtn.onClick.AddListener(() => StartCoroutine(OnClickRegBtn()));
|
2024-11-11 19:48:32 +08:00
|
|
|
|
}
|
2024-11-15 23:31:54 +08:00
|
|
|
|
|
2024-11-13 10:28:08 +08:00
|
|
|
|
public IEnumerator OnClickRegBtn()
|
|
|
|
|
{
|
|
|
|
|
loginbody body = new loginbody
|
|
|
|
|
{
|
|
|
|
|
userName = userNameField.text,
|
|
|
|
|
password = passwordField.text,
|
|
|
|
|
verifyCode = int.Parse(verifyCodeField.text)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string jsonBody = JsonUtility.ToJson(body);
|
|
|
|
|
using (UnityWebRequest webRequest = new UnityWebRequest("http://121.40.42.41:8080/snail/user/register", "POST"))
|
|
|
|
|
{
|
|
|
|
|
webRequest.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(jsonBody));
|
|
|
|
|
webRequest.uploadHandler.contentType = "application/json";
|
|
|
|
|
webRequest.downloadHandler = new DownloadHandlerBuffer();
|
|
|
|
|
|
|
|
|
|
yield return webRequest.SendWebRequest();
|
|
|
|
|
|
|
|
|
|
if (webRequest.result == UnityWebRequest.Result.Success)
|
|
|
|
|
{
|
|
|
|
|
string registerResponse = webRequest.downloadHandler.text;
|
|
|
|
|
Debug.Log("Register Response: " + registerResponse);
|
2024-11-13 23:15:46 +08:00
|
|
|
|
|
|
|
|
|
SceneManager.LoadScene(1);
|
2024-11-15 23:31:54 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-11-13 10:28:08 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("ע<><D7A2>ʧ<EFBFBD>ܣ<EFBFBD> " + webRequest.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-15 23:31:54 +08:00
|
|
|
|
public async void OnClickLoginBtnAsync()
|
|
|
|
|
{
|
2024-11-25 23:58:19 +08:00
|
|
|
|
|
|
|
|
|
|
2024-11-27 01:48:52 +08:00
|
|
|
|
/* loginbody body = new loginbody
|
|
|
|
|
{
|
|
|
|
|
userName = userNameField.text,
|
|
|
|
|
password = passwordField.text,
|
|
|
|
|
verifyCode = int.Parse(verifyCodeField.text)
|
|
|
|
|
};*/
|
2024-11-16 16:01:27 +08:00
|
|
|
|
loginbody body = new loginbody
|
|
|
|
|
{
|
2024-11-27 01:48:52 +08:00
|
|
|
|
userName = "15151658596",
|
|
|
|
|
password = "123456",
|
|
|
|
|
verifyCode = 111111
|
2024-11-16 16:01:27 +08:00
|
|
|
|
};
|
2024-11-15 23:31:54 +08:00
|
|
|
|
string loginResponse = await web.SendRequest(web.URL+"/snail/user/login", "POST", JsonUtility.ToJson(body));
|
|
|
|
|
ServerResponse response = JsonUtility.FromJson<ServerResponse>(loginResponse);
|
|
|
|
|
if (response != null && response.code == 200 && response.data != null)
|
|
|
|
|
{
|
|
|
|
|
Global.global.serverResponse = response;
|
|
|
|
|
SceneManager.LoadScene(1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-27 01:48:52 +08:00
|
|
|
|
//Debug.Log(response.code);
|
2024-11-15 23:31:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 19:48:32 +08:00
|
|
|
|
private void OnClickRigistBtn()
|
|
|
|
|
{
|
2024-11-12 11:06:38 +08:00
|
|
|
|
yzm.gameObject.SetActive(true);
|
|
|
|
|
mm.gameObject.SetActive(true);
|
|
|
|
|
qrmm.gameObject.SetActive(true);
|
|
|
|
|
yqm.gameObject.SetActive(true);
|
|
|
|
|
logBtn.gameObject.SetActive(false);
|
|
|
|
|
regbtn.gameObject.SetActive(true);
|
|
|
|
|
regImg.gameObject.SetActive(true);
|
|
|
|
|
pwdBtn.gameObject.SetActive(false);
|
|
|
|
|
yzmBtn.gameObject.SetActive(false);
|
2024-11-11 19:48:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnClickYzmBtn()
|
|
|
|
|
{
|
2024-11-16 16:06:26 +08:00
|
|
|
|
if(isOpenYzm)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-11 19:48:32 +08:00
|
|
|
|
pwdBtn.transform.position -= new Vector3(0f, 26.4f, 0f);
|
|
|
|
|
yzmBtn.transform.position += new Vector3(0f, 26.4f, 0f);
|
|
|
|
|
yzm.gameObject.SetActive(true);
|
|
|
|
|
mm.gameObject.SetActive(false);
|
2024-11-16 16:06:26 +08:00
|
|
|
|
isOpenYzm = true;
|
|
|
|
|
isOpenPwd = false;
|
2024-11-11 19:48:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnClickPwdBtn()
|
|
|
|
|
{
|
2024-11-16 16:06:26 +08:00
|
|
|
|
if (isOpenPwd)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-11 19:48:32 +08:00
|
|
|
|
pwdBtn.transform.position += new Vector3(0f, 26.4f, 0f);
|
|
|
|
|
yzmBtn.transform.position -= new Vector3(0f, 26.4f, 0f);
|
|
|
|
|
yzm.gameObject.SetActive(false);
|
|
|
|
|
mm.gameObject.SetActive(true);
|
2024-11-16 16:06:26 +08:00
|
|
|
|
isOpenPwd = true;
|
|
|
|
|
isOpenYzm = false;
|
2024-11-11 19:48:32 +08:00
|
|
|
|
}
|
2024-11-12 11:06:38 +08:00
|
|
|
|
|
2024-11-15 23:31:54 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ݽṹ
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class ServerResponse
|
|
|
|
|
{
|
|
|
|
|
public int code;
|
|
|
|
|
public string message;
|
|
|
|
|
public Data data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class Data
|
|
|
|
|
{
|
|
|
|
|
public int userId;
|
|
|
|
|
public string userName;
|
|
|
|
|
public string token;
|
|
|
|
|
public string nickName;
|
|
|
|
|
public string headImg;
|
|
|
|
|
public string gender;
|
|
|
|
|
public string birthday;
|
|
|
|
|
public int? voluteCoin;
|
|
|
|
|
public int? beansCoin;
|
|
|
|
|
public int? ichorCoin;
|
|
|
|
|
public string idCard;
|
|
|
|
|
public string inviteCodeMy;
|
|
|
|
|
public string inviteCodeBind;
|
|
|
|
|
public string bindTime;
|
|
|
|
|
public string station;
|
|
|
|
|
public string cuteNo;
|
|
|
|
|
public string memberTime;
|
|
|
|
|
public bool? isMember;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-12 11:06:38 +08:00
|
|
|
|
|