| | |
| | | btnSendCode.TextAlignment = TextAlignment.Center;
|
| | | btnSendCode.IsBold = true;
|
| | | rowVerCode.AddChidren(btnSendCode);
|
| | | btnSendCode.ButtonClickEvent += async (sender, e) =>
|
| | | btnSendCode.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //检测输入的账号
|
| | | nowInputAccount = txtAccount.Text.Trim();
|
| | |
| | | return;
|
| | | }
|
| | | //发送验证码
|
| | | hadSendCode = await this.SendVerCode(btnSendCode, nowInputAccount, i_div);
|
| | | hadSendCode = this.SendVerCode(btnSendCode, nowInputAccount, i_div);
|
| | | };
|
| | |
|
| | | //底线
|
| | |
| | | //登陆中....
|
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //登陆参数
|
| | | var pra = new SendDataToServer.LoginObj();
|
| | |
| | |
|
| | | //访问接口
|
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(pra);
|
| | | var result = await CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
| | | var result = CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/Login", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
| | |
|
| | | //处理登陆成功的数据
|
| | | this.AdjustLoginSuccessData(result, pra, i_account, i_psw, i_div);
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //是否已经绑定
|
| | | var re = await isBindAuthAsync(authStr);
|
| | | var re = isBindAuthAsync(authStr);
|
| | | if (re)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | |
| | | //直接登录
|
| | | HomePage.Instance.ShowLoginLoadView();
|
| | | });
|
| | | var resultRegID = await Shared.Common.CommonPage.Instance.PushRegID();
|
| | | var homes = await HdlResidenceLogic.Current.GetHomeListsFromDb();
|
| | | var resultRegID = Shared.Common.CommonPage.Instance.PushRegID();
|
| | | var homes = HdlResidenceLogic.Current.GetHomeListsFromDb();
|
| | | //刷新个人中心的内存及线程
|
| | | await UserCenter.UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | //启动ZigBee
|
| | | ZigBee.Common.Application.Init();
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | this.RemoveFromParent();
|
| | | CommonPage.Instance.RemoveViewByTag("Login");
|
| | |
| | | else
|
| | | {
|
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var registerPage = new AccountRegister();
|
| | | CommonPage.Instance.AddChidren(registerPage);
|
| | |
| | | /// </summary>
|
| | | /// <param name="authStr"></param>
|
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<bool> isBindAuthAsync(string authStr)
|
| | | private bool isBindAuthAsync(string authStr)
|
| | | {
|
| | | var authRes = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.AuthUserRes>(authStr);
|
| | | var auth = new SendDataToServer.AuthUser()
|
| | |
| | | //获取微信昵称
|
| | | 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");
|
| | | var byteData = Common.CommonPage.Instance.DoRequestZigbeeHttpsInterface(strUrl, null, null, "GET");
|
| | | if (byteData == null)
|
| | | {
|
| | | return false;
|
| | |
| | | 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));
|
| | | var revertObj = CommonPage.Instance.RequestHttpsZigbeeAsync("ZigbeeUsers/InsertOrUpdateAuthUser", System.Text.Encoding.UTF8.GetBytes(requestJson));
|
| | | if (revertObj == null)
|
| | | {
|
| | | return false;
|
| | |
| | | /// <param name="i_account">账号</param>
|
| | | /// <param name="i_verCode">验证码</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private async void LoginByVerCode(string i_account, string i_verCode, int i_div)
|
| | | private void LoginByVerCode(string i_account, string i_verCode, int i_div)
|
| | | {
|
| | | var pra = new SendDataToServer.LoginValidCodeOBJ()
|
| | | //登陆中....
|
| | | CommonPage.Loading.Start(Language.StringByID(R.MyInternationalizationString.Logining));
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | Account = i_account,
|
| | | Code = i_verCode,
|
| | | Language = CommonPage.ZigBeeLanguage,
|
| | | AreaCode = int.Parse(CommonPage.PhoneZoneStr)
|
| | | };
|
| | | var result = await CommonFormResouce.LoginByCode(pra);
|
| | | //处理登陆成功的数据
|
| | | this.AdjustLoginSuccessData(result, pra, i_account, string.Empty, i_div);
|
| | | var pra = new SendDataToServer.LoginValidCodeOBJ()
|
| | | {
|
| | | Account = i_account,
|
| | | Code = i_verCode,
|
| | | Language = CommonPage.ZigBeeLanguage,
|
| | | AreaCode = int.Parse(CommonPage.PhoneZoneStr)
|
| | | };
|
| | | var result = CommonFormResouce.LoginByCode(pra);
|
| | | //处理登陆成功的数据
|
| | | this.AdjustLoginSuccessData(result, pra, i_account, string.Empty, i_div);
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="account">账号</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<bool> SendVerCode(NormalViewControl btnSendCode, string account, int i_div)
|
| | | private bool SendVerCode(NormalViewControl btnSendCode, string account, int i_div)
|
| | | {
|
| | | //不能再点击
|
| | | btnSendCode.CanClick = false;
|
| | |
| | | AreaCode = int.Parse(CommonPage.PhoneZoneStr),
|
| | | Language = CommonPage.ZigBeeLanguage
|
| | | };
|
| | | var requestRevertObj = await CommonFormResouce.LoginSendVerCode(reqDtoSignPhone);
|
| | | var requestRevertObj = CommonFormResouce.LoginSendVerCode(reqDtoSignPhone);
|
| | | if (requestRevertObj == null)
|
| | | {
|
| | | //请求服务器失败
|
| | |
| | | /// <param name="i_account">账号</param>
|
| | | /// <param name="i_psw">密码,验证码登陆时,设置为 string.Empty</param>
|
| | | /// <param name="i_div">1:手机号 2:邮箱</param>
|
| | | private async void AdjustLoginSuccessData(Common.ResponseEntity.ResponsePack revertObj, object pra,
|
| | | private void AdjustLoginSuccessData(Common.ResponseEntity.ResponsePack revertObj, object pra,
|
| | | string i_account, string i_psw, int i_div)
|
| | | {
|
| | | if (revertObj == null)
|
| | |
| | | Config.Instance.LoginToken = revertData.Token;
|
| | | Config.Instance.Save();
|
| | |
|
| | | var resultRegID = await CommonPage.Instance.PushRegID();
|
| | | var homes = await HdlResidenceLogic.Current.GetHomeListsFromDb();
|
| | | var resultRegID = CommonPage.Instance.PushRegID();
|
| | | var homes = HdlResidenceLogic.Current.GetHomeListsFromDb();
|
| | | //刷新个人中心的内存及线程
|
| | | await UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | UserCenterLogic.InitUserCenterMenmoryAndThread();
|
| | | //启动ZigBee
|
| | | ZigBee.Common.Application.Init();
|
| | |
|