This commit is contained in:
舒荣森 2024-10-30 01:06:46 +08:00
parent 45899c03d0
commit 088b92a5b1
2 changed files with 14 additions and 32 deletions

View File

@ -1,7 +1,12 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
[System.Serializable]
public struct Register
{
public string Phone;
public string Code;
}
public class mount : MonoBehaviour public class mount : MonoBehaviour
{ {
// Start is called before the first frame update // Start is called before the first frame update
@ -29,11 +34,11 @@ public class mount : MonoBehaviour
boxTypes[1] = new BoxType { Name = "verification_code", textName = " 验证码 ", prompt = "请输入验证码", Type = 0, is_required = true }; boxTypes[1] = new BoxType { Name = "verification_code", textName = " 验证码 ", prompt = "请输入验证码", Type = 0, is_required = true };
boxTypes[2] = new BoxType { Name = "submit", textName = " 取消确定 ",Type = 2}; boxTypes[2] = new BoxType { Name = "submit", textName = " 取消确定 ",Type = 2};
GameObject gameObject = add_pop_up(); GameObject gameObject = add_pop_up();
//测试输入框回调处理 List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "注册");//测试输入框回调处理
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) =>//手机号获取验证码点击 gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click((BoxType boxType,int type) =>//手机号获取验证码点击
{ {
if (string.IsNullOrWhiteSpace(boxType.content)) { if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content)) {
Promptmgr.Instance.PromptBubble("请不要" + boxType.textName + "为空"); Promptmgr.Instance.PromptBubble("请不要" + boxType.textName + "为空");
return; } return; }
Debug.Log("获取验证码"); Debug.Log("获取验证码");
@ -44,7 +49,11 @@ public class mount : MonoBehaviour
Destroy(gameObject); Destroy(gameObject);
} }
else if (type == 1){ else if (type == 1){
string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST"); Register register = new Register();
register.Phone = boxTypes[0].content;
register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(register);
string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST", jsonString);
Debug.Log(response); Debug.Log(response);
} }
}); });

View File

@ -52,31 +52,4 @@ public class input_box_pop_up_window : MonoBehaviour
return gameObjects; return gameObjects;
} }
public void onClikeAsync()//点击事件
{
bool is_ret = true;
foreach (var boxType in boxTypes)
{
switch (boxType.Type)
{
case 0:
if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content))
{
is_ret = false;
Promptmgr.Instance.PromptBubble("请不要"+boxType.textName+"为空");
}
break;
case 1:
if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content))
{
is_ret = false;
Promptmgr.Instance.PromptBubble("请不要" + boxType.textName + "为空");
}
break;
}
}
if (is_ret) OnClike.Invoke(boxTypes);
}
} }