| | |
| | | using System; |
| | | using System.Text; |
| | | using Shared.Common; |
| | | using Shared.Phone.UserView; |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="account"></param> |
| | | /// <param name="password"></param> |
| | | public void Show(string account, string password) |
| | | public void Show(string account, string password,string OpenID="") |
| | | { |
| | | var dialog = new FrameLayout() |
| | | { |
| | |
| | | }; |
| | | AddChidren(willLogin); |
| | | |
| | | AutoLogin(account, password); |
| | | AutoLogin(account, password,OpenID); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="account"></param> |
| | | /// <param name="password"></param> |
| | | private void AutoLogin(string account, string password) |
| | | private void AutoLogin(string account, string password, string OpenID = "") |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | |
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining)); |
| | | Action action = async () => { |
| | | var loginSuccess = await HomePage.Instance.LoginByPWDAsync(account, password); |
| | | if (loginSuccess == 1) |
| | | if (loginSuccess==1) |
| | | { |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | if (string.IsNullOrEmpty(OpenID)==false) |
| | | { |
| | | BindAuthUser(Config.Instance.Guid, OpenID); |
| | | } |
| | | ZigBee.Common.Application.Init(); |
| | | |
| | | //登录成功 |
| | |
| | | { |
| | | UserPage.Instance.Fresh(); |
| | | CommonPage.Loading.Hide(); |
| | | this.RemoveFromParent(); |
| | | CommonPage.Instance.RemoveViewByTag("Register"); |
| | | CommonPage.Instance.RemoveViewByTag("Login"); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | |
| | | finally |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | this.RemoveFromParent(); |
| | | CommonPage.Instance.RemoveViewByTag("Register"); |
| | | CommonPage.Instance.RemoveViewByTag("Login"); |
| | | } |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定 |
| | | /// </summary> |
| | | /// <param name="guid"></param> |
| | | /// <param name="openId"></param> |
| | | private void BindAuthUser(string guid, string openId) |
| | | { |
| | | new System.Threading.Thread(async () => |
| | | { |
| | | var auth = new SendDataToServer.BindAuthUser |
| | | { |
| | | AccountGuid = guid, |
| | | OpenID = openId |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(auth); |
| | | var revert = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/BindAuthUserToAccount", Encoding.UTF8.GetBytes(requestJson)); |
| | | }) |
| | | { |
| | | IsBackground = true |
| | | }.Start(); |
| | | } |
| | | } |
| | | } |