diff --git a/meng_yao/Assets/Scenes/loading.unity b/meng_yao/Assets/Scenes/loading.unity index 66b544172..37df1f0e5 100644 --- a/meng_yao/Assets/Scenes/loading.unity +++ b/meng_yao/Assets/Scenes/loading.unity @@ -1105,6 +1105,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b1b99ebb1bd230344b4f56185c7f21b2, type: 3} m_Name: m_EditorClassIdentifier: + loading_Jiekou: {fileID: 1348751389} sceneslider: {fileID: 2057344806} logo_inbtn: {fileID: 603807337} loadDuration: 5 @@ -1219,6 +1220,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f8a0d55335aa2244abba9eff5c8cbe29, type: 3} m_Name: m_EditorClassIdentifier: + _realNameAuthentication: {fileID: 0} + login: {fileID: 0} + logout: {fileID: 0} + sendCode: {fileID: 0} + checkCode: {fileID: 0} + register: {fileID: 0} --- !u!1 &1352207951 GameObject: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/script/scene_loading/Logo_in.cs b/meng_yao/Assets/script/scene_loading/Logo_in.cs index 9ea026ca2..8b3b0d270 100644 --- a/meng_yao/Assets/script/scene_loading/Logo_in.cs +++ b/meng_yao/Assets/script/scene_loading/Logo_in.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using System.Net.NetworkInformation; +using Newtonsoft.Json; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; @@ -11,6 +12,7 @@ using UnityEngine.UI; public class Logo_in : mount { + public loading_jiekou loading_Jiekou; public Slider sceneslider; public Button logo_inbtn; @@ -96,6 +98,23 @@ public class Logo_in : mount GameObject gameObject = add_pop_up(true);//生成弹窗母体 List gameObjects = gameObject.GetComponent().updateUI(boxTypes, "注册");//测试输入框回调处理 + + gameObjects[3].GetComponent().register_click( + async (BoxType boxType, int type) => //注册确定或取消 + { + if (type == 0) //发送验证码按钮 + { + bool response = await loading_Jiekou.SendCode(boxTypes[0].content,1); + if (response) + { + Promptmgr.Instance.PromptBubble("发送成功"); + } + else + { + Promptmgr.Instance.PromptBubble("发送失败"); + } + } + }); gameObjects[4].GetComponent().register_click( async (BoxType boxType, int type) => //注册确定或取消 { @@ -106,8 +125,25 @@ public class Logo_in : mount } else if (type == 1) //确认注册并登录并进行实名认证 { - Real_name_screen(); + + RegisterResponse response = await loading_Jiekou.Register(boxTypes[0].content, boxTypes[1].content, boxTypes[2].content, boxTypes[3].content); + Debug.Log(response.message); gameObject.GetComponent().destroy(); + + //这里验证码校验有问题,以及账号校验还没做 + //bool succefful =await loading_Jiekou.CheckCode(boxTypes[0].content, 1, boxTypes[3].content); + //if (succefful) + //{ + // RegisterResponse response = await loading_Jiekou.Register(boxTypes[0].content, boxTypes[1].content, boxTypes[2].content, boxTypes[3].content); + // Debug.Log(response.message); + // gameObject.GetComponent().destroy(); + //} + //else + //{ + + //} + // Real_name_screen(); + } }); } @@ -131,6 +167,21 @@ public class Logo_in : mount } else if (type == 1) { + string response = await loading_Jiekou.Login("app", boxTypes[0].content, boxTypes[1].content, "password"); + loginResponse apifox = JsonConvert.DeserializeObject(response); + Debug.Log(response); + + if (apifox.code == 200) + { + gameObject.SetActive(false); + Promptmgr.Instance.PromptBubble("登录成功"); + sceneslider.gameObject.SetActive(true); + StartCoroutine(jiaLoading()); + } + else + { + Debug.Log(apifox.message); + } //这里调用登录方法 } @@ -144,7 +195,7 @@ public class Logo_in : mount boxTypes.Add(new BoxType { Name = "account_number", textName = " 手机号", prompt = "请输入手机号", Type = 0, is_required = true }); boxTypes.Add(new BoxType { Name = "verification_code", textName = " 验证码", prompt = "请输入验证码", Type = 1,nametext2 = "发送",is_required = true }); boxTypes.Add(new BoxType { Name = "sumbit", prompt = "密码登录", Type = 11,is_required = true }); - boxTypes.Add(new BoxType { Name = "submit", textName = " 取消确定 ",prompt = "取消", Type = 5 }); + boxTypes.Add(new BoxType { Name = "submit", textName = " 取消确定 ",prompt = "注册", Type = 5 }); GameObject gameObject = add_pop_up(true);//生成弹窗母体 List gameObjects = gameObject.GetComponent().updateUI(boxTypes, "登录");//测试输入框回调处理 @@ -161,13 +212,22 @@ public class Logo_in : mount { if (type == 0) { + bool response =await loading_Jiekou.SendCode(boxTypes[0].content); + if (response) + { + Promptmgr.Instance.PromptBubble("发送成功"); + } + else + { + Promptmgr.Instance.PromptBubble("发送失败"); + } //这里调用发送验证码的接口 Debug.Log("发送验证码"); } }); - gameObjects[2].GetComponent().register_click(async (BoxType boxType, int type) =>//登录确定或取消 + gameObjects[2].GetComponent().register_click(async (BoxType boxType, int type) =>//密码登录界面 { if (type == 1) { @@ -175,7 +235,7 @@ public class Logo_in : mount gameObject.GetComponent().destroy(); } }); - gameObjects[3].GetComponent().register_click(async (BoxType boxType, int type) =>//登录确定或取消 + gameObjects[3].GetComponent().register_click(async (BoxType boxType, int type) =>//选择注册还是登录 { if (type == 0)//注册 { @@ -185,35 +245,22 @@ public class Logo_in : mount } else if (type == 1)//登录 { - //Login login = new Login(); - //login.Phone = boxTypes[0].content; - //Debug.Log(boxTypes[0].content); - ////register.Code = boxTypes[0].content; - //string jsonString = JsonUtility.ToJson(login); - //string response = await web.SendRequest(web.URL+"/Player/Login", "POST", jsonString); - //Debug.Log(response); - - - //Rootobject root = JsonUtility.FromJson(response); - - - //if (root.ErrorMessage=="" && boxTypes[0].content!= "") - //{ - // gameObject.SetActive(false); - // Promptmgr.Instance.PromptBubble("登录成功"); - // isLoading = true; - //} - //else - //{ - // Promptmgr.Instance.PromptBubble("登录失败,请先注册"); - //} + string response = await loading_Jiekou.Login("app", boxTypes[0].content, boxTypes[1].content, "code"); + loginResponse apifox = JsonConvert.DeserializeObject(response); + Debug.Log(response); - - gameObject.SetActive(false); - Promptmgr.Instance.PromptBubble("登录成功"); - sceneslider.gameObject.SetActive(true); - StartCoroutine(jiaLoading()); + if (apifox.code == 200) + { + gameObject.SetActive(false); + Promptmgr.Instance.PromptBubble("登录成功"); + sceneslider.gameObject.SetActive(true); + StartCoroutine(jiaLoading()); + } + else + { + Promptmgr.Instance.PromptBubble(apifox.message); + } } }); diff --git a/meng_yao/Assets/script/scene_loading/loading_jiekou.cs b/meng_yao/Assets/script/scene_loading/loading_jiekou.cs index 83e727f17..8d2421e69 100644 --- a/meng_yao/Assets/script/scene_loading/loading_jiekou.cs +++ b/meng_yao/Assets/script/scene_loading/loading_jiekou.cs @@ -32,11 +32,12 @@ public class loading_jiekou : MonoBehaviour loginBody.username = username; loginBody.password = password; loginBody.type = type; + string response = await login.Login(loginBody); - return await login.Login(loginBody); + return response; } - public async Task SendCode(string account,int scene)//发送验证码 + public async Task SendCode(string account,int scene=0)//发送验证码 { sendCode = new sendCode(); SendCodeBody sendCodeBody = new SendCodeBody();