From f788a1e320b8505435ed66e2456ddb2d0a838f76 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期四, 19 十一月 2020 19:58:14 +0800
Subject: [PATCH] 2020-11-19 1.优化绑定和解绑页面。2.修改密码功能实现,UI界面实现,接口实现。
---
HDL_ON/Common/Utlis.cs | 140 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 138 insertions(+), 2 deletions(-)
diff --git a/HDL_ON/Common/Utlis.cs b/HDL_ON/Common/Utlis.cs
index 329f7f5..3f8d765 100644
--- a/HDL_ON/Common/Utlis.cs
+++ b/HDL_ON/Common/Utlis.cs
@@ -1,5 +1,8 @@
锘縰sing System;
-namespace HDL_ON.Common
+using Shared;
+using System.Text.RegularExpressions;
+
+namespace HDL_ON
{
/// <summary>
/// 甯哥敤宸ュ叿绫�
@@ -15,5 +18,138 @@
Console.WriteLine(mes);
#endif
}
- }
+
+ /// <summary>
+ /// 寮圭獥鎻愮ず
+ /// </summary>
+ /// <param name="mes"></param>
+ public static void ShowAlertOnMainThread(string mes)
+ {
+ Application.RunOnMainThread(() => {
+ new Alert("", mes, Language.StringByID(StringId.Close)).Show();
+ });
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="mes"></param>
+ /// <param name="bodyView"></param>
+ public static void ShowTip(String mes, View bodyView)
+ {
+ var tip = new Tip()
+ {
+ Text = mes,
+ CloseTime = 1,
+ Direction = AMPopTipDirection.None
+ };
+ tip.Show(bodyView);
+ }
+
+
+ #region 鈻� 鍚勭姝e垯妫�娴媉______________________
+ /// <summary>
+ /// 鐢ㄤ簬涓浗澶ч檰楠岃瘉鎵嬫満鍙锋鍒欒〃杈惧紡
+ /// </summary>
+ public static string PhoneRegexStr = "^[1][0-9]{10}$";
+ /// <summary>
+ /// 鐢ㄤ簬楠岃瘉闈炰腑鍥藉ぇ闄嗘墜鏈哄彿姝e垯琛ㄨ揪寮�
+ /// </summary>
+ public static string PhoneForForeignRegexStr = "^[0-9]*$";
+ /// <summary>
+ /// 鐢ㄤ簬楠岃瘉閭姝e垯琛ㄨ揪寮�
+ /// </summary>
+ public static string EmailRegexStr = "^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$";
+
+ /// <summary>
+ /// 鍒ゆ柇鏄惁鍖呭惈澶у啓瀛楁瘝
+ /// </summary>
+ /// <returns><c>true</c>, if contain upper was checked, <c>false</c> otherwise.</returns>
+ /// <param name="value">Value.</param>
+ public static bool CheckContainUpper(string value)
+ {
+ Regex reg = new Regex("[A-Z]+");
+ return reg.IsMatch(value);
+ }
+
+ /// <summary>
+ /// 鍒ゆ柇鏄惁鍖呭惈灏忓啓瀛楁瘝
+ /// </summary>
+ /// <returns><c>true</c>, if contain lower was checked, <c>false</c> otherwise.</returns>
+ /// <param name="value">Value.</param>
+ public static bool CheckContainLower(string value)
+ {
+ Regex reg = new Regex("[a-z]+");
+ return reg.IsMatch(value);
+ }
+
+ /// <summary>
+ /// 鍒ゆ柇鏄惁鍖呭惈鏁板瓧
+ /// </summary>
+ /// <returns><c>true</c>, if contain lower was checked, <c>false</c> otherwise.</returns>
+ /// <param name="value">Value.</param>
+ public static bool CheckContainNum(string value)
+ {
+ Regex reg = new Regex("[0-9]+");
+ return reg.IsMatch(value);
+ }
+
+ /// <summary>
+ /// 鍒ゆ柇鏄惁鍖呭惈绗﹀彿
+ /// </summary>
+ /// <returns><c>true</c>, if contain lower was checked, <c>false</c> otherwise.</returns>
+ /// <param name="value">Value.</param>
+ public static bool CheckContainSymbol(string value)
+ {
+ Regex reg = new Regex("([^a-z0-9A-Z])+");
+ return reg.IsMatch(value);
+ }
+
+ /// <summary>
+ /// 妫�娴嬮偖绠辨槸鍚﹀悎娉�
+ /// </summary>
+ /// <param name="email"></param>
+ /// <returns></returns>
+ public static bool CheckEmail(string email)
+ {
+ Regex reg = new Regex(EmailRegexStr);
+ return reg.IsMatch(email);
+ }
+
+ /// <summary>
+ /// 妫�娴嬫墜鏈哄彿鏄惁鍚堟硶
+ /// </summary>
+ /// <param name="phoneNumber">鎵嬫満鍙�</param>
+ /// <param name="areaCode">鍦板尯浠g爜</param>
+ /// <returns></returns>
+ public static bool CheckPhoneNumber(string phoneNumber, string areaCode)
+ {
+ //鏍¢獙澶栧浗鎵嬫満鍙�
+ if (areaCode != "86")
+ {
+ Regex reg = new Regex(PhoneForForeignRegexStr);
+ return reg.IsMatch(phoneNumber);
+ }
+
+ //鏍¢獙鍥藉唴鎵嬫満鍙�
+ if (phoneNumber.Length > 11)
+ {
+ return false;
+ }
+ else if (phoneNumber.Length == 11)
+ {
+ Regex reg = new Regex(PhoneRegexStr);
+ return reg.IsMatch(phoneNumber);
+ }
+ else
+ {
+ //姝e垯琛ㄨ揪寮忓垽鏂槸鍚︽暟瀛�
+ Regex reg = new Regex("^[0-9]*$");
+ return reg.IsMatch(phoneNumber);
+ }
+ }
+
+ #endregion
+ }
+
}
--
Gitblit v1.8.0