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/AccountLogin.cs | 742 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 483 insertions(+), 259 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs b/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs
old mode 100755
new mode 100644
index 6287edc..8dd8ba2
--- a/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Account/AccountLogin.cs
@@ -1,12 +1,7 @@
锘縰sing System;
-using System.Collections.Generic;
-using System.Net;
-using System.Text;
-using uPLibrary.Networking.M2Mqtt;
using Shared.Common;
-using Shared.IO;
using Shared.Phone.UserView;
-using System.Net.Http;
+using Shared.Phone.Device.CommonForm;
namespace Shared.Phone.Device.Account
{
@@ -21,25 +16,26 @@
/// </summary>
private FrameLayout midFrameLayout;
/// <summary>
- /// 娉ㄥ唽鎸夐挳
+ /// 鎵嬫満閭
/// </summary>
- private Button registerBtn;
+ private PhoneEmailForm phoneEmailForm;
/// <summary>
- /// 璐﹀彿杈撳叆鎺т欢
+ /// phoneRowForm
/// </summary>
- private EditText accountET;
+ private PhoneLoginRowForm phoneRow;
/// <summary>
- /// 瀵嗙爜杈撳叆鎺т欢
+ /// emailRow
/// </summary>
- private EditText passwrodET;
+ private EmailLoginRowForm emailRow;
/// <summary>
- /// 鐧诲綍鎸夐挳
+ /// pwdRow
/// </summary>
- private Button loginBtn;
+ private PwdLoginRowForm pwdRow;
+
/// <summary>
- /// 闅愯棌瀵嗙爜
+ /// 璐﹀彿瀵嗙爜fl
/// </summary>
- private Button hidenPWDbtn;
+ private FrameLayout accountPwdFL;
/// <summary>
/// 鐧诲綍閿欒鎻愮ず鎸夐挳
/// </summary>
@@ -49,9 +45,34 @@
/// </summary>
private Button forgotPasswordBtn;
/// <summary>
+ /// 鐧诲綍鎸夐挳
+ /// </summary>
+ private Button loginBtn;
+ /// <summary>
/// 楠岃瘉鐮佺櫥褰曟寜閽�
/// </summary>
private Button loginByCodeBtn;
+ /// <summary>
+ /// 娉ㄥ唽鎸夐挳
+ /// </summary>
+ private Button registerBtn;
+ /// <summary>
+ /// 璐﹀彿
+ /// </summary>
+ private string account;
+ /// <summary>
+ /// 瀵嗙爜
+ /// </summary>
+ private string password;
+ /// <summary>
+ /// wechat
+ /// </summary>
+ private Button wechatBtn;
+ /// <summary>
+ /// qq
+ /// </summary>
+ private Button qqBtn;
+
#endregion
@@ -62,7 +83,14 @@
/// </summary>
public AccountLogin()
{
- BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
+ CommonPage.Instance.IsDrawerLockMode = true;
+ BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
+ Tag = "Login";
+ }
+
+ public override void RemoveFromParent()
+ {
+ base.RemoveFromParent();
}
#endregion
@@ -93,165 +121,180 @@
/// <param name="password">Password.</param>
public void LoginViewShow(string account = "", string password = "")
{
+ this.account = account;
+ this.password = password;
#region midFrameLayout
midFrameLayout = new FrameLayout()
{
Width = LayoutParams.MatchParent,
Height = Application.GetRealHeight(CommonPage.AppRealHeight),
- //Y = Application.GetRealHeight(36),
BackgroundColor =ZigbeeColor.Current.GXCBackgroundColor
};
AddChidren(midFrameLayout);
#endregion
#region 甯冨眬璐︽埛锛屽瘑鐮侊紝蹇樿瀵嗙爜锛屾敞鍐� 鎵嬫満楠岃瘉鐮佺櫥褰�
- registerBtn = new Button()
- {
- Width = Application.GetRealWidth(250),
- Height = Application.GetRealHeight(80),
- X = Application.GetRealWidth(CommonPage.AppRealWidth-250-50),
- Y = Application.GetRealHeight(100),
- TextID = R.MyInternationalizationString.Register,
- TextSize = 15,
- TextColor = ZigbeeColor.Current.GXCTextBlueColor,
- TextAlignment = TextAlignment.CenterRight
- };
- midFrameLayout.AddChidren(registerBtn);
- var logoBtn = new Button()
+ var logoBG = new Button()
{
- Width = Application.GetMinRealAverage(270),
- Height = Application.GetMinRealAverage(270),
- Y = Application.GetRealHeight(150)+registerBtn.Bottom,
- UnSelectedImagePath = "Logo/Logo.png",
- Gravity=Gravity.CenterHorizontal
+ Height = Application.GetRealHeight(619),
+ UnSelectedImagePath = "Account/Logo_loginBG.png"
};
- midFrameLayout.AddChidren(logoBtn);
+ midFrameLayout.AddChidren(logoBG);
- var accountFL = new FrameLayout()
+ var phoneEmailBGFL = new FrameLayout()
{
- 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,
+ 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(accountFL);
+ midFrameLayout.AddChidren(logo);
- accountET = new EditText()
+ var logoName = new Button()
{
- X=Application.GetRealWidth(20),
- Width = Application.GetRealWidth(660),
- PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPhoneNumberOrEmail),
- TextAlignment = TextAlignment.Center,
- PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
- TextColor = ZigbeeColor.Current.GXCTextBlackColor,
- Text=account
+ Y = logo.Bottom,
+ Height = Application.GetRealHeight(69),
+ Width = Application.GetRealWidth(300),
+ Gravity = Gravity.CenterHorizontal,
+ TextID = R.MyInternationalizationString.AppName,
+ TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ TextSize=16
};
- accountFL.AddChidren(accountET);
+ midFrameLayout.AddChidren(logoName);
- var passwordFL = new FrameLayout()
+ phoneEmailForm = new PhoneEmailForm();
+ phoneEmailForm.Init(midFrameLayout);
+
+
+ //閿欒鎻愮ずBtn
+ loginErrorBtn = new Button()
{
+ X = Application.GetRealWidth(242),
+ Y = Application.GetRealHeight(740),
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
+ Height = Application.GetRealHeight(58),
+ TextColor = ZigbeeColor.Current.GXCTextRed,
+ TextAlignment = TextAlignment.CenterLeft,
+ TextSize=CommonFormResouce.TextSize,
+ IsBold=true
};
- midFrameLayout.AddChidren(passwordFL);
+ midFrameLayout.AddChidren(loginErrorBtn);
- passwrodET = new EditText()
+ accountPwdFL = new FrameLayout()
{
- Width = Application.GetRealWidth(450),
- PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputPWD),
- TextAlignment = TextAlignment.Center,
- SecureTextEntry = true,
- PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
- TextColor = ZigbeeColor.Current.GXCTextBlackColor,
- Text=password,
- Gravity=Gravity.CenterHorizontal
+ Y = Application.GetRealHeight(801),
+ Height = Application.GetRealHeight(553),
+ Width = Application.GetRealWidth(942),
+ Gravity = Gravity.CenterHorizontal,
+ BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
+ Radius = (uint)Application.GetRealHeight(17)
};
- passwordFL.AddChidren(passwrodET);
+ midFrameLayout.AddChidren(accountPwdFL);
- hidenPWDbtn = new Button()
- {
- X = passwrodET.Right + Application.GetRealWidth(20),
- Width = Application.GetMinReal(72),
- Height = Application.GetMinReal(72),
- UnSelectedImagePath = "Account/HidenPWD.png",
- SelectedImagePath = "Account/UnHidenPWD.png",
- Gravity=Gravity.CenterVertical
- };
- passwordFL.AddChidren(hidenPWDbtn);
+ AddPhoneOrEmailFL(accountPwdFL, "Phone");
forgotPasswordBtn = new Button()
{
- Width = Application.GetRealWidth(400),
- Height = Application.GetRealHeight(110),
- Y = passwordFL.Bottom + Application.GetRealHeight(100),
- TextID = R.MyInternationalizationString.ForgotPassword,
- TextSize = 15,
- TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor,
- TextAlignment = TextAlignment.Center,
- Gravity=Gravity.CenterHorizontal
+ 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()
{
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(110),
- Y = Application.GetRealHeight(100) + forgotPasswordBtn.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 = Application.GetRealHeight(1293),
+ Width = Application.GetRealWidth(688),
+ Height = Application.GetRealHeight(127),
Gravity = Gravity.CenterHorizontal,
- Enable = !string.IsNullOrEmpty(passwrodET.Text),
- IsSelected = !string.IsNullOrEmpty(passwrodET.Text)
+ TextID = R.MyInternationalizationString.Login,
+ TextSize = 16,
+ 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(pwdRow.PasswrodET?.Text),
+ IsSelected = !string.IsNullOrEmpty(pwdRow.PasswrodET?.Text),
+ IsBold=true
};
midFrameLayout.AddChidren(loginBtn);
- //閿欒鎻愮ずBtn
- 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
- };
- midFrameLayout.AddChidren(loginErrorBtn);
-
loginByCodeBtn = new Button()
{
+ X=Application.GetRealWidth(98),
+ Y = Application.GetRealHeight(1466),
Width = Application.GetRealWidth(300),
- Height = Application.GetRealHeight(110),
- Y = midFrameLayout.Bottom - Application.GetRealHeight(100+110),
+ Height = Application.GetRealHeight(49),
TextID = R.MyInternationalizationString.LoginByCode,
- TextColor = ZigbeeColor.Current.GXCTextBlueColor,
- TextAlignment = TextAlignment.Center,
- TextSize = 15,
- Gravity = Gravity.CenterHorizontal
+ TextColor = ZigbeeColor.Current.GXCTextGrayColor,
+ TextAlignment = TextAlignment.CenterLeft,
+ TextSize = CommonFormResouce.loginTextSize
};
midFrameLayout.AddChidren(loginByCodeBtn);
- #endregion
- #region event
- passwrodET.EditorEnterAction = (ae) =>
+ registerBtn = new Button()
{
- Application.HideSoftInput();
+ 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);
+
+ wechatBtn = new Button
+ {
+ X = Application.GetRealWidth(395),
+ Y = Application.GetRealHeight(1737),
+ Width = Application.GetMinRealAverage(115),
+ Height = Application.GetMinRealAverage(115),
+ UnSelectedImagePath = "Account/Wechat.png",
+ Gravity=Gravity.CenterHorizontal
+ };
+ midFrameLayout.AddChidren(wechatBtn);
+
+ qqBtn = new Button
+ {
+ X = Application.GetRealWidth(567),
+ Y = Application.GetRealHeight(1737),
+ Width = Application.GetMinRealAverage(115),
+ Height = Application.GetMinRealAverage(115),
+ UnSelectedImagePath = "Account/QQ.png"
+ };
+ //midFrameLayout.AddChidren(qqBtn);
+
+ #endregion
BindEvent();
- #endregion
+
+ if (string.IsNullOrEmpty(account) == false && AccountLogic.Instance.CheckEmail(account) == true)
+ {
+ SelectPhoneOrEmail_MouseUpEvent(phoneEmailForm.SelectedEmail, null);
+ this.account = string.Empty;
+ }
+ else
+ {
+ this.account = string.Empty;
+ }
}
#endregion
@@ -263,21 +306,21 @@
/// </summary>
private void BindEvent()
{
+ //閫夋嫨鎵嬫満閭
+ phoneEmailForm.SelectedPhone.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
+ phoneEmailForm.SelectedEmail.MouseUpEventHandler += SelectPhoneOrEmail_MouseUpEvent;
//鐧诲綍浜嬩欢
loginBtn.MouseUpEventHandler += LoginBtnEvent;
//鐭俊鐧诲綍
loginByCodeBtn.MouseUpEventHandler += LoginByCode;
- //蹇樿瀵嗙爜
- forgotPasswordBtn.MouseUpEventHandler += ForgetPWD;
//娉ㄥ唽浜嬩欢
registerBtn.MouseUpEventHandler += Register;
- //璐﹀彿鐩戝惉
- accountET.TextChangeEventHandler += Account_TextChange;
- //瀵嗙爜鐩戝惉浜嬩欢
- passwrodET.TextChangeEventHandler += Pwd_TextChange;
- //闅愯棌瀵嗙爜
- hidenPWDbtn.MouseUpEventHandler += HidePWD;
-
+ //蹇樿瀵嗙爜
+ forgotPasswordBtn.MouseUpEventHandler += ForgetPWD_MouseUpEvent;
+ //wechat
+ wechatBtn.MouseUpEventHandler += LoginByWechat;
+ //qq
+ qqBtn.MouseUpEventHandler += LoginByQQ;
}
#endregion
@@ -291,15 +334,23 @@
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
private void LoginBtnEvent(object sender,MouseEventArgs mouseEventArgs)
{
- Login(accountET.Text.Trim(), passwrodET.Text.Trim());
+ if (phoneEmailForm.SelectedPhone.IsSelected)
+ {
+ Login(phoneRow.AccountET.Text.Trim(), pwdRow.PasswrodET.Text.Trim());
+ }
+ else
+ {
+ Login(emailRow.AccountET.Text.Trim(), pwdRow.PasswrodET.Text.Trim());
+ }
+
}
/// <summary>
/// 鐧诲綍
/// </summary>
- /// <param name="account">Account.</param>
- /// <param name="password">Password.</param>
- private void Login(string account, string password)
+ /// <param name="accountStr">Account.</param>
+ /// <param name="passwordStr">Password.</param>
+ private void Login(string accountStr, string passwordStr)
{
//Application.RunOnMainThread( () =>
//{
@@ -307,12 +358,17 @@
{
try
{
+ if(CheckAccount(accountStr)==false)
+ {
+ return;
+ }
+
CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
var requestObj = new SendDataToServer.LoginObj
{
- Account = account,
- Password = password,
+ Account = accountStr,
+ Password = passwordStr,
Source = CommonPage.Source,
Company = CommonPage.Company
};
@@ -321,6 +377,7 @@
if (revertObj == null)
{
CommonPage.Instance.FailureToServer();
+ CommonPage.Loading.Hide();
return;
}
var stateCodeStr = revertObj.StateCode.ToUpper();
@@ -331,29 +388,21 @@
{
return;
}
- this.RemoveFromParent();
- UserPage.Instance.Fresh();
+ HomePage.Instance.ShowLoginLoadView();
new System.Threading.Thread(async () =>
{
- //鍚姩ZigBee
- ZigBee.Common.Application.Init();
//瀛樺偍鏁版嵁
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.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.Password = password;
+ Config.Instance.Password = passwordStr;
+ Config.Instance.MD5PWD = revertData.MD5PWD;
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;
+ Config.Instance.LoginToken = revertData.Token;
if (Config.Instance.AccountList.Find((obj) => obj == revertData.Account) == null)
{
Config.Instance.AccountList.Add(revertData.Account);
@@ -363,13 +412,17 @@
var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
var homes = await House.GetHomeLists();
//鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
- await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
- Shared.Common.Room.canInitAllRoom = true;
+ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
+ //鍚姩ZigBee
+ ZigBee.Common.Application.Init();
+
Shared.Common.Room.InitAllRoom();
Application.RunOnMainThread(() =>
{
- UserPage.Instance.Fresh();
CommonPage.Loading.Hide();
+ this.RemoveFromParent();
+ CommonPage.Instance.RemoveViewByTag("Login");
+ UserPage.Instance.Fresh();
});
})
{ IsBackground = true }.Start();
@@ -379,28 +432,24 @@
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 == "USERNAMEORPWDERROR")
{
CommonPage.Loading.Hide();
//璐﹀彿鎴栧瘑鐮侀敊璇�
loginErrorBtn.TextID = R.MyInternationalizationString.USERNAMEORPWDERROR;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.USERNAMEORPWDERROR);
}
else if (stateCodeStr == "ACCOUNTNOEXISTS")
{
CommonPage.Loading.Hide();
//璐﹀彿涓嶅瓨鍦�
loginErrorBtn.TextID = R.MyInternationalizationString.ACCOUNTNOEXISTS;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ACCOUNTNOEXISTS);
}
else if (stateCodeStr == "YOUDATANOISLOCALREGION")
{
@@ -413,12 +462,11 @@
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginLocalRegionRes>(revertObj.ResponseData.ToString());
CommonPage.RequestHttpsHost = responseDataObj.RegionServer;
//鍐嶆鐧诲綍
- Login(account, password);
+ Login(accountStr, passwordStr);
}
else
{
loginErrorBtn.TextID = R.MyInternationalizationString.RequestServerFailed;
- CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.RequestServerFailed);
}
}
catch (Exception ex)
@@ -437,103 +485,290 @@
}
/// <summary>
+ /// CheckAccount
+ /// </summary>
+ /// <param name="accountStr"></param>
+ /// <returns></returns>
+ private bool CheckAccount(string accountStr)
+ {
+ if (phoneEmailForm.SelectedEmail.IsSelected)
+ {
+ if (AccountLogic.Instance.CheckEmail(accountStr) == false)
+ {
+ loginErrorBtn.TextID = R.MyInternationalizationString.TheEmailError;
+ return false;
+ }
+ }
+ else
+ {
+ if (AccountLogic.Instance.CheckPhone(accountStr) == false)
+ {
+ loginErrorBtn.TextID = R.MyInternationalizationString.ThePhoneError;
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
/// 閫氳繃楠岃瘉鐮佺櫥褰�
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
private void LoginByCode(object sender,MouseEventArgs mouseEventArgs)
{
- this.RemoveFromParent();
+ //this.RemoveFromParent();
var loginByCodePage = new AccountLoginByCode();
CommonPage.Instance.AddChidren(loginByCodePage);
loginByCodePage.Show();
}
+ /// <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();
+ //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+ await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
+ //鍚姩ZigBee
+ ZigBee.Common.Application.Init();
+ 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 strUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + authRes.access_token;
+ strUrl += "&openid=" + authRes.openid;
+ var byteData = await Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET");
+ if (byteData == null)
+ {
+ return false;
+ }
+ var receipData = System.Text.Encoding.UTF8.GetString(byteData);
+ var nickData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserCenter.NicknameInfo>(receipData);
+ auth.UserName = nickData.nickname;
+
+ 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;
+ }
+ }
+
+ /// <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;
+ loginErrorBtn.Text = string.Empty;
+ (sender as Button).IsSelected = (sender as Button).IsBold = true;
+ if((sender as Button).Tag.ToString()=="Phone")
+ {
+ AddPhoneOrEmailFL(accountPwdFL, "Phone");
+ }
+ else
+ {
+ AddPhoneOrEmailFL(accountPwdFL, "Email");
+ }
+ }
+ /// <summary>
+ /// AddPhoneOrEmailFL
+ /// </summary>
+ /// <param name="accountPwdFrameLayout"></param>
+ /// <param name="phoneOrEmail"></param>
+ private void AddPhoneOrEmailFL(FrameLayout accountPwdFrameLayout,string phoneOrEmail)
+ {
+ accountPwdFrameLayout.RemoveAll();
+
+ if (phoneOrEmail == "Phone")
+ {
+ phoneRow = new PhoneLoginRowForm();
+ phoneRow.Init(accountPwdFrameLayout, this, this.account, 29, 29);
+ phoneRow.AccountET.TextChangeEventHandler += Account_TextChange;
+ }
+ else
+ {
+ emailRow = new EmailLoginRowForm();
+ emailRow.Init(accountPwdFrameLayout, this.account, 29, 29);
+ emailRow.AccountET.TextChangeEventHandler += Account_TextChange;
+ }
+
+ pwdRow = new PwdLoginRowForm();
+ pwdRow.Init(accountPwdFrameLayout, 29, 225);
+ pwdRow.PasswrodET.TextChangeEventHandler += Pwd_TextChange;
+ }
#endregion
+
#region 鈼� 蹇樿瀵嗙爜________________________
/// <summary>
/// 蹇樿瀵嗙爜
/// </summary>
- private void ForgetPWD(object sender, MouseEventArgs mouseEventArgs)
+ private void ForgetPWD_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
{
- var forgetWPDDialog = new Dialog()
- {
- BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
- };
- forgetWPDDialog.Show();
- var forgetSelectedView = new FrameLayout()
- {
- BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
- Gravity = Gravity.Center,
- Width = Application.GetRealWidth(700),
- Height = Application.GetRealHeight(700),
- Radius = (uint)Application.GetRealHeight(30),
- };
- forgetWPDDialog.AddChidren(forgetSelectedView);
-
- var forgetByPhone = new Button()
- {
- Y = Application.GetRealHeight(100),
- Width = Application.GetRealWidth(600),
- Height = Application.GetRealHeight(100),
- TextID = R.MyInternationalizationString.FindPWDByPhone,
- TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
- TextAlignment = TextAlignment.Center,
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
- Radius = (uint)Application.GetRealHeight(50),
- Gravity = Gravity.CenterHorizontal
- };
- forgetSelectedView.AddChidren(forgetByPhone);
-
- var forgetByEmail = new Button()
- {
- Y = Application.GetRealHeight(100) + forgetByPhone.Bottom,
- Width = Application.GetRealWidth(600),
- Height = Application.GetRealHeight(100),
- TextID = R.MyInternationalizationString.FindPWDByEmail,
- TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
- TextAlignment = TextAlignment.Center,
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
- Radius = (uint)Application.GetRealHeight(50),
- Gravity = Gravity.CenterHorizontal
- };
- forgetSelectedView.AddChidren(forgetByEmail);
-
- var cancleBtn = new Button()
- {
- Y = Application.GetRealHeight(100) + forgetByEmail.Bottom,
- Width = Application.GetRealWidth(300),
- Height = Application.GetRealHeight(100),
- TextID = R.MyInternationalizationString.Cancel,
- TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
- TextAlignment = TextAlignment.Center,
- BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
- Radius = (uint)Application.GetRealHeight(50),
- Gravity = Gravity.CenterHorizontal
- };
- forgetSelectedView.AddChidren(cancleBtn);
-
- forgetByPhone.MouseUpEventHandler += (sender1, e1) =>
- {
- forgetWPDDialog.Close();
- this.RemoveFromParent();
- var forgot = new Account.ForgotPasswordByPhone();
- CommonPage.Instance.AddChidren(forgot);
- forgot.Show();
- };
- forgetByEmail.MouseUpEventHandler += (sender1, e1) =>
- {
- forgetWPDDialog.Close();
- this.RemoveFromParent();
- var forgot = new Account.ForgotPasswordByEmail();
- CommonPage.Instance.AddChidren(forgot);
- forgot.Show();
- };
- cancleBtn.MouseUpEventHandler += (sender1, e1) =>
- {
- forgetWPDDialog.Close();
- };
+ var forgot = new AccountForgetPWD();
+ CommonPage.Instance.AddChidren(forgot);
+ forgot.Show();
}
#endregion
@@ -547,9 +782,8 @@
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
private void Register(object sender,MouseEventArgs mouseEventArgs)
{
- this.RemoveFromParent();
- var registerPage = new RegistrationPhoneOREmail();
- Shared.Common.CommonPage.Instance.AddChidren(registerPage);
+ var registerPage = new AccountRegister();
+ CommonPage.Instance.AddChidren(registerPage);
registerPage.Show();
}
@@ -563,7 +797,7 @@
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
private void Account_TextChange(object sender,string mouseEventArgs)
{
- loginErrorBtn.Text = "";
+ loginErrorBtn.Text = string.Empty;
}
/// <summary>
@@ -573,19 +807,19 @@
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
private void Pwd_TextChange(object sender,string mouseEventArgs)
{
- loginErrorBtn.Text = "";
- if (1 <= passwrodET.Text.Trim().Length && passwrodET.Text.Trim().Length <= 16 && accountET.Text.Trim().Length > 0)
+ loginErrorBtn.Text = string.Empty;
+ if (1 <= pwdRow.PasswrodET.Text.Trim().Length && pwdRow.PasswrodET.Text.Trim().Length <= 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length>0))
{
loginBtn.Enable = loginBtn.IsSelected = true;
}
- else if (passwrodET.Text.Trim().Length > 16)
+ else if (pwdRow.PasswrodET.Text.Trim().Length > 16)
{
- passwrodET.Text = mouseEventArgs.Remove(16);
+ pwdRow.PasswrodET.Text = mouseEventArgs.Remove(16);
}
- else if (passwrodET.Text.Trim().Length > 16 && accountET.Text.Trim().Length > 0)
+ else if (pwdRow.PasswrodET.Text.Trim().Length > 16 && (phoneRow.AccountET.Text.Trim().Length > 0 || emailRow?.AccountET.Text.Trim().Length > 0))
{
loginBtn.Enable = loginBtn.IsSelected = true;
- passwrodET.Text = mouseEventArgs.Remove(16);
+ pwdRow.PasswrodET.Text = mouseEventArgs.Remove(16);
}
else
{
@@ -594,17 +828,7 @@
}
-
#endregion
- #region 鈼� 瀵嗙爜闅愯棌__________________________
-
- private void HidePWD(object sender, MouseEventArgs mouseEventArgs)
- {
- passwrodET.SecureTextEntry = !passwrodET.SecureTextEntry;
- hidenPWDbtn.IsSelected = !hidenPWDbtn.IsSelected;
- }
-
- #endregion
}
}
--
Gitblit v1.8.0