Cute_demon_attacks/meng_yao/Assets/script/ConnactServer/Logo_in.cs
舒荣森 a114da04ba add
2024-10-30 19:42:59 +08:00

84 lines
2.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using UnityEngine;
using UnityEngine.UI;
public struct Login
{
public string phonenumble;
}
public class Logo_in : mount
{
public Slider sceneslider;
public Button logo_inbtn;
// Start is called before the first frame update
void Start()
{
//sceneslider.gameObject.SetActive(false);
//logo_inbtn.onClick.AddListener(ShowLogoin);
login_in_screen();
}
void ShowLogoin()
{
login_in_screen();
}
public void login_in_screen()//登录界面
{
List<BoxType> boxTypes = new List<BoxType>();
boxTypes.Add(new BoxType { Name = "account_number", textName = " 手机号", prompt = "请输入手机号", Type = 1, is_required = true });
boxTypes.Add(new BoxType { Name = "verification_code", textName = " 验证码", prompt = "请输入验证码", Type = 0, is_required = true });
boxTypes.Add(new BoxType { Name = "submit", textName = " 取消确定 ", Type = 5 });
GameObject gameObject = add_pop_up(true);//生成弹窗母体
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "登录");//测试输入框回调处理
//gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click((BoxType boxType, int type) =>//手机号获取验证码点击
//{
// if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content))
// {
// Promptmgr.Instance.PromptBubble("请不要" + boxType.textName + "为空");
// return;
// }
// Debug.Log("获取验证码");
//});
gameObjects[2].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
{
if (type == 0)//注册
{
Login login = new Login();
login.phonenumble = boxTypes[0].prompt;
//register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(login);
string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST", jsonString);
Debug.Log(response);
}
else if (type == 1)//登录
{
Login login = new Login();
login.phonenumble = boxTypes[0].prompt;
//register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(login);
string response = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString);
Debug.Log(response);
}
});
}
// Update is called once per frame
void Update()
{
}
}