From f718d23a262a5a8e1241fdeaeb4153399f95e79d Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 21 四月 2020 09:19:05 +0800
Subject: [PATCH] 20200421
---
HDL_ON/UI/UI1-Login/LoginPageBLL.cs | 289 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 221 insertions(+), 68 deletions(-)
diff --git a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
index 9653896..b3399d7 100644
--- a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
+++ b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using Shared;
+using HDL_ON.Entity;
namespace HDL_ON.UI.UI1Login
{
@@ -35,12 +36,40 @@
if (btnGetVerificationCode.IsSelected)
{
string phoneNumber = etAccount.Text.Trim();
- btnGetVerificationCode.IsSelected = false;
+ if (string.IsNullOrEmpty(phoneNumber))
+ {
+ var tip = new Tip()
+ {
+ Text = Language.StringByID(StringId.PlsEntryPhoneNumber),
+ CloseTime = 3,
+ Direction = AMPopTipDirection.None
+ };
+ tip.Show(bodyView);
+
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ return;
+ }
+ if (!Regex.IsMatch(account, @"^[1]+\d{10}") || (account.Length != 11))
+ {
+ var tip = new Tip()
+ {
+ Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
+ CloseTime = 3,
+ Direction = AMPopTipDirection.None
+ };
+ tip.Show(bodyView);
+
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ return;
+ }
+ btnGetVerificationCode.IsSelected = false ;
btnGetVerificationCode.TextColor = CSS_Color.PromptingColor1;
int time = 60;
new Thread(() =>
{
- while (time < 0)
+ while (time > 0)
{
time--;
Application.RunOnMainThread(() =>
@@ -56,8 +85,61 @@
});
})
{ IsBackground = true }.Start();
- //鑾峰彇楠岃瘉鐮�
- pm.GetPhoneLoginVerCode(phoneNumber);
+ new Thread(() =>
+ {
+ //鑾峰彇楠岃瘉鐮�
+ var result = pm.GetPhoneLoginVerCode(phoneNumber);
+ if (result.StateCode.ToUpper() == "SUCCESS")
+ {
+ }
+ //鐧诲綍澶辫触
+ else
+ {
+ string tipStr = "Sever erorr";
+ switch (result.StateCode.ToUpper())
+ {
+ case "USERNAMEORPWDERROR":
+ tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError);
+ Application.RunOnMainThread(() =>
+ {
+ btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
+ });
+ break;
+ case "ACCOUNTNOEXISTS":
+ tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS);
+ Application.RunOnMainThread(() =>
+ {
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ });
+ break;
+ case "SENDFAIL":
+ tipStr = Language.StringByID(StringId.FailedToSendVerificationCode);
+ Application.RunOnMainThread(() =>
+ {
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ });
+ break;
+ case "Self:Net_Error":
+ tipStr = Language.StringByID(StringId.NetworkAnomaly);
+ break;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ //鎻愮ず鍘熷洜
+ var tip = new Tip()
+ {
+ Text = tipStr,
+ CloseTime = 3,
+ Direction = AMPopTipDirection.None
+ };
+ tip.Show(bodyView);
+ });
+ }
+ })
+ { IsBackground = true }.Start();
}
};
}
@@ -75,11 +157,11 @@
btnEmailLogin.TextSize = CSS_FontSize.TextFontSize;
btnPhoneLogin.TextColor = CSS_Color.MainColor;
btnPhoneLogin.TextSize = CSS_FontSize.EmphasisFontSize_Secondary;
- etAccount.PlaceholderText = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber);
+ etAccount.PlaceholderText = Language.StringByID(StringId.PlsEntryPhoneNumber);
#endregion
#region 鍒囨崲鐧诲綍鏂瑰紡鍙婂浘鏍�
- logintType = 0;
+ loginType = 0;
if (btnAccountIcon.Parent != null)
{
btnAccountIcon.RemoveFromParent();
@@ -102,7 +184,7 @@
#endregion
#region 鍒囨崲鐧诲綍绫诲瀷鍙婂浘鏍�
- logintType = 1;
+ loginType = 1;
if (btnGlobalRoaming.Parent != null)
{
btnGlobalRoaming.RemoveFromParent();
@@ -147,6 +229,7 @@
btnSwitchLoginMode.TextID = StringId.VerificationCodeLogin;
passwordView.AddChidren(btnVisiblePassword);
passwordView.AddChidren(btnDividingLineVertical_PasswordView2);
+ etPassword.PlaceholderText = Language.StringByID(StringId.PlsEntryPassword);
passwordView.AddChidren(btnForgetPassword);
btnPasswordIcon.IsSelected = false;
if (btnGetVerificationCode.Parent != null)
@@ -159,8 +242,13 @@
//楠岃瘉鐮佺櫥褰�
else if (logintMode == 1)
{
+ if (Regex.IsMatch(account, @"^[1]+\d{10}") && (account.Length == 11))
+ {
+ btnGetVerificationCode.IsSelected = true;
+ }
btnSwitchLoginMode.TextID = StringId.PasswordLogin;
passwordView.AddChidren(btnGetVerificationCode);
+ etPassword.PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode);
btnPasswordIcon.IsSelected = true;
if (btnVisiblePassword.Parent != null)
{
@@ -181,7 +269,7 @@
}
/// <summary>
- /// 鏂囨湰妗嗛�変腑浜嬩欢
+ /// 鏂囨湰妗嗙劍鐐瑰彉鍖栦簨浠�
/// </summary>
void LoadPage_SelectionEditText()
{
@@ -197,6 +285,47 @@
{
btnAccountViewBottomLine.BackgroundColor = CSS_Color.DividingLineColor;
btnAccountViewBottomLine.Height = Application.GetRealHeight(1);
+ account = etAccount.Text.Trim();
+ if (account.Length == 0)
+ return;
+ if (loginType == 0)
+ {
+ if (!Regex.IsMatch(account, @"^[1]+\d{10}") || (account.Length != 11))
+ {
+ var tip = new Tip()
+ {
+ Text = Language.StringByID(StringId.PlsEntryCorrectMobilNeumber),
+ CloseTime = 3,
+ Direction = AMPopTipDirection.None
+ };
+ tip.Show(bodyView);
+
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ }
+ else
+ {
+ if (btnGetVerificationCode.Text == Language.StringByID(StringId.GetVerificationCode))
+ {
+ btnGetVerificationCode.IsSelected = true;
+ }
+ }
+ }
+ else
+ {
+ if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+"))
+ {
+ var tip = new Tip()
+ {
+ Text = Language.StringByID(StringId.PlsEntryCorrectEmailAddress),
+ CloseTime = 3,
+ Direction = AMPopTipDirection.None
+ };
+ tip.Show(bodyView);
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ }
+ }
}
};
//褰撶劍鐐瑰湪瀵嗙爜鏂囨湰妗嗘椂锛屾枃鏈搴曠嚎鐐逛寒
@@ -257,9 +386,9 @@
account = etAccount.Text.Trim();
password = etPassword.Text.Trim();
- if (logintType == 0)
+ if (loginType == 0)
{
- if (!Regex.IsMatch(account, @"^[1]+\d{9}"))
+ if (!Regex.IsMatch(account, @"^[1]+\d{10}") && (account.Length == 11))
{
var tip = new Tip()
{
@@ -273,7 +402,7 @@
}
else
{
- if (!Regex.IsMatch(account, "^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$"))
+ if (!Regex.IsMatch(account, "([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,5})+"))
{
var tip = new Tip()
{
@@ -289,7 +418,7 @@
//鍒涘缓鐧诲綍绾跨▼
var loginThread = LoadThread_Login();
waitPage = new Loading();
- new WaitPageMothed().LoadPage_WaitPage(loginThread, bodyView, waitPage);
+ new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
}
};
@@ -342,9 +471,6 @@
Application.RunOnMainThread(() =>
{
- waitPage.RemoveFromParent();
- waitPage = null;
-
//璺宠浆椤甸潰----
MainPage.GoUserPage();
});
@@ -354,6 +480,18 @@
catch (Exception ex)
{
MainPage.Log($"LoginPage : {ex.Message}");
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (waitPage != null)
+ {
+ waitPage.RemoveFromParent();
+ waitPage = null;
+ }
+
+ });
}
})
{ IsBackground = true };
@@ -365,9 +503,18 @@
bool LoadMethod_Login()
{
var result = false;
- //璋冪敤鐧诲綍鎺ュ彛
- var loginResult = pm.LoginByPassword(account, password);
- if (loginResult.StateCode == "SUCCESS")
+ ResponsePack loginResult;
+ if (logintMode == 0)
+ {
+ //璋冪敤鐧诲綍鎺ュ彛
+ loginResult = pm.LoginByPassword(account, password);
+ }
+ else
+ {
+ //璋冪敤鐧诲綍鎺ュ彛
+ loginResult = pm.LoginValidCode(account, password);
+ }
+ if (loginResult.StateCode.ToUpper() == "SUCCESS")
{
var loginDataStr = Newtonsoft.Json.Linq.JObject.FromObject(loginResult.ResponseData);
@@ -375,16 +522,23 @@
MainPage.LoginUser = new UserInfo
{
ID = (int)loginDataStr.GetValue("UserID"),
- MasterID = (int)loginDataStr.GetValue("MainUserID"),
- AccountType = (int)loginDataStr.GetValue("UserType"),
- AccountString = account,
- Password = password,
- LastTime = DateTime.Now,
+ masterID = (int)loginDataStr.GetValue("MainUserID"),
+ accountType = (int)loginDataStr.GetValue("UserType"),
+ accountString = account,
+ password = password,
+ lastTime = DateTime.Now,
SIP_Account = loginDataStr.GetValue("AllVisionRegisterDevUserNameGuid").ToString(),
+ userName = loginDataStr.GetValue("Remark").ToString(),
};
MainPage.LoginUser.SaveUserInfo();
MainPage.Log("鐧诲綍鎴愬姛銆�");
result = true;
+ //鑾峰彇鐢ㄦ埛淇℃伅
+ new Thread(() =>
+ {
+ pm.GetUserInfo();
+ })
+ { IsBackground = true }.Start();
}
//鐧诲綍澶辫触
else
@@ -392,8 +546,32 @@
string tipStr = "Sever erorr";
switch (loginResult.StateCode)
{
+ case "ValidCodeAndPhoneNoEqual":
+ tipStr = Language.StringByID(StringId.VerificationCodeError);
+ Application.RunOnMainThread(() =>
+ {
+ btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
+ });
+ break;
case "USERNAMEORPWDERROR":
tipStr = Language.StringByID(StringId.LoginFailed_AccountOrPasswordError);
+ Application.RunOnMainThread(() =>
+ {
+ btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
+ });
+ break;
+ case "ACCOUNTNOEXISTS":
+ tipStr = Language.StringByID(StringId.ACCOUNTNOEXISTS);
+ Application.RunOnMainThread(() =>
+ {
+ btnAccountViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
+ btnAccountViewBottomLine.Height = Application.GetRealHeight(2);
+ });
+ break;
+ case "NoRecord":
+ tipStr = Language.StringByID(StringId.PlsGetTheVerificationCode);
break;
case "Self:Net_Error":
tipStr = Language.StringByID(StringId.NetworkAnomaly);
@@ -402,6 +580,7 @@
//璐﹀彿鎴栬�呭瘑鐮侀敊璇�
Application.RunOnMainThread(() =>
{
+ waitPage.Hide();
//鎻愮ず鍘熷洜
var tip = new Tip()
{
@@ -410,8 +589,6 @@
Direction = AMPopTipDirection.None
};
tip.Show(bodyView);
- btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
- btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
});
}
return result;
@@ -424,38 +601,16 @@
{
var result = false;
var responsePack = pm.GetHomePager();
- if (responsePack.StateCode == "Success")
- {
- var dataStr = Newtonsoft.Json.Linq.JObject.FromObject(responsePack.ResponseData);
- //娌℃湁浣忓畢
- if (dataStr.GetValue("PageData").ToString() == "[]")
- {
- }
- else
- {
- MainPage.LoginUser.HomeLists = new List<RegionInfoRes>();
- foreach (var jsonData in dataStr.GetValue("PageData"))
- {
- var homeJsonStr = Newtonsoft.Json.Linq.JObject.FromObject(jsonData);
- var home = new RegionInfoRes()
- {
- RegionID = homeJsonStr.GetValue("Id").ToString(),
- RegionName = homeJsonStr.GetValue("RegionName").ToString(),
- Name = homeJsonStr.GetValue("Name").ToString(),
- };
- MainPage.LoginUser.HomeLists.Add(home);
- }
- UserConfig.Instance.CurrentRegion = MainPage.LoginUser.HomeLists[0];
- UserConfig.Instance.SaveUserConfig();
- MainPage.LoginUser.SaveUserInfo();
- }
+
+ if (responsePack == "Success")
+ {
result = true;
}
else
{
var tipStr = "Server erorr";
- switch (responsePack.StateCode)
+ switch (responsePack)
{
case "NoLogin":
tipStr = Language.StringByID(StringId.InvalidLoginCertificate);
@@ -472,7 +627,6 @@
};
tip.Show(bodyView);
});
-
}
return result;
}
@@ -485,22 +639,21 @@
btnRegister.MouseUpEventHandler += (sender, e) =>
{
//鍥炶皟浜嬩欢
- Action<string> callBackAction = (callBackPar_Action) =>
- {
- Application.RunOnMainThread(() =>
- {
- try
- {
- etAccount.Text = callBackPar_Action;
- }
- catch (Exception ex)
- {
- MainPage.Log($"login callBackAction : {ex.Message}");
- }
- });
- };
+ //Action callBackAction = () =>
+ //{
+ // Application.RunOnMainThread(() =>
+ // {
+ // try
+ // {
+ // }
+ // catch (Exception ex)
+ // {
+ // MainPage.Log($"login callBackAction : {ex.Message}");
+ // }
+ // });
+ //};
- var registerPage = new RegisterPage(callBackAction);
+ var registerPage = new RegisterPage();
registerPage.Show();
registerPage.ShowDialog();
};
@@ -534,4 +687,4 @@
};
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.8.0