From 587c36e27131f2d028fcabc13b296a8de7470034 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期三, 08 一月 2020 08:59:19 +0800
Subject: [PATCH] 2019.1.8
---
ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs | 1433 +++++++++++++++++++++++++++++++++--------------------------
1 files changed, 794 insertions(+), 639 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs b/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs
old mode 100755
new mode 100644
index f9536ee..798fe31
--- a/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Account/AccountLoginByCode.cs
@@ -4,730 +4,885 @@
using System.Collections.Generic;
using System.Timers;
using Shared.Phone.UserView;
+using Shared.Phone.Device.CommonForm;
namespace Shared.Phone.Device.Account
{
/// <summary>
/// 楠岃瘉鐮佺櫥褰�
/// </summary>
- public class AccountLoginByCode: FrameLayout
+ public class AccountLoginByCode : FrameLayout
{
+
+ #region 鈼� 鍙橀噺____________________________
+ /// <summary>
+ /// 鑳屾櫙瑙嗗浘
+ /// </summary>
+ private FrameLayout midFrameLayout;
+ /// <summary>
+ /// 鎵嬫満閭
+ /// </summary>
+ private PhoneEmailForm phoneEmailForm;
+ /// <summary>
+ /// phoneRowForm
+ /// </summary>
+ private PhoneRowForm phoneRow;
+ /// <summary>
+ /// emailRow
+ /// </summary>
+ private EmailRowForm emailRow;
+ /// <summary>
+ /// codeRow
+ /// </summary>
+ private VerificationCodeRowForm codeRow;
+ /// <summary>
+ /// 璐﹀彿楠岃瘉鐮乫l
+ /// </summary>
+ private FrameLayout accountCodeFL;
+ /// <summary>
+ /// 鐧诲綍鎸夐挳
+ /// </summary>
+ private Button loginBtn;
+ /// <summary>
+ /// 蹇樿瀵嗙爜鎸夐挳
+ /// </summary>
+ private Button forgotPasswordBtn;
+ /// <summary>
+ /// 娉ㄥ唽
+ /// </summary>
+ private Button registerBtn;
+ /// <summary>
+ /// 璐﹀彿鐧诲綍
+ /// </summary>
+ private Button LoginByAccountPWDBtn;
+ /// <summary>
+ /// 鐧诲綍閿欒鎻愮ず鎸夐挳
+ /// </summary>
+ private Button loginErrorBtn;
+ /// <summary>
+ /// 璐﹀彿
+ /// </summary>
+ private string account;
+ /// <summary>
+ /// 楠岃瘉鐮�
+ /// </summary>
+ private string code;
+ /// <summary>
+ /// wechat
+ /// </summary>
+ private Button wechatBtn;
+
+ private Timer t;
+ private DateTime dateBegin;
+
+ #endregion
+
+
/// <summary>
/// The phone string.
/// </summary>
- public string phoneStr = "";
+ //public string phoneStr = "";
/// <summary>
/// 鎵嬫満鍙疯緭鍏ユ槸鍚︾鍚堣鍒�
/// </summary>
public bool IsRightAccount = false;
/// <summary>
- /// *****鍗囩骇鍒嗗竷寮忓悗锛孉ccount 浠呭寘鍚墜鏈哄彿锛屼笉鍐嶅寘鍚�00鍖哄彿銆傚瘑鐮佷笉鍐嶉渶瑕丮D5鍔犲瘑銆俵anguage涓篈PP璇�
- /// 涓嬫潵閫夋嫨鎵嬫満鍖哄彿 榛樿涓浗澶ч檰涓�86
- ///鍙戦�佸浗闄� / 娓境鍙版秷鎭椂锛屾帴鏀跺彿鐮佹牸寮忎负00 + 鍥介檯鍖哄彿 + 鍙风爜锛屽鈥�008615899998888鈥� 璋冪敤API鏃讹紝Company瀛楁璇蜂紶鍏ユ暣鍨嬪�硷細4銆� 銆�
- ///鍥藉唴 璋冪敤API鏃讹紝Company瀛楁璇蜂紶鍏ユ暣鍨嬪�硷細0銆�
- /// </summary>
- public List<Common.ResponseEntity.AreaCodeOBJ> areaCodeList = new List<Common.ResponseEntity.AreaCodeOBJ>();
- /// <summary>
/// Initializes a new instance of the <see cref="T:Shared.Phone.Device.Account.AccountLoginByCode"/> class.
/// </summary>
public AccountLoginByCode()
{
+ CommonPage.Instance.IsDrawerLockMode = true;
Tag = "Login";
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
+ t = new Timer();
+ dateBegin = new DateTime();
+ }
+ public override void RemoveFromParent()
+ {
+ base.RemoveFromParent();
}
/// <summary>
/// Show this instance.
/// </summary>
- public async void Show()
+ public void Show()
{
- CommonPage.Loading.Start();
- try
- {
- var requestOBJ = new SendDataToServer.GetAreaCodeOBJ()
- {
- RequestVersion = CommonPage.RequestVersion
- };
- var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestOBJ);
- var revertOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/GetAreaCode", System.Text.Encoding.UTF8.GetBytes(requestJson));
- if (revertOBJ == null)
- {
- return;
- }
- if (revertOBJ.StateCode.ToUpper() == "SUCCESS")
- {
- var responseData = revertOBJ.ResponseData;
- areaCodeList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Common.ResponseEntity.AreaCodeOBJ>>(responseData.ToString());
- }
- }
- catch { }
- finally
- {
- CommonPage.Loading.Hide();
- ShowLoginByCodeView();
- }
-
+ ShowLoginByCodeView();
}
/// <summary>
/// Shows the login by code view.
/// </summary>
public void ShowLoginByCodeView()
{
- var t = new Timer();
- var dateBegin = new DateTime();
-
#region midFrameLayout
- var midFrameLayout = new FrameLayout()
+ midFrameLayout = new FrameLayout()
{
Width = LayoutParams.MatchParent,
- Height = Application.GetRealHeight(1920),
+ Height = Application.GetRealHeight(CommonPage.AppRealHeight),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
AddChidren(midFrameLayout);
#endregion
- #region 甯冨眬璐︽埛 娉ㄥ唽 鎵嬫満楠岃瘉鐮佺櫥褰�
-
- var registerBtn = new Button()
+ var logoBG = new Button()
{
- Width = Application.GetRealWidth(250),
- Height = Application.GetRealHeight(80),
- X = Application.GetRealWidth(1080 - 250 - 50),
- Y = Application.GetRealHeight(100),
- TextID = R.MyInternationalizationString.Register,
- TextSize = 15,
- TextColor = ZigbeeColor.Current.GXCTextBlueColor,
- TextAlignment = TextAlignment.CenterRight
+ Height = Application.GetRealHeight(619),
+ UnSelectedImagePath = "Account/Logo_loginBG.png"
};
- midFrameLayout.AddChidren(registerBtn);
+ midFrameLayout.AddChidren(logoBG);
- var logoBtn = new Button()
+ var phoneEmailBGFL = new FrameLayout()
{
- Width = Application.GetMinRealAverage(270),
- Height = Application.GetMinRealAverage(270),
- Y = Application.GetRealHeight(150) + registerBtn.Bottom,
- UnSelectedImagePath = "Logo/Logo.png",
+ Y = logoBG.Bottom,
+ Height = Application.GetRealHeight(1921),
+ BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
+ };
+ midFrameLayout.AddChidren(phoneEmailBGFL);
+
+ var logo = new Button()
+ {
+ Width = Application.GetMinRealAverage(184),
+ Height = Application.GetMinRealAverage(184),
+ Y = Application.GetRealHeight(230),
+ UnSelectedImagePath = "Account/Logo_White.png",
Gravity = Gravity.CenterHorizontal
};
- midFrameLayout.AddChidren(logoBtn);
+ midFrameLayout.AddChidren(logo);
- var accountFL = new FrameLayout()
+ var logoName = new Button()
{
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(110),
- Y = Application.GetRealHeight(200) + logoBtn.Bottom,
- Radius = (uint)Application.GetRealHeight(55),
- BorderColor = ZigbeeColor.Current.GXCBorderColor,
- BorderWidth = 1,
- Gravity = Gravity.CenterHorizontal
- };
- midFrameLayout.AddChidren(accountFL);
- var accountZoneBtn = new Button()
- {
- Width = Application.GetRealWidth(200),
- X = Application.GetRealWidth(20),
- Text = "+" + CommonPage.PhoneZoneStr,
- TextAlignment = TextAlignment.Center,
- TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor
- };
- accountFL.AddChidren(accountZoneBtn);
- var accountZoneLine = new Button()
- {
- X = Application.GetRealWidth(10) + accountZoneBtn.Right,
- Width = 1,
- Height = Application.GetRealHeight(60),
- Gravity=Gravity.CenterVertical,
- BackgroundColor = ZigbeeColor.Current.GXCLineColor
- };
- accountFL.AddChidren(accountZoneLine);
- var accountET = new EditText()
- {
- X = accountZoneLine.Right + Application.GetRealWidth(20),
- Width = Application.GetRealWidth(400),
- PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNum),
- TextAlignment = TextAlignment.Center,
- PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
- TextColor = ZigbeeColor.Current.GXCTextBlackColor
- };
- accountFL.AddChidren(accountET);
-
- var verificationCodeFL = new FrameLayout()
- {
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(110),
- Y = accountFL.Bottom + Application.GetRealHeight(100),
- Radius = (uint)Application.GetRealHeight(55),
- BorderColor = ZigbeeColor.Current.GXCBorderColor,
- BorderWidth = 1,
- Gravity = Gravity.CenterHorizontal
- };
- midFrameLayout.AddChidren(verificationCodeFL);
- var verificationCodeET = new EditText()
- {
- X = Application.GetRealWidth(20),
- Width = Application.GetRealWidth(350),
- PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputVerificationCode),
- TextAlignment = TextAlignment.Center,
- PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
- TextColor = ZigbeeColor.Current.GXCTextBlackColor
- };
- verificationCodeFL.AddChidren(verificationCodeET);
-
- var sendCodeLine = new Button()
- {
- X = Application.GetRealWidth(10) + verificationCodeET.Right,
- Width = 1,
- Height = Application.GetRealHeight(60),
- Gravity=Gravity.CenterVertical,
- BackgroundColor = ZigbeeColor.Current.GXCLineColor
- };
- verificationCodeFL.AddChidren(sendCodeLine);
-
- var sendCodeBtn = new Button()
- {
- X = sendCodeLine.Right + Application.GetRealWidth(20),
- Width = Application.GetRealWidth(250),
- TextID = R.MyInternationalizationString.SendVerificationCode,
- TextColor = ZigbeeColor.Current.GXCTextUnselectedColor,
- SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
- TextAlignment = TextAlignment.Center,
- Enable = false,
- IsSelected=false
- };
- verificationCodeFL.AddChidren(sendCodeBtn);
-
- var loginBtn = new Button()
- {
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(110),
- Y = Application.GetRealHeight(200) + verificationCodeFL.Bottom,
- TextID = R.MyInternationalizationString.Login,
- TextSize = 15,
- TextColor = Shared.Common.ZigbeeColor.Current.GXCTextWhiteColor,
- Radius = (uint)Application.GetRealHeight(55),
- BorderWidth = 0,
- BackgroundColor = ZigbeeColor.Current.GXCButtonUnselectedColor,
- SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
+ Y = logo.Bottom,
+ Height = Application.GetRealHeight(69),
+ Width = Application.GetRealWidth(300),
Gravity = Gravity.CenterHorizontal,
- Enable = false,
- IsSelected=false
+ TextID = R.MyInternationalizationString.AppName,
+ TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ TextSize = 16
};
- midFrameLayout.AddChidren(loginBtn);
+ midFrameLayout.AddChidren(logoName);
+
+ phoneEmailForm = new PhoneEmailForm();
+ phoneEmailForm.Init(midFrameLayout);
//閿欒鎻愮ずBtn
- var loginErrorBtn = new Button()
+ loginErrorBtn = new Button()
{
- Y = loginBtn.Bottom + Application.GetRealHeight(50),
- Width = Application.GetRealWidth(1080 - 100),
- Height = Application.GetRealHeight(110),
- TextColor = ZigbeeColor.Current.GXCRedColor,
- Gravity = Gravity.CenterHorizontal
+ X = Application.GetRealWidth(242),
+ Y = Application.GetRealHeight(740),
+ Width = Application.GetRealWidth(700),
+ Height = Application.GetRealHeight(58),
+ TextColor = ZigbeeColor.Current.GXCTextRed,
+ TextAlignment = TextAlignment.CenterLeft,
+ TextSize = CommonFormResouce.TextSize,
+ IsBold = true
};
midFrameLayout.AddChidren(loginErrorBtn);
- var LoginByAccountPWDBtn = new Button()
+ accountCodeFL = new FrameLayout()
{
- Width = Application.GetRealWidth(500),
- Height = Application.GetRealHeight(110),
- Y = midFrameLayout.Bottom - Application.GetRealHeight(100 + 110),
- TextID = R.MyInternationalizationString.LoginByAccountPWD,
- TextColor = ZigbeeColor.Current.GXCTextBlueColor,
- TextAlignment = TextAlignment.Center,
+ Y = Application.GetRealHeight(801),
+ Height = Application.GetRealHeight(553),
+ Width = Application.GetRealWidth(942),
Gravity = Gravity.CenterHorizontal,
- TextSize = 15
+ BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
+ Radius = (uint)Application.GetRealHeight(17)
+ };
+ midFrameLayout.AddChidren(accountCodeFL);
+
+ AddPhoneOrEmailFL(accountCodeFL, "Phone");
+
+ forgotPasswordBtn = new Button()
+ {
+ X = Application.GetRealWidth(CommonPage.AppRealWidth - 115 - 250),
+ Y = Application.GetRealHeight(1198),
+ Width = Application.GetRealWidth(250),
+ Height = Application.GetRealHeight(58),
+ TextID = R.MyInternationalizationString.ForgotPWD_1,
+ TextSize = CommonFormResouce.loginTextSize,
+ TextColor = Shared.Common.ZigbeeColor.Current.GXCTextGrayColor,
+ TextAlignment = TextAlignment.CenterRight
+ };
+ midFrameLayout.AddChidren(forgotPasswordBtn);
+
+ loginBtn = new Button()
+ {
+ Y = Application.GetRealHeight(1281),
+ Width = Application.GetRealWidth(688),
+ Height = Application.GetRealHeight(127),
+ Gravity = Gravity.CenterHorizontal,
+ TextID = R.MyInternationalizationString.Login,
+ TextSize = 16,
+ IsBold=true,
+ TextColor = ZigbeeColor.Current.GXCTextGrayColor,
+ SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonBlackSelectedColor,
+ BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor,
+ Radius = (uint)Application.GetRealHeight(127 / 2),
+ Enable = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text),
+ IsSelected = !string.IsNullOrEmpty(codeRow.VerificationCodeET?.Text)
+ };
+ midFrameLayout.AddChidren(loginBtn);
+
+ LoginByAccountPWDBtn = new Button()
+ {
+ X = Application.GetRealWidth(98),
+ Y = Application.GetRealHeight(1466),
+ Width = Application.GetRealWidth(300),
+ Height = Application.GetRealHeight(49),
+ TextID = R.MyInternationalizationString.LoginByAccountPWD,
+ TextColor = ZigbeeColor.Current.GXCTextGrayColor,
+ TextAlignment = TextAlignment.CenterLeft,
+ TextSize = CommonFormResouce.loginTextSize
};
midFrameLayout.AddChidren(LoginByAccountPWDBtn);
- #endregion
- #region event
- accountET.TextChangeEventHandler += (sender, e) =>
+ registerBtn = new Button()
{
- loginErrorBtn.Text = "";
- //鏍¢獙鎵嬫満鍙�
- if (CommonPage.PhoneZoneStr != "86")
- {
- var reg = new Regex(CommonPage.PhoneForForeignRegexStr);
- var mFalg = reg.Match(accountET.Text.Trim());
- if (!mFalg.Success)
- {
- var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim));
- aler.Show();
- sendCodeBtn.Enable =sendCodeBtn.IsSelected= false;
- IsRightAccount = false;
- }
- else
- {
- sendCodeBtn.Enable = sendCodeBtn.IsSelected= true;
- IsRightAccount = true;
- }
- }
- else
- {
- if (accountET.Text.Trim().Length == 11)
- {
- var reg = new Regex(CommonPage.PhoneRegexStr);
- var mFalg = reg.Match(accountET.Text.Trim());
- if (!mFalg.Success)
- {
- sendCodeBtn.Enable =sendCodeBtn.IsSelected= false;
- IsRightAccount = false;
- var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.OK));
- aler.Show();
- }
- else
- {
- sendCodeBtn.Enable = sendCodeBtn.IsSelected= true;
- IsRightAccount = true;
- }
- }
- else if (accountET.Text.Trim().Length > 11)
- {
- accountET.Text = e.Remove(11);
- }
- else
- {
- sendCodeBtn.Enable = sendCodeBtn.IsSelected = false;
- IsRightAccount = false;
- //姝e垯琛ㄨ揪寮忓垽鏂槸鍚︽暟瀛�
- var reg = new Regex("^[0-9]*$");
- if (!reg.IsMatch(accountET.Text))
- {
- var aler = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.PleaseInputTheCorrectCellPhoneNumber), Language.StringByID(R.MyInternationalizationString.Confrim));
- aler.Show();
- accountET.Text = "";
- }
+ X = Application.GetRealWidth(738),
+ Y = Application.GetRealHeight(1466),
+ Width = Application.GetRealWidth(244),
+ Height = Application.GetRealHeight(49),
+ TextID = R.MyInternationalizationString.Register,
+ TextColor = ZigbeeColor.Current.GXCTextGrayColor,
+ TextAlignment = TextAlignment.CenterRight,
+ TextSize = CommonFormResouce.loginTextSize
+ };
+ midFrameLayout.AddChidren(registerBtn);
- }
- }
- };
- verificationCodeET.TextChangeEventHandler += (sender, e) =>
+ wechatBtn = new Button
{
- loginErrorBtn.Text = "";
- if (verificationCodeET.Text.Trim().Length > 0 && IsRightAccount)
- {
- loginBtn.IsSelected = loginBtn.Enable = true;
- }
- else
- {
- loginBtn.IsSelected = loginBtn.Enable = false;
- }
+ X = Application.GetRealWidth(395),
+ Y = Application.GetRealHeight(1737),
+ Width = Application.GetMinRealAverage(115),
+ Height = Application.GetMinRealAverage(115),
+ UnSelectedImagePath = "Account/Wechat.png",
+ Gravity = Gravity.CenterHorizontal
};
- sendCodeBtn.MouseUpEventHandler += async (sender, e) =>
+ midFrameLayout.AddChidren(wechatBtn);
+
+ BindEvent();
+ }
+
+ #region 鈼� 缁戝畾浜嬩欢_________________________
+
+ /// <summary>
+ /// 缁戝畾鎸夐挳浜嬩欢
+ /// </summary>
+ private void BindEvent()
+ {
+ //閫夋嫨鎵嬫満閭
+ phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
+ phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
+ //鐧诲綍浜嬩欢
+ loginBtn.MouseUpEventHandler += LoginBtnEvent;
+ //璐﹀彿鐧诲綍
+ LoginByAccountPWDBtn.MouseUpEventHandler += LoginByPWD;
+ //娉ㄥ唽浜嬩欢
+ registerBtn.MouseUpEventHandler += Register;
+ //蹇樿瀵嗙爜
+ forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent;
+ //wechat
+ wechatBtn.MouseUpEventHandler += LoginByWechat;
+
+ }
+
+ #endregion
+
+
+ #region 鈼� 鐧诲綍____________________________
+
+ /// <summary>
+ /// 鐧诲綍浜嬩欢
+ /// </summary>
+ /// <param name="sender">Sender.</param>
+ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+ private async void LoginBtnEvent(object sender, MouseEventArgs mouseEventArgs)
+ {
+ CommonPage.Loading.Start();
+ try
{
- string phoneNum = accountET.Text.Trim();
- CommonPage.Loading.Start();
- try
+ if (CheckAccount(account) == false)
{
- int companyInt = 0;
- if (CommonPage.PhoneZoneStr == "86")
+ return;
+ }
+ var reqLoginByCode = new SendDataToServer.LoginValidCodeOBJ()
+ {
+ Account = account,
+ Code = code,
+ Language = CommonPage.ZigBeeLanguage,
+ AreaCode = int.Parse(CommonPage.PhoneZoneStr)
+ };
+ var requestRevetLoginCodeOBJ = await CommonFormResouce.LoginByCode(reqLoginByCode);
+ if (requestRevetLoginCodeOBJ == null)
+ {
+ CommonPage.Instance.FailureToServer();
+ return;
+ }
+ var stateCodeStr = requestRevetLoginCodeOBJ.StateCode.ToUpper();
+ if (stateCodeStr == "SUCCESS")
+ {
+ if (requestRevetLoginCodeOBJ.ResponseData == null)
{
- companyInt = CommonPage.Company;
- phoneStr = phoneNum;
- }
- else
- {
- companyInt = CommonPage.CompanyForINTERNETION;
- phoneStr = phoneNum;
- }
- var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj()
- {
- Account = phoneStr,
- Company = companyInt,
- AreaCode = int.Parse(CommonPage.PhoneZoneStr),
- Language = CommonPage.ZigBeeLanguage
- };
- var requesetJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqDtoSignPhone);
- var requestRevertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/LoginSendVerCode", System.Text.Encoding.UTF8.GetBytes(requesetJson));
- if (requestRevertObj == null)
- {
- CommonPage.Instance.FailureToServer();
return;
}
- var stateCodeStr = requestRevertObj.StateCode.ToUpper();
- if (stateCodeStr == "SUCCESS")
+
+ HomePage.Instance.ShowLoginLoadView();
+ new System.Threading.Thread(async () =>
{
- TimeBegin();
- var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SendVerificationCodeSuccess), Language.StringByID(R.MyInternationalizationString.Confrim));
- alert.Show();
- }
- else if (stateCodeStr == "PARAMETEROREMPTY")
- {
- //鎻愪緵鐨勫弬鏁伴敊璇�
- loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY);
- }
- else if (stateCodeStr == "ACCOUNTNOEXISTS")
- {
- //璐﹀彿涓嶅瓨鍦�
- loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
- accountET.Text = "";
- IsRightAccount = false;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ACCOUNTNOEXISTS);
- }
- else if (stateCodeStr == "SENDFAIL")
- {
- //楠岃瘉鐮佸彂閫佸け璐�
- loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.SENDFAIL);
- }
- else
- {
- loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed);
- }
+ var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
+ var revertData = responseDataObj;
+ Config.ReFresh();
+ Config.Instance.Password = string.Empty;
+ Config.Instance.Account = revertData.Account;
+ Config.Instance.Guid = revertData.Guid;
+ Config.Instance.MD5PWD = revertData.MD5PWD;
+ Config.Instance.LoginDateTime = DateTime.Now;
+ Config.Instance.LoginToken = revertData.Token;
+ if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
+ {
+ Config.Instance.AccountList.Add(revertData.Account);
+ }
+ //闇�瑕佹妸鐧诲綍鍚庤繑鍥炵殑md5瀵嗙爜 璧嬪�肩敓鎴怲oken 鍥犱负鐢ㄦ埛娌℃湁杈撳叆瀵嗙爜
+ Config.Instance.MD5PWD = revertData.MD5PWD;
+ Config.Instance.Save();
+ var resultRegID = await CommonPage.Instance.PushRegID();
+ var homes = await House.GetHomeLists();
+
+ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
+ //鍚姩ZigBee
+ ZigBee.Common.Application.Init();
+
+ Shared.Common.Room.InitAllRoom();
+ Application.RunOnMainThread(() =>
+ {
+ this.RemoveFromParent();
+ CommonPage.Instance.RemoveViewByTag("Login");
+ UserPage.Instance.Fresh();
+ CommonPage.Loading.Hide();
+ });
+ })
+ { IsBackground = true }.Start();
}
- catch
- {
- loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
- }
- finally
+ else if (stateCodeStr == "NOTVERIFY")
{
CommonPage.Loading.Hide();
+ //鏈縺娲�
+ loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY;
+ CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTVERIFY);
}
- };
-
- loginBtn.MouseDownEventHandler += (sender, e) =>
- {
- loginBtn.IsSelected = true;
- };
- //login
- loginBtn.MouseUpEventHandler += (sender, e) =>
- {
- loginByCode();
- };
- void loginByCode()
- {
- Action action = async () =>
+ else if (stateCodeStr == "NOTENABLE")
{
- CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
- try
- {
- var reqLoginByCode = new SendDataToServer.LoginValidCodeOBJ()
- {
- Account = accountET.Text.Trim(),
- Code = verificationCodeET.Text.Trim(),
- Language = CommonPage.ZigBeeLanguage,
- AreaCode = int.Parse(CommonPage.PhoneZoneStr)
- };
- var requesLoginCodeJson = Newtonsoft.Json.JsonConvert.SerializeObject(reqLoginByCode);
-
- var requestRevetLoginCodeOBJ = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/LoginValidCode", System.Text.Encoding.UTF8.GetBytes(requesLoginCodeJson));
- if (requestRevetLoginCodeOBJ == null)
- {
- CommonPage.Instance.FailureToServer();
- return;
- }
- var stateCodeStr = requestRevetLoginCodeOBJ.StateCode.ToUpper();
- if (stateCodeStr == "SUCCESS")
- {
- if (requestRevetLoginCodeOBJ.ResponseData == null)
- {
- return;
- }
- this.RemoveFromParent();
- Application.MainPage?.RemoveViewByTag("Login");
-
- UserPage.Instance.Fresh();
-
- new System.Threading.Thread(async () =>
- {
- var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
- var revertData = responseDataObj;
- Config.ReFresh();
- Config.Instance.UserID = revertData.UserID;
- Config.Instance.MasterID = revertData.MainUserID;
- Config.Instance.AccountType = revertData.UserType;
- Config.Instance.Account = revertData.Account;
- Config.Instance.MqttKey = revertData.MqttKey;
- Config.Instance.Guid = revertData.Guid;
- Config.Instance.LoginDateTime = DateTime.Now;
- Config.Instance.ConnectZigbeeMqttBrokerPwd = revertData.ConnectZigbeeMqttBrokerPwd;
- Config.Instance.ConnectZigbeeMqttClientId = revertData.ConnectZigbeeMqttClientId;
- Config.Instance.ZigbeeMqttBrokerLoadSubDomain = revertData.ZigbeeMqttBrokerLoadSubDomain;
- if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
- {
- Config.Instance.AccountList.Add(revertData.Account);
- }
- //闇�瑕佹妸鐧诲綍鍚庤繑鍥炵殑md5瀵嗙爜 璧嬪�肩敓鎴怲oken 鍥犱负鐢ㄦ埛娌℃湁杈撳叆瀵嗙爜
- Config.Instance.MD5PWD = revertData.MD5PWD;
- Config.Instance.Save();
- var resultRegID = await CommonPage.Instance.PushRegID();
- var homes = await House.GetHomeLists();
-
- //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
- await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
-
- Shared.Common.Room.canInitAllRoom = true;
- Shared.Common.Room.InitAllRoom();
- Application.RunOnMainThread(() =>
- {
- UserPage.Instance.Fresh();
- CommonPage.Loading.Hide();
- });
- })
- { IsBackground = true }.Start();
- }
- else if (stateCodeStr == "NOTVERIFY")
- {
- CommonPage.Loading.Hide();
- //鏈縺娲�
- loginErrorBtn.TextID = R.MyInternationalizationString.NOTVERIFY;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTVERIFY);
- }
- else if (stateCodeStr == "NOTENABLE")
- {
- CommonPage.Loading.Hide();
- //璇ョ敤鎴峰睘浜庤皟璇曡处鍙凤紝骞舵湭鍚敤
- loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.NOTENABLE);
- }
- else if (stateCodeStr == "PARAMETEROREMPTY")
- {
- CommonPage.Loading.Hide();
- //鎻愪緵鐨勫弬鏁伴敊璇�
- loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.PARAMETEROREMPTY);
- }
- else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL")
- {
- CommonPage.Loading.Hide();
- //楠岃瘉鐮侀敊璇�
- loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL);
- }
- else if (stateCodeStr == "YOUDATANOISLOCALREGION")
- {
- CommonPage.Loading.Hide();
- //涓嶅湪鏈尯鍩燂紝闇�瑕侀噸瀹氬悜鍖哄煙鍚庡啀娆¤姹傜櫥褰�
- if (requestRevetLoginCodeOBJ.ResponseData == null)
- {
- return;
- }
- var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
- CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
- //鍐嶆鐧诲綍
- loginByCode();
- }
- else
- {
- CommonPage.Loading.Hide();
- loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed);
- }
- }
- catch
- {
- CommonPage.Loading.Hide();
- CommonPage.Instance.FailureToServer();
- }
- finally
- {
- //CommonPage.Loading.Hide();
- }
- };
- action();
- }
-
- //娉ㄥ唽浜嬩欢
- registerBtn.MouseUpEventHandler += (sender, e) =>
- {
- this.RemoveFromParent();
- var registerPage = new RegistrationPhoneOREmail();
- Shared.Common.CommonPage.Instance.AddChidren(registerPage);
- registerPage.Show();
- };
- //璐﹀彿瀵嗙爜鐧诲綍
- LoginByAccountPWDBtn.MouseUpEventHandler += (sender, e) =>
- {
- this.RemoveFromParent();
- var login = new AccountLogin();
- Shared.Common.CommonPage.Instance.AddChidren(login);
- login.Show();
- };
-
- void TimeBegin()
- {
- t.Interval = 1000;
- t.AutoReset = true;
- t.Enabled = true;
- t.Elapsed += TimeOut;
- //鍚姩璁℃椂鍣ㄥ�掕鏃�-60s
- t.Start();
- dateBegin = DateTime.Now;
- }
-
- void TimeOut(object source, System.Timers.ElapsedEventArgs e)
- {
- var span = DateTime.Now - dateBegin;
- if (span.TotalSeconds <= 61)
+ CommonPage.Loading.Hide();
+ //璇ョ敤鎴峰睘浜庤皟璇曡处鍙凤紝骞舵湭鍚敤
+ loginErrorBtn.TextID = R.MyInternationalizationString.NOTENABLE;
+ }
+ else if (stateCodeStr == "PARAMETEROREMPTY")
{
- Application.RunOnMainThread(() =>
+ CommonPage.Loading.Hide();
+ //鎻愪緵鐨勫弬鏁伴敊璇�
+ loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
+ }
+ else if (stateCodeStr == "VALIDCODEANDPHONENOEQUAL")
+ {
+ CommonPage.Loading.Hide();
+ loginErrorBtn.TextID = R.MyInternationalizationString.VALIDCODEANDPHONENOEQUAL;
+ }
+ else if (stateCodeStr == "NORECORD")
+ {
+ CommonPage.Loading.Hide();
+ loginErrorBtn.TextID = R.MyInternationalizationString.NORECORD;
+ }
+ else if (stateCodeStr == "YOUDATANOISLOCALREGION")
+ {
+ CommonPage.Loading.Hide();
+ //涓嶅湪鏈尯鍩燂紝闇�瑕侀噸瀹氬悜鍖哄煙鍚庡啀娆¤姹傜櫥褰�
+ if (requestRevetLoginCodeOBJ.ResponseData == null)
{
- sendCodeBtn.Text = Convert.ToInt16((60 - span.TotalSeconds)) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCode);
- sendCodeBtn.Enable = false;
- });
+ return;
+ }
+ var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(requestRevetLoginCodeOBJ.ResponseData.ToString());
+ CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
+ //鍐嶆鐧诲綍
+ //loginByCode();
}
else
{
- Application.RunOnMainThread(() =>
- {
- sendCodeBtn.Enable = true;
- sendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode;
- t.Stop();
- t.Close();
- });
+ CommonPage.Loading.Hide();
+ loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
}
}
-
- Button tempClickZoneImgBtn = new Button();
- Button tempClickZoneNameBtn = new Button();
- EventHandler<MouseEventArgs> phoneZoneHandler = (senderZone, eZone) =>
+ catch
{
- //ZoneListView
- var phoneZoneSelectedShowView = new Dialog()
- {
- Height = Application.GetRealHeight(1000),
- Width = Application.GetRealWidth(700),
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
- Radius=(uint)Application.GetRealHeight(30)
- };
- phoneZoneSelectedShowView.Show();
+ CommonPage.Loading.Hide();
+ CommonPage.Instance.FailureToServer();
+ }
+ finally
+ {
+ CommonPage.Loading.Hide();
+ }
- var phoneZoneTitle = new Button()
- {
- Height = Application.GetRealHeight(110),
- TextID = R.MyInternationalizationString.PleaseSelectAreaCode,
- TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
- TextSize = 15,
- BackgroundColor=ZigbeeColor.Current.GXCButtonBlueColor
- };
- phoneZoneSelectedShowView.AddChidren(phoneZoneTitle);
-
- var phoneZoneSelectedListView = new VerticalScrolViewLayout()
- {
- Y = phoneZoneTitle.Bottom,
- Height = Application.GetRealHeight(1000-110*2),
- BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
- };
- phoneZoneSelectedShowView.AddChidren(phoneZoneSelectedListView);
-
- for (int i = 0; i < areaCodeList.Count; i++)
- {
- var zoneItemLName = areaCodeList[i].Name;
- var zoneItemLCode = areaCodeList[i].Code;
- var zoneItemFL = new FrameLayout()
- {
- Width = phoneZoneSelectedListView.Width,
- Height = Application.GetRealHeight(110),
- Tag = i + 10086
- };
- phoneZoneSelectedListView.AddChidren(zoneItemFL);
-
- var zoneIsSelectedBtn = new Button()
- {
- Width = Application.GetMinReal(80),
- Height = Application.GetMinReal(80),
- UnSelectedImagePath = "Account/Check.png",
- SelectedImagePath = "Account/CheckSelected.png",
- Tag = i + 10086,
- Gravity=Gravity.CenterVertical
- };
- zoneItemFL.AddChidren(zoneIsSelectedBtn);
-
- var zoneItemNameBtn = new Button()
- {
- X = Application.GetRealWidth(20)+zoneIsSelectedBtn.Right,
- Width = zoneItemFL.Width - Application.GetRealWidth(100),
- Height = Application.GetRealHeight(110)-1,
- Text = zoneItemLName,
- TextColor = ZigbeeColor.Current.GXCTextBlackColor,
- SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
- TextAlignment = TextAlignment.CenterLeft,
- Tag = i + 10000
- };
- zoneItemFL.AddChidren(zoneItemNameBtn);
-
- var zoneLine = new Button()
- {
- Y = zoneItemFL.Height - 1,
- Width = zoneItemFL.Width,
- Height = 1,
- BackgroundColor = ZigbeeColor.Current.GXCPlaceHolderTextColor
- };
- zoneItemFL.AddChidren(zoneLine);
-
- EventHandler<MouseEventArgs> selectedZone = (sender, e) =>
- {
- tempClickZoneImgBtn.IsSelected = false;
- tempClickZoneNameBtn.IsSelected = false;
- zoneItemNameBtn.IsSelected = true;
- zoneIsSelectedBtn.IsSelected = true;
- tempClickZoneImgBtn = zoneIsSelectedBtn;
- tempClickZoneNameBtn = zoneItemNameBtn;
- CommonPage.PhoneZoneStr = zoneItemLCode;
- };
- zoneIsSelectedBtn.MouseUpEventHandler += selectedZone;
- zoneItemNameBtn.MouseUpEventHandler += selectedZone;
- //榛樿
- if(zoneItemLCode==CommonPage.PhoneZoneStr)
- {
- zoneItemNameBtn.IsSelected = true;
- zoneIsSelectedBtn.IsSelected = true;
- tempClickZoneImgBtn = zoneIsSelectedBtn;
- tempClickZoneNameBtn = zoneItemNameBtn;
- }
- }
- var cancleBtn = new Button()
- {
- Y = phoneZoneSelectedListView.Bottom,
- Height = Application.GetRealHeight(110),
- Width = Application.GetRealWidth(700 / 2),
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
- TextID = R.MyInternationalizationString.Cancel,
- TextSize = 15
- };
- phoneZoneSelectedShowView.AddChidren(cancleBtn);
- cancleBtn.MouseUpEventHandler += (sender, e) =>
- {
- phoneZoneSelectedShowView.Close();
- };
- cancleBtn.MouseDownEventHandler += (sender, e) =>
- {
- cancleBtn.IsSelected = true;
- };
-
- var lineCancleOK = new Button()
- {
- X = cancleBtn.Right,
- Y = phoneZoneSelectedListView.Bottom,
- Height = Application.GetRealHeight(110),
- Width = 1,
- BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
- };
- phoneZoneSelectedShowView.AddChidren(lineCancleOK);
-
- var okBtn = new Button()
- {
- X = lineCancleOK.Right+1,
- Y = phoneZoneSelectedListView.Bottom,
- Height = Application.GetRealHeight(110),
- Width = Application.GetRealWidth(700 / 2)-1,
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
- TextID = R.MyInternationalizationString.Confrim,
- TextSize = 15
- };
- phoneZoneSelectedShowView.AddChidren(okBtn);
- okBtn.MouseUpEventHandler += (sender, e) =>
- {
- accountZoneBtn.Text = "+" + CommonPage.PhoneZoneStr;
- phoneZoneSelectedShowView.Close();
- };
- okBtn.MouseDownEventHandler += (sender, e) =>
- {
- okBtn.IsSelected = true;
- };
- };
- accountZoneBtn.MouseUpEventHandler += phoneZoneHandler;
- #endregion
}
+
+ /// <summary>
+ /// 閫氳繃瀵嗙爜鐧诲綍
+ /// </summary>
+ /// <param name="sender">Sender.</param>
+ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+ private void LoginByPWD(object sender, MouseEventArgs mouseEventArgs)
+ {
+ this.RemoveFromParent();
+ var login = new AccountLogin();
+ Shared.Common.CommonPage.Instance.AddChidren(login);
+ login.Show();
+ }
+
+ /// <summary>
+ /// phone/email 閫夋嫨
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="mouseEventArgs"></param>
+ private void SelectPhoneOrEmail_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
+ {
+ phoneEmailForm.SelectedPhone.IsSelected = phoneEmailForm.SelectedEmail.IsSelected = false;
+ phoneEmailForm.SelectedPhone.IsBold = phoneEmailForm.SelectedEmail.IsBold = false;
+ loginBtn.Enable = loginBtn.IsSelected = false;
+ (sender as Button).IsSelected = (sender as Button).IsBold = true;
+ if ((sender as Button).Tag.ToString() == "Phone")
+ {
+ AddPhoneOrEmailFL(accountCodeFL, "Phone");
+ }
+ else
+ {
+ AddPhoneOrEmailFL(accountCodeFL, "Email");
+ }
+ }
+ /// <summary>
+ /// AddPhoneOrEmailFL
+ /// </summary>
+ /// <param name="accountCodeFrameLayout"></param>
+ /// <param name="phoneOrEmail"></param>
+ private void AddPhoneOrEmailFL(FrameLayout accountCodeFrameLayout, string phoneOrEmail)
+ {
+ accountCodeFrameLayout.RemoveAll();
+ account = string.Empty;
+ loginErrorBtn.Text = string.Empty;
+ if (phoneOrEmail == "Phone")
+ {
+ phoneRow = new PhoneRowForm();
+ phoneRow.Init(accountCodeFrameLayout, this, this.account, 29, 29);
+ phoneRow.AccountET.TextChangeEventHandler += Account_TextChange;
+ }
+ else
+ {
+ emailRow = new EmailRowForm();
+ emailRow.Init(accountCodeFrameLayout, this.account, 29, 29);
+ emailRow.AccountET.TextChangeEventHandler += Account_TextChange;
+ }
+
+ codeRow = new VerificationCodeRowForm();
+ codeRow.Init(accountCodeFrameLayout, 29, 225);
+ codeRow.SendCodeBtn.MouseUpEventHandler += SendCode_MouseUpEventAsync;
+ codeRow.VerificationCodeET.TextChangeEventHandler += Code_TextChange;
+ }
+
+ /// <summary>
+ /// wechat鐧诲綍
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="mouseEventArgs"></param>
+ private void LoginByWechat(object sender, MouseEventArgs mouseEventArgs)
+ {
+#if Android
+ //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP),
+ // Language.StringByID(R.MyInternationalizationString.LoginByWechat),
+ // Language.StringByID(R.MyInternationalizationString.Cancel),
+ // Language.StringByID(R.MyInternationalizationString.Confrim));
+ //alert.Show();
+ //alert.ResultEventHandler += (send, e) =>
+ //{
+ //if (e)
+ //{
+ com.hdl.home.Application.WXLogin();
+ com.hdl.home.WXEntryActivity.RespAction = (authStr) =>
+ {
+ if (authStr == null)
+ {
+
+ }
+ else
+ {
+ new System.Threading.Thread(async () =>
+ {
+ var re = await isBindAuthAsync(authStr);
+ if (re)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ //鐩存帴鐧诲綍
+ HomePage.Instance.ShowLoginLoadView();
+ });
+ var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
+ var homes = await House.GetHomeLists();
+ //鍚姩ZigBee
+ ZigBee.Common.Application.Init();
+ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
+ Shared.Common.Room.InitAllRoom();
+ Application.RunOnMainThread(() =>
+ {
+ this.RemoveFromParent();
+ CommonPage.Instance.RemoveViewByTag("Login");
+ UserPage.Instance.Fresh();
+ });
+ }
+ else
+ {
+ var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
+ Application.RunOnMainThread(() =>
+ {
+ var registerPage = new AccountRegister();
+ Shared.Common.CommonPage.Instance.AddChidren(registerPage);
+ registerPage.OpenID = authRes.openid;
+ registerPage.Show();
+ });
+ }
+ })
+ { IsBackground = true }.Start();
+ }
+ };
+ //}
+ //};
+#endif
+
+#if iOS
+ Home.IOS.AppDelegate.WXLogin();
+ Home.IOS.AppDelegate.RespAction = (authStr) =>
+ {
+ if (authStr == null)
+ {
+
+ }
+ else
+ {
+ new System.Threading.Thread(async () =>
+ {
+
+ var re = await isBindAuthAsync(authStr);
+ if (re)
+ {
+ //鐩存帴鐧诲綍
+ //this.RemoveFromParent();
+
+ //UserPage.Instance.Fresh();
+ var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
+ var homes = await House.GetHomeLists();
+ //鍚姩ZigBee
+ ZigBee.Common.Application.Init();
+ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
+ Shared.Common.Room.InitAllRoom();
+ Application.RunOnMainThread(() =>
+ {
+ this.RemoveFromParent();
+ UserPage.Instance.Fresh();
+ });
+ }
+ else
+ {
+ var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
+ Application.RunOnMainThread(() =>
+ {
+ var registerPage = new AccountRegister();
+ Shared.Common.CommonPage.Instance.AddChidren(registerPage);
+ registerPage.OpenID = authRes.openid;
+ registerPage.Show();
+ });
+ }
+ })
+ { IsBackground = true }.Start();
+ }
+ };
+#endif
+ }
+
+ /// <summary>
+ /// qq鐧诲綍
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="mouseEventArgs"></param>
+ private void LoginByQQ(object sender, MouseEventArgs mouseEventArgs)
+ {
+
+ }
+
+ /// <summary>
+ /// 鏄惁宸茬粦瀹�
+ /// </summary>
+ /// <param name="authStr"></param>
+ /// <returns></returns>
+ private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr)
+ {
+ var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
+ var auth = new SendDataToServer.AuthUser()
+ {
+ AccessToken = authRes.access_token,
+ RefreshToken = authRes.refresh_token,
+ OpenID = authRes.openid
+ };
+ var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth);
+ var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson));
+ if (revertObj == null)
+ {
+ return false;
+ }
+ var stateCodeStr = revertObj.StateCode.ToUpper();
+ if (stateCodeStr == "SUCCESS")
+ {
+ var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString());
+ var revertData = responseDataObj;
+ Config.Instance.Account = revertData.Account;
+ Config.Instance.MD5PWD = revertData.MD5PWD;
+ Config.Instance.Guid = revertData.Guid;
+ Config.Instance.LoginDateTime = DateTime.Now;
+ if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
+ {
+ Config.Instance.AccountList.Add(revertData.Account);
+ }
+ Config.Instance.Save();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ #endregion
+
+ #region 鈼� 璐﹀彿銆侀獙璇佺爜鐩戝惉______________________
+ /// <summary>
+ /// 璐﹀彿鐩戝惉
+ /// </summary>
+ /// <param name="sender">Sender.</param>
+ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+ private void Account_TextChange(object sender, string mouseEventArgs)
+ {
+ loginErrorBtn.Text = string.Empty;
+ if ((sender as EditText).Text.Trim().Length > 0)
+ {
+ IsRightAccount = true;
+ codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = true;
+ account= (sender as EditText).Text.Trim();
+ }
+ else
+ {
+ IsRightAccount = false;
+ codeRow.SendCodeBtn.Enable = codeRow.SendCodeBtn.IsSelected = false;
+ }
+ }
+
+ /// <summary>
+ /// code鐩戝惉浜嬩欢
+ /// </summary>
+ /// <param name="sender">Sender.</param>
+ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+ private void Code_TextChange(object sender, string mouseEventArgs)
+ {
+ loginErrorBtn.Text = "";
+ if ((sender as EditText).Text.Trim().Length > 0 && IsRightAccount)
+ {
+ loginBtn.Enable = loginBtn.IsSelected = true;
+ }
+ else
+ {
+ loginBtn.Enable = loginBtn.IsSelected = false;
+ }
+ code = (sender as EditText).Text.Trim();
+ }
+
+ #endregion
+
+
+ void TimeOut(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ var span = DateTime.Now - dateBegin;
+ if (span.TotalSeconds <= 61)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ codeRow.SendCodeBtn.Text = Convert.ToInt16(60 - span.TotalSeconds) + "s" + Language.StringByID(R.MyInternationalizationString.SendVerificationCodeAgain);
+ codeRow.SendCodeBtn.Enable = false;
+ });
+ }
+ else
+ {
+ Application.RunOnMainThread(() =>
+ {
+ codeRow.SendCodeBtn.Enable = true;
+ codeRow.SendCodeBtn.TextID = R.MyInternationalizationString.SendVerificationCode;
+ t.Stop();
+ t.Close();
+ });
+ }
+ }
+
+ void TimeBegin()
+ {
+ t.Interval = 1000;
+ t.AutoReset = true;
+ t.Enabled = true;
+ t.Elapsed += TimeOut;
+ //鍚姩璁℃椂鍣ㄥ�掕鏃�-60s
+ t.Start();
+ dateBegin = DateTime.Now;
+ }
+
+ #region 鈼� 娉ㄥ唽_____________________________
+
+ /// <summary>
+ /// 娉ㄥ唽
+ /// </summary>
+ /// <param name="sender">Sender.</param>
+ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
+ private void Register(object sender, MouseEventArgs mouseEventArgs)
+ {
+ this.RemoveFromParent();
+ var registerPage = new AccountRegister();
+ CommonPage.Instance.AddChidren(registerPage);
+ registerPage.Show();
+ }
+
+ #endregion
+
+ #region 鈼� 蹇樿瀵嗙爜________________________
+ /// <summary>
+ /// 蹇樿瀵嗙爜
+ /// </summary>
+ private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
+ {
+ this.RemoveFromParent();
+ var forgot = new AccountForgetPWD();
+ CommonPage.Instance.AddChidren(forgot);
+ forgot.Show();
+ }
+
+ #endregion
+
+ #region 鈼� 鍙戦�侀獙璇佺爜________________________
+ /// <summary>
+ /// 鍙戦�侀獙璇佺爜
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="mouseEventArgs"></param>
+ private async void SendCode_MouseUpEventAsync(object sender, MouseEventArgs mouseEventArgs)
+ {
+ if (CheckAccount(account) == false)
+ {
+ return;
+ }
+
+ (sender as Button).Enable = (sender as Button).IsSelected = false;
+ CommonPage.Loading.Start();
+ try
+ {
+ int companyInt = 0;
+ if (CommonPage.PhoneZoneStr == "86" || phoneEmailForm.SelectedEmail.IsSelected)
+ {
+ companyInt = CommonPage.Company;
+ }
+ else
+ {
+ companyInt = CommonPage.CompanyForINTERNETION;
+ }
+ var reqDtoSignPhone = new SendDataToServer.LoginSendVerCodeObj()
+ {
+ Account = account,
+ Company = companyInt,
+ AreaCode = int.Parse(CommonPage.PhoneZoneStr),
+ Language = CommonPage.ZigBeeLanguage
+ };
+ var requestRevertObj = await CommonFormResouce.LoginSendVerCode(reqDtoSignPhone);
+ if (requestRevertObj == null)
+ {
+ CommonPage.Instance.FailureToServer();
+ return;
+ }
+ var stateCodeStr = requestRevertObj.StateCode.ToUpper();
+ if (stateCodeStr == "SUCCESS")
+ {
+ TimeBegin();
+ var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SendVerificationCodeSuccess), Language.StringByID(R.MyInternationalizationString.Confrim));
+ alert.Show();
+ }
+ else if (stateCodeStr == "PARAMETEROREMPTY")
+ {
+ //鎻愪緵鐨勫弬鏁伴敊璇�
+ loginErrorBtn.TextID = R.MyInternationalizationString.PARAMETEROREMPTY;
+ (sender as Button).Enable = (sender as Button).IsSelected = true;
+ }
+ else if (stateCodeStr == "ACCOUNTNOEXISTS")
+ {
+ //璐﹀彿涓嶅瓨鍦�
+ loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
+ IsRightAccount = false;
+ (sender as Button).Enable = (sender as Button).IsSelected = true;
+ }
+ else if (stateCodeStr == "SENDFAIL")
+ {
+ //楠岃瘉鐮佸彂閫佸け璐�
+ loginErrorBtn.TextID = R.MyInternationalizationString.SENDFAIL;
+ (sender as Button).Enable = (sender as Button).IsSelected = true;
+ }
+ else
+ {
+ loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
+ (sender as Button).Enable = (sender as Button).IsSelected = true;
+ }
+ }
+ catch
+ {
+ loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
+ (sender as Button).Enable = (sender as Button).IsSelected = true;
+ }
+ finally
+ {
+ CommonPage.Loading.Hide();
+ }
+ }
+
+ /// <summary>
+ /// CheckAccount
+ /// </summary>
+ /// <param name="accountStr"></param>
+ /// <returns></returns>
+ private bool CheckAccount(string accountStr)
+ {
+ loginErrorBtn.Text = string.Empty;
+ if (phoneEmailForm.SelectedEmail.IsSelected)
+ {
+ if (AccountLogic.Instance.CheckEmail(accountStr) == false)
+ {
+ loginErrorBtn.TextID = R.MyInternationalizationString.TheEmailError;
+ return false;
+ }
+ }
+ else
+ {
+ if (AccountLogic.Instance.CheckPhoneWithZone(accountStr, CommonPage.PhoneZoneStr) == false)
+ {
+ loginErrorBtn.TextID = R.MyInternationalizationString.ThePhoneError;
+ return false;
+ }
+ }
+ return true;
+ }
+
+ #endregion
+
+ #region 鈼� 楠岃瘉楠岃瘉鐮乢_______________________
+
+
+
+ #endregion
}
}
--
Gitblit v1.8.0