From 52e317b95d830f8cd1156b403ff5a34fb8f9bccb Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 31 七月 2020 17:43:42 +0800
Subject: [PATCH] 2020-7-31-2
---
HDL_ON/UI/UI1-Login/LoginPageBLL.cs | 393 ++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 308 insertions(+), 85 deletions(-)
diff --git a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
index 9653896..15b85eb 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
{
@@ -30,17 +31,45 @@
/// </summary>
void GetVerificationCode()
{
- btnGetVerificationCode.MouseUpEventHandler += (sender, e) =>
+ btnGetVerificationCode.MouseUpEventHandler = (sender, e) =>
{
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.GetLoginVerCode(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();
}
};
}
@@ -68,18 +150,22 @@
void LoadPage_SwitchLoginType()
{
//閫夋嫨鎵嬫満鐧诲綍
- btnPhoneLogin.MouseUpEventHandler += (sender, e) =>
+ btnPhoneLogin.MouseUpEventHandler = (sender, e) =>
{
+ if (loginType == 0)
+ return;
+ etAccount.Text = registerPhone;
+ etPassword.Text = "";
#region 鍒囨崲閫変腑鎸夐挳
btnEmailLogin.TextColor = CSS_Color.PromptingColor1;
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();
@@ -88,11 +174,45 @@
//鏄剧ず楠岃瘉鐮佺櫥褰曟柟寮忥紝鎵嬫満鐧诲綍鏈夐獙璇佺爜鐧诲綍
btnSwitchLoginMode.Visible = true;
#endregion
+
+ #region
+ if (logintMode == 1)
+ {
+ if (Regex.IsMatch(account, @"^[1]+\d{10}") && (account.Length == 11) && btnGetVerificationCode.Text == Language.StringByID(StringId.GetVerificationCode))
+ {
+ btnGetVerificationCode.IsSelected = true;
+ }
+ btnSwitchLoginMode.TextID = StringId.PasswordLogin;
+ //passwordView.AddChidren(btnGetVerificationCode);
+ btnGetVerificationCode.Visible = true;
+ etPassword.PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode);
+ btnPasswordIcon.IsSelected = true;
+ if (btnVisiblePassword.Parent != null)
+ {
+ btnVisiblePassword.RemoveFromParent();
+ }
+ if (btnDividingLineVertical_PasswordView2.Parent != null)
+ {
+ btnDividingLineVertical_PasswordView2.RemoveFromParent();
+ }
+ if (btnForgetPassword.Parent != null)
+ {
+ btnForgetPassword.RemoveFromParent();
+ }
+ //楠岃瘉鐮佷笉闇�瑕侀殣钘�
+ etPassword.SecureTextEntry = false;
+ }
+ #endregion
+
};
//閫夋嫨閭鐧诲綍
btnEmailLogin.MouseUpEventHandler += (sender, e) =>
{
+ if (loginType == 1)
+ return;
+ etAccount.Text = registerEmail;
+ etPassword.Text = "";
#region 鍒囨崲閫変腑鎸夐挳
btnPhoneLogin.TextColor = CSS_Color.PromptingColor1;
btnPhoneLogin.TextSize = CSS_FontSize.TextFontSize;
@@ -102,7 +222,7 @@
#endregion
#region 鍒囨崲鐧诲綍绫诲瀷鍙婂浘鏍�
- logintType = 1;
+ loginType = 1;
if (btnGlobalRoaming.Parent != null)
{
btnGlobalRoaming.RemoveFromParent();
@@ -111,7 +231,7 @@
#endregion
//閭鍙湁瀵嗙爜鐧诲綍妯″紡
- logintMode = 0;
+ //logintMode = 0;
//瀵嗙爜鐧诲綍
btnSwitchLoginMode.TextID = StringId.VerificationCodeLogin;
passwordView.AddChidren(btnVisiblePassword);
@@ -119,10 +239,11 @@
passwordView.AddChidren(btnForgetPassword);
btnPasswordIcon.IsSelected = false;
- if (btnGetVerificationCode.Parent != null)
- {
- btnGetVerificationCode.RemoveFromParent();
- }
+ //if (btnGetVerificationCode.Parent != null)
+ //{
+ //btnGetVerificationCode.RemoveFromParent();
+ btnGetVerificationCode.Visible = false;
+ //}
//闅愯棌瀵嗙爜
etPassword.SecureTextEntry = true;
//闅愯棌楠岃瘉鐮佺櫥褰曟柟寮忥紝閭鐧诲綍娌℃湁楠岃瘉鐮佺櫥褰�
@@ -136,7 +257,7 @@
/// </summary>
void LoadPage_SwitchLoginMode()
{
- btnSwitchLoginMode.MouseUpEventHandler += (sender, e) =>
+ btnSwitchLoginMode.MouseUpEventHandler = (sender, e) =>
{
logintMode = logintMode == 0 ? 1 : 0;
//娓呴櫎瀵嗙爜妗嗘枃鏈暟鎹�
@@ -147,20 +268,28 @@
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)
- {
- btnGetVerificationCode.RemoveFromParent();
- }
+ //if (btnGetVerificationCode.Parent != null)
+ //{
+ //btnGetVerificationCode.RemoveFromParent();
+ btnGetVerificationCode.Visible = false;
+ //}
//闅愯棌瀵嗙爜
etPassword.SecureTextEntry = true;
}
//楠岃瘉鐮佺櫥褰�
else if (logintMode == 1)
{
+ if (Regex.IsMatch(account, @"^[1]+\d{10}") && (account.Length == 11) && btnGetVerificationCode.Text == Language.StringByID(StringId.GetVerificationCode))
+ {
+ btnGetVerificationCode.IsSelected = true;
+ }
btnSwitchLoginMode.TextID = StringId.PasswordLogin;
- passwordView.AddChidren(btnGetVerificationCode);
+ //passwordView.AddChidren(btnGetVerificationCode);
+ btnGetVerificationCode.Visible = true;
+ etPassword.PlaceholderText = Language.StringByID(StringId.PlsEntryVerificationCode);
btnPasswordIcon.IsSelected = true;
if (btnVisiblePassword.Parent != null)
{
@@ -181,12 +310,12 @@
}
/// <summary>
- /// 鏂囨湰妗嗛�変腑浜嬩欢
+ /// 鏂囨湰妗嗙劍鐐瑰彉鍖栦簨浠�
/// </summary>
void LoadPage_SelectionEditText()
{
//褰撶劍鐐瑰湪璐﹀彿鏂囨湰妗嗘椂锛屾枃鏈搴曠嚎鐐逛寒
- etAccount.FoucsChanged += (sender, e) =>
+ etAccount.FoucsChanged = (sender, e) =>
{
if (etAccount.Foucs)
{
@@ -197,6 +326,55 @@
{
btnAccountViewBottomLine.BackgroundColor = CSS_Color.DividingLineColor;
btnAccountViewBottomLine.Height = Application.GetRealHeight(1);
+ account = etAccount.Text.Trim();
+ if (loginType == 0)
+ {
+ registerPhone = account;
+ }
+ else
+ {
+ registerEmail = account;
+ }
+ 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 +435,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 +451,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,20 +467,30 @@
//鍒涘缓鐧诲綍绾跨▼
var loginThread = LoadThread_Login();
waitPage = new Loading();
- new WaitPageMothed().LoadPage_WaitPage(loginThread, bodyView, waitPage);
-
+ new PublicAssmebly().LoadPage_WaitPage(loginThread, bodyView, waitPage);
}
};
#region 褰撹处鍙峰瘑鐮侀兘杈撳叆鏃讹紝鎵嶈兘鐐瑰嚮鐧诲綍鎸夐挳
- etAccount.TextChangeEventHandler += (sender, e) =>
+ etAccount.TextChangeEventHandler = (sender, e) =>
{
- if (etAccount.Text.Trim().Length > 0 && etPassword.Text.Trim().Length > 0)
+ account = etAccount.Text.Trim();
+ if (account.Length > 0 && etPassword.Text.Trim().Length > 0)
{
btnLogin.IsSelected = true;
}
else
{
btnLogin.IsSelected = false;
+ }
+ if (Regex.IsMatch(account, @"^[1]+\d{10}") )//&& account.Length == 11)
+ {
+ btnGetVerificationCode.IsSelected = true;
+ btnGetVerificationCode.TextColor = CSS_Color.MainBackgroundColor;
+ }
+ else
+ {
+ btnGetVerificationCode.IsSelected = false;
+ btnGetVerificationCode.TextColor = CSS_Color.PromptingColor1;
}
};
etPassword.TextChangeEventHandler += (sender, e) =>
@@ -330,6 +518,18 @@
{
//鐧诲綍
var loginResult = LoadMethod_Login();
+ if( !string.IsNullOrEmpty (verAccount))//楠岃瘉鐧诲綍璐﹀彿
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (verAccount == etPassword.Text.Trim())
+ {
+ //璺宠浆椤甸潰----
+ MainPage.GoUserPage();
+ return;
+ }
+ });
+ }
if (loginResult)
{
//鑾峰彇浣忓畢淇℃伅
@@ -342,9 +542,6 @@
Application.RunOnMainThread(() =>
{
- waitPage.RemoveFromParent();
- waitPage = null;
-
//璺宠浆椤甸潰----
MainPage.GoUserPage();
});
@@ -354,6 +551,18 @@
catch (Exception ex)
{
MainPage.Log($"LoginPage : {ex.Message}");
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (waitPage != null)
+ {
+ waitPage.RemoveFromParent();
+ waitPage = null;
+ }
+
+ });
}
})
{ IsBackground = true };
@@ -365,9 +574,18 @@
bool LoadMethod_Login()
{
var result = false;
- //璋冪敤鐧诲綍鎺ュ彛
- var loginResult = pm.LoginByPassword(account, password);
- if (loginResult.StateCode == "SUCCESS")
+ ResponsePack loginResult;
+ if (logintMode == 0 || loginType == 1)
+ {
+ //璋冪敤鐧诲綍鎺ュ彛
+ 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 +593,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 +617,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 +651,7 @@
//璐﹀彿鎴栬�呭瘑鐮侀敊璇�
Application.RunOnMainThread(() =>
{
+ waitPage.Hide();
//鎻愮ず鍘熷洜
var tip = new Tip()
{
@@ -410,8 +660,6 @@
Direction = AMPopTipDirection.None
};
tip.Show(bodyView);
- btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
- btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
});
}
return result;
@@ -424,38 +672,15 @@
{
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 +697,6 @@
};
tip.Show(bodyView);
});
-
}
return result;
}
@@ -485,22 +709,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 +757,4 @@
};
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.8.0