|
|
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.UI;
|
|
|
using UnityEngine.SceneManagement;
|
|
|
+using UnityEngine.Networking;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using DG.Tweening;
|
|
|
using Newtonsoft.Json;
|
|
|
@@ -18,9 +19,11 @@ public class LoginMgr : MonoBehaviour
|
|
|
[SerializeField] Sprite[] loginModeSprites;
|
|
|
[SerializeField] GameObject loginInUser;
|
|
|
[SerializeField] GameObject loginInPWD;
|
|
|
+ [SerializeField] GameObject loginInCaptcha1;
|
|
|
[SerializeField] GameObject loginInPhone;
|
|
|
[SerializeField] GameObject loginInCode;
|
|
|
[SerializeField] GameObject loginValidTime;
|
|
|
+ [SerializeField] GameObject loginInCaptcha2;
|
|
|
[SerializeField] GameObject registerInUser;
|
|
|
[SerializeField] GameObject registerInPWD1;
|
|
|
[SerializeField] GameObject registerInPWD2;
|
|
|
@@ -28,6 +31,7 @@ public class LoginMgr : MonoBehaviour
|
|
|
[SerializeField] GameObject registerInGender;
|
|
|
[SerializeField] Text loginTip;
|
|
|
[SerializeField] Text registerTip;
|
|
|
+ [SerializeField] Transform agreementTF;
|
|
|
|
|
|
public static UserInfo myUserInfo = new UserInfo();
|
|
|
static int userInfo_version = 1000;
|
|
|
@@ -37,6 +41,15 @@ public class LoginMgr : MonoBehaviour
|
|
|
void Awake()
|
|
|
{
|
|
|
TextAutoLanguage.Init();
|
|
|
+
|
|
|
+ agreementTF.Find("TextA").GetComponent<Button>().onClick.AddListener(delegate() {
|
|
|
+ GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
|
|
|
+ o.GetComponent<AgreementView>().EnterUserAgreement();
|
|
|
+ });
|
|
|
+ agreementTF.Find("TextB").GetComponent<Button>().onClick.AddListener(delegate() {
|
|
|
+ GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
|
|
|
+ o.GetComponent<AgreementView>().EnterPrivacyAgreement();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
void Start()
|
|
|
@@ -55,6 +68,35 @@ public class LoginMgr : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ IEnumerator GetCaptcha(CaptchaType type)
|
|
|
+ {
|
|
|
+ int code = UnityEngine.Random.Range(1000, 10000);
|
|
|
+ UnityWebRequest uwr = new UnityWebRequest(CommonConfig.businessServerURI + "/api/createCaptcha?code=" + code, UnityWebRequest.kHttpVerbGET);
|
|
|
+ uwr.downloadHandler = new DownloadHandlerTexture();
|
|
|
+ yield return uwr.SendWebRequest();
|
|
|
+ Texture2D texture = DownloadHandlerTexture.GetContent(uwr);
|
|
|
+ Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
|
|
+ switch (type) {
|
|
|
+ case CaptchaType.Login:
|
|
|
+ loginInCaptcha1.transform.Find("CodeImage").GetComponent<Image>().sprite = sprite;
|
|
|
+ captcha_Login = code;
|
|
|
+ break;
|
|
|
+ case CaptchaType.LoginPhone:
|
|
|
+ loginInCaptcha2.transform.Find("CodeImage").GetComponent<Image>().sprite = sprite;
|
|
|
+ captcha_LoginPhone = code;
|
|
|
+ break;
|
|
|
+ case CaptchaType.Register:
|
|
|
+ captcha_Register = code;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ enum CaptchaType {
|
|
|
+ Login, LoginPhone, Register
|
|
|
+ }
|
|
|
+ int captcha_Login = -222222222;
|
|
|
+ int captcha_LoginPhone = -222222222;
|
|
|
+ int captcha_Register = -222222222;
|
|
|
+
|
|
|
InputField GetInputField(GameObject inputNode)
|
|
|
{
|
|
|
return inputNode.transform.Find("InputField").GetComponent<InputField>();
|
|
|
@@ -68,9 +110,14 @@ public class LoginMgr : MonoBehaviour
|
|
|
loginMode2.GetComponent<Image>().sprite = loginModeSprites[0];
|
|
|
loginInUser.SetActive(true);
|
|
|
loginInPWD.SetActive(true);
|
|
|
+ loginInCaptcha1.SetActive(true);
|
|
|
loginInPhone.SetActive(false);
|
|
|
loginInCode.SetActive(false);
|
|
|
loginValidTime.SetActive(false);
|
|
|
+ loginInCaptcha2.SetActive(false);
|
|
|
+ if (captcha_Login < 0) {
|
|
|
+ StartCoroutine(GetCaptcha(CaptchaType.Login));
|
|
|
+ }
|
|
|
}
|
|
|
else if (loginMode == 2)
|
|
|
{
|
|
|
@@ -78,9 +125,14 @@ public class LoginMgr : MonoBehaviour
|
|
|
loginMode2.GetComponent<Image>().sprite = loginModeSprites[1];
|
|
|
loginInUser.SetActive(false);
|
|
|
loginInPWD.SetActive(false);
|
|
|
+ loginInCaptcha1.SetActive(false);
|
|
|
loginInPhone.SetActive(true);
|
|
|
loginInCode.SetActive(true);
|
|
|
loginValidTime.SetActive(true);
|
|
|
+ loginInCaptcha2.SetActive(true);
|
|
|
+ if (captcha_LoginPhone < 0) {
|
|
|
+ StartCoroutine(GetCaptcha(CaptchaType.LoginPhone));
|
|
|
+ }
|
|
|
}
|
|
|
loginTip.GetComponent<TextAutoLanguage>().SetText(0);
|
|
|
}
|
|
|
@@ -106,6 +158,14 @@ public class LoginMgr : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
public void login() {
|
|
|
+ if (loginMode == 1) {
|
|
|
+ LoginNormal();
|
|
|
+ } else if (loginMode == 2) {
|
|
|
+ LoginByPhone();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void LoginNormal() {
|
|
|
InputField user = GetInputField(loginInUser);
|
|
|
if (user.text.Trim().Length == 0) {
|
|
|
loginTip.color = Color.yellow;
|
|
|
@@ -118,6 +178,12 @@ public class LoginMgr : MonoBehaviour
|
|
|
loginTip.GetComponent<TextAutoLanguage>().SetText(42);
|
|
|
return;
|
|
|
}
|
|
|
+ // InputField captcha = GetInputField(loginInCaptcha1);
|
|
|
+ // if (captcha.text.Trim().Length == 0) {
|
|
|
+ // loginTip.color = Color.yellow;
|
|
|
+ // loginTip.GetComponent<TextAutoLanguage>().SetText(42);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
UserInfos userInfos = GetUserInfos();
|
|
|
foreach (var userInfo in userInfos.list)
|
|
|
{
|
|
|
@@ -140,6 +206,10 @@ public class LoginMgr : MonoBehaviour
|
|
|
loginTip.GetComponent<TextAutoLanguage>().SetText(45);
|
|
|
}
|
|
|
|
|
|
+ void LoginByPhone() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public void Register()
|
|
|
{
|
|
|
InputField user = GetInputField(registerInUser);
|