|
@@ -1,6 +1,5 @@
|
|
|
using Newtonsoft.Json;
|
|
|
using System.Collections.Generic;
|
|
|
-using System.Net.Mail;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.UIElements;
|
|
|
|
|
@@ -17,7 +16,7 @@ public class ResetUIController : MonoBehaviour
|
|
|
private Label message, errMsg;
|
|
|
private TextField email, mobile, verification, password;
|
|
|
private Button submit, cancel;
|
|
|
- private int condition = 0; // 0: 中文初始, 1: 其他语言初始, 2: 输入验证码和新的密码
|
|
|
+ private SceneCondition sceneCondition = SceneCondition.ChineseInitial;
|
|
|
private Dictionary<string, string> errorMessageDict = new();
|
|
|
private string errorText = string.Empty; // 错误信息汇总
|
|
|
void OnEnable()
|
|
@@ -45,7 +44,7 @@ public class ResetUIController : MonoBehaviour
|
|
|
// 初始化语言和显示设定
|
|
|
void InitSetting()
|
|
|
{
|
|
|
- // 设置 shopping UI界面里面label和按键的语言显示
|
|
|
+ // 设置 reset UI界面里面label和按键的语言显示
|
|
|
string textValue = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "resetUI", "button", "submit", EnviromentSetting.languageCode });
|
|
|
submit.text = textValue;
|
|
|
textValue = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "resetUI", "button", "cancel", EnviromentSetting.languageCode });
|
|
@@ -74,13 +73,13 @@ public class ResetUIController : MonoBehaviour
|
|
|
|
|
|
if (EnviromentSetting.languageCode == "zh-cn")
|
|
|
{
|
|
|
- condition = 0;
|
|
|
+ sceneCondition = SceneCondition.ChineseInitial;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- condition = 1;
|
|
|
+ sceneCondition = SceneCondition.OtherLanguageInitial;
|
|
|
}
|
|
|
- ConditionSetting(condition);
|
|
|
+ ConditionSetting(sceneCondition.GetHashCode());
|
|
|
}
|
|
|
|
|
|
// 根据condition的值来显示不同的UI
|
|
@@ -138,12 +137,12 @@ public class ResetUIController : MonoBehaviour
|
|
|
|
|
|
void SubmitClick()
|
|
|
{
|
|
|
- if (condition <= 1)
|
|
|
+ if (sceneCondition.GetHashCode() <= 1)
|
|
|
{
|
|
|
// 申请验证码阶段
|
|
|
RequestVerificationCodePost();
|
|
|
}
|
|
|
- else if (condition ==2)
|
|
|
+ else if (sceneCondition.GetHashCode() == 2)
|
|
|
{
|
|
|
// 输入验证码阶段和输入新密码阶段
|
|
|
NewPassowrdRequest();
|
|
@@ -181,8 +180,8 @@ public class ResetUIController : MonoBehaviour
|
|
|
if (data["message"] == "verification sent")
|
|
|
{
|
|
|
// 发送验证码成功
|
|
|
- condition = 2;
|
|
|
- ConditionSetting(condition);
|
|
|
+ sceneCondition = SceneCondition.InputVerificationCodeAndNewPassword;
|
|
|
+ ConditionSetting(sceneCondition.GetHashCode());
|
|
|
}
|
|
|
}
|
|
|
else if (data != null && data["status"] == "error")
|
|
@@ -253,7 +252,7 @@ public class ResetUIController : MonoBehaviour
|
|
|
|
|
|
void FormatCheck()
|
|
|
{
|
|
|
- switch (condition)
|
|
|
+ switch (sceneCondition.GetHashCode())
|
|
|
{
|
|
|
case 0:
|
|
|
{
|
|
@@ -269,7 +268,7 @@ public class ResetUIController : MonoBehaviour
|
|
|
}
|
|
|
case 1:
|
|
|
{
|
|
|
- if (email.value != "" && IsValidEmail(email.text))
|
|
|
+ if (email.value != "" && GameTool.IsValidEmail(email.text))
|
|
|
{
|
|
|
submit.SetEnabled(true);
|
|
|
}
|
|
@@ -281,7 +280,7 @@ public class ResetUIController : MonoBehaviour
|
|
|
}
|
|
|
case 2:
|
|
|
{
|
|
|
- if (verification.value != "" && password.text.Length>=8)
|
|
|
+ if (verification.value != "" && password.text.Length >= 8)
|
|
|
{
|
|
|
submit.SetEnabled(true);
|
|
|
}
|
|
@@ -293,20 +292,12 @@ public class ResetUIController : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- #region 格式验证区
|
|
|
- // email 格式检测
|
|
|
- private bool IsValidEmail(string email)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- var addr = new MailAddress(email);
|
|
|
- return addr.Address == email;
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion
|
|
|
+public enum SceneCondition
|
|
|
+{
|
|
|
+ // 0: 中文初始, 1: 其他语言初始, 2: 输入验证码和新的密码
|
|
|
+ ChineseInitial = 0,
|
|
|
+ OtherLanguageInitial = 1,
|
|
|
+ InputVerificationCodeAndNewPassword = 2,
|
|
|
}
|