using System; using System.Text; using System.Text.RegularExpressions; using Shared.Common; namespace Shared.Phone.Login { public class AccountLogic { #region ◆ 变量____________________________ /// /// _instance /// private static AccountLogic _instance; /// /// Instance /// public static AccountLogic Instance { get { if(_instance==null) { _instance = new AccountLogic(); } return _instance; } } #endregion #region ◆ 邮箱____________________________ /// /// 检查邮箱合法性 /// /// /// public bool CheckEmail(string email) { var regex= new Regex(CommonPage.EmailRegexStr); return regex.IsMatch(email); } #endregion #region ◆ 手机____________________________ /// /// 检查手机号合法性 /// /// /// public bool CheckPhone(string phone) { var regex = new Regex(CommonPage.PhoneForForeignRegexStr); return regex.IsMatch(phone); } /// /// 检查手机号合法性、区分区号 /// /// 手机号 /// 区号 /// public bool CheckPhoneWithZone(string phone, string zoneCode) { if (zoneCode == "86") { var regex = new Regex(CommonPage.PhoneRegexStr); return regex.IsMatch(phone); } else { var regex = new Regex(CommonPage.PhoneForForeignRegexStr); return regex.IsMatch(phone); } } #endregion #region ◆ 密码____________________________ /// /// 检查密码长度合法性 /// /// /// public bool CheckPwdLength(string password) { if (password.Trim().Length >= 6 && password.Trim().Length <= 13) { return true; } return false; } #endregion #region ◆ 经纬度__________________________ /// /// ReceiveAppLatAndLon /// /// /// public async void ReceiveAppLatAndLon(string lon, string lat) { try { var requestObj = new SendDataToServer.ReceiveAppLatAndLonObj { Longitude = lon, Latitude = lat }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); var revertObj = RequestHttpsZigbeeAsync("ProcessRange/ReceiveAppLatAndLon", System.Text.Encoding.UTF8.GetBytes(requestJson)); if (UserCenter.UserCenterResourse.HideOption.WriteGpsPoint == 1) { string flage = revertObj == null ? "false" : revertObj.StateCode; string txtvalue = "lon:" + lon + " lat:" + lat + " " + flage; HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, txtvalue); UserCenter.HdlLogLogic.Current.WriteLog(-1, "经纬度上报 " + txtvalue); } } catch { } } /// /// 请求服务器方法 /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据 /// /// 请求Url /// 请求的的数据 /// 得到响应的数据 public Shared.Common.ResponseEntity.ResponsePack RequestHttpsZigbeeAsync(string requestUrl, byte[] byteData) { string result = RequestHttpsZigbeeResultAsync(requestUrl, byteData); if (result != null) { try { var data = Newtonsoft.Json.JsonConvert.DeserializeObject(result); return data; } catch (Exception ex) { System.Console.WriteLine(ex.Message); } } return null; } /// /// 请求服务器方法 /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据 /// /// 请求Url /// 请求的的数据 /// 得到响应的数据 public string RequestHttpsZigbeeResultAsync(string requestUrl, byte[] byteData) { var result = RequestHttpsZigbeeBytesResultAsync(requestUrl, byteData); if (result != null) { return Encoding.UTF8.GetString(result); } return null; } /// /// 请求服务器方法 /// 指定一个Url,和请求方法,数据,Cookie,得到响应的数据 /// /// 请求Url /// 请求的的数据 /// POST 或者 GET 等等 /// 得到响应的数据 public byte[] RequestHttpsZigbeeBytesResultAsync(string requestUrl, byte[] byteData, string requestMethod = "POST") { //请求Url的完成路径 var requestHost = "https://global.hdlcontrol.com/GeofenceService"; var fullUrl = $"{requestHost}/{requestUrl}"; return CommonPage.Instance.DoRequestZigbeeHttpsInterface(fullUrl, byteData, Config.Instance.Token, requestMethod); } #endregion } }