| | |
| | | { |
| | | subaccountListView.RemoveAll (); |
| | | foreach (var subaccount in subaccountList) { |
| | | if (subaccount.UserType == 2) |
| | | //2020-01-07 带确认 |
| | | if (subaccount.AccountType == 2) |
| | | continue; |
| | | RowLayout subaccountRowView = new RowLayout () { |
| | | Height = Application.GetRealHeight(110), |
| | |
| | | }; |
| | | subaccountRowView.AddChidren (rightButton); |
| | | |
| | | EventHandler<MouseEventArgs> eHandler = (sender, e) => { |
| | | modifySubaccount (subaccount); |
| | | }; |
| | | subaccountRowView.MouseUpEventHandler += eHandler; |
| | | btnDebugTitle.MouseUpEventHandler += eHandler; |
| | | rightButton.MouseUpEventHandler += eHandler; |
| | | //EventHandler<MouseEventArgs> eHandler = (sender, e) => { |
| | | // modifySubaccount (subaccount); |
| | | //}; |
| | | //subaccountRowView.MouseUpEventHandler += eHandler; |
| | | //btnDebugTitle.MouseUpEventHandler += eHandler; |
| | | //rightButton.MouseUpEventHandler += eHandler; |
| | | |
| | | Button btnRowLine = new Button () { |
| | | Y = Application.GetRealHeight(105), |
| | |
| | | if (e) { |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | try { |
| | | var requestObj = new RemoveSubAccountObj () { Email = subaccount.Account }; |
| | | |
| | | var requestObj = new DeletedSubAccountObj () { |
| | | SubAccount = subaccount.SubAccountDistributedMark, |
| | | HouseDistributedMark = UserConfig.Instance.CurrentRegion.Id, |
| | | }; |
| | | |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("RemoveSubAccount", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var revertObj = MainPage.RequestHttps (API.DeletedSubAccount, requestJson, true); |
| | | if (revertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | Application.RunOnMainThread (() => { |
| | | subaccountList.Remove (subaccount); |
| | | addSubaccountList (); |
| | | }); |
| | | } else { |
| | | //错误提示 |
| | | ShowDeletedSubAccountErrorInfo (revertObj.StateCode); |
| | | } |
| | | } catch { |
| | | MainPage.FailureToServer (); |
| | |
| | | Y = btnTitle.Bottom + Application.GetRealHeight (30), |
| | | Width = Application.GetRealWidth (420), |
| | | Height = Application.GetRealHeight (40), |
| | | Text="User name", |
| | | Text = "SubAccount", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = SkinStyle.Current.TextColor, |
| | | }; |
| | |
| | | }; |
| | | subaccountDialogView.AddChidren (etEmail); |
| | | |
| | | Button btnSubaccountPassword = new Button () { |
| | | X = Application.GetRealWidth (40), |
| | | Y = etEmail.Bottom + Application.GetRealHeight (20), |
| | | Width = Application.GetRealWidth (420), |
| | | Height = Application.GetRealHeight (40), |
| | | TextID = R.MyInternationalizationString.Password, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = SkinStyle.Current.TextColor, |
| | | }; |
| | | subaccountDialogView.AddChidren (btnSubaccountPassword); |
| | | //Button btnSubaccountPassword = new Button () { |
| | | // X = Application.GetRealWidth (40), |
| | | // Y = etEmail.Bottom + Application.GetRealHeight (20), |
| | | // Width = Application.GetRealWidth (420), |
| | | // Height = Application.GetRealHeight (40), |
| | | // TextID = R.MyInternationalizationString.Password, |
| | | // TextAlignment = TextAlignment.CenterLeft, |
| | | // TextColor = SkinStyle.Current.TextColor, |
| | | //}; |
| | | //subaccountDialogView.AddChidren (btnSubaccountPassword); |
| | | |
| | | EditText etSubaccountPassword = new EditText () { |
| | | X = Application.GetRealWidth (40), |
| | | Y = btnSubaccountPassword.Bottom, |
| | | Width = Application.GetRealWidth (420), |
| | | Height = Application.GetRealHeight (80), |
| | | TextColor = SkinStyle.Current.TextColor, |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.DialogTitle, |
| | | BorderWidth = 2, |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | subaccountDialogView.AddChidren (etSubaccountPassword); |
| | | //EditText etSubaccountPassword = new EditText () { |
| | | // X = Application.GetRealWidth (40), |
| | | // Y = btnSubaccountPassword.Bottom, |
| | | // Width = Application.GetRealWidth (420), |
| | | // Height = Application.GetRealHeight (80), |
| | | // TextColor = SkinStyle.Current.TextColor, |
| | | // Radius = 5, |
| | | // BorderColor = SkinStyle.Current.DialogTitle, |
| | | // BorderWidth = 2, |
| | | // TextAlignment = TextAlignment.Center, |
| | | //}; |
| | | //subaccountDialogView.AddChidren (etSubaccountPassword); |
| | | |
| | | FrameLayout bottomView = new FrameLayout () { |
| | | Y = subaccountDialogView.Height - Application.GetRealHeight (90), |
| | |
| | | |
| | | btnSaveSubaccount.MouseUpEventHandler += (sender3, e3) => { |
| | | string addSubaccount = etEmail.Text.Trim (); |
| | | string addSubaccountPassword = etSubaccountPassword.Text.Trim (); |
| | | string addSubaccountReamrk = DateTime.Now.Ticks.ToString(); |
| | | //string addSubaccountPassword = etSubaccountPassword.Text.Trim (); |
| | | //string addSubaccountReamrk = DateTime.Now.Ticks.ToString(); |
| | | //string addSubaccountReamrk = etSubaccountReamrk.Text.Trim (); |
| | | if (string.IsNullOrEmpty (addSubaccount)) { |
| | | new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.TipEntrySubaccount), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etEmail); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty (addSubaccountPassword)) { |
| | | new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etSubaccountPassword); |
| | | return; |
| | | } |
| | | if(string.IsNullOrEmpty (addSubaccountReamrk)){ |
| | | //new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.TipEntrySubaccountRemark), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etSubaccountReamrk); |
| | | //if (string.IsNullOrEmpty (addSubaccountPassword)) { |
| | | // new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etSubaccountPassword); |
| | | //return; |
| | | }if (addSubaccountPassword.Length < 6) { |
| | | new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PasswordLenghtTip), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show (etSubaccountPassword); |
| | | return; |
| | | } |
| | | //} |
| | | //if(string.IsNullOrEmpty (addSubaccountReamrk)){ |
| | | // //new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.TipEntrySubaccountRemark), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show(etSubaccountReamrk); |
| | | // //return; |
| | | //} |
| | | //if (addSubaccountPassword.Length < 6) { |
| | | // new Tip () { MaxWidth = 250, Text = Language.StringByID (R.MyInternationalizationString.PasswordLenghtTip), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show (etSubaccountPassword); |
| | | // return; |
| | | //} |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | |
| | | subaccount.Account = addSubaccount; |
| | | subaccount.Remark = addSubaccountReamrk; |
| | | //subaccount.Remark = addSubaccountReamrk; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | if (isModify) { |
| | | var requestObj = new EditSubAccountObj () { Id = subaccount.UserID, Email = addSubaccount, Password = addSubaccountPassword, Remark = addSubaccountReamrk }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("EditSubAccount", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | Application.RunOnMainThread (() => { |
| | | addSubaccountList (); |
| | | dialog.Close (); |
| | | }); |
| | | } |
| | | //var requestObj = new EditSubAccountObj () { Id = subaccount.UserID, Email = addSubaccount, Password = addSubaccountPassword, Remark = addSubaccountReamrk }; |
| | | //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | //var revertObj = MainPage.RequestHttps ("EditSubAccount", requestJson, true); |
| | | //if (revertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | // Application.RunOnMainThread (() => { |
| | | // addSubaccountList (); |
| | | // dialog.Close (); |
| | | // }); |
| | | //} |
| | | } else { |
| | | var requestObj = new SignSubAccountObj () { Email = addSubaccount, Password = addSubaccountPassword, Remark = addSubaccountReamrk }; |
| | | //var requestObj = new SignSubAccountObj () { Email = addSubaccount, Password = addSubaccountPassword, Remark = addSubaccountReamrk }; |
| | | |
| | | var requestObj = new BindSubAccountObj () { |
| | | HouseDistributedMark = UserConfig.Instance.CurrentRegion.Id, |
| | | SubAccount = addSubaccount, |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps ("SignSubAccount", requestJson); |
| | | if (revertObj.StateCode == "SUCCESS") { |
| | | var requestObj2 = new GetSubAccountListObj (); |
| | | |
| | | var revertObj = MainPage.RequestHttps (API.BindSubAccount, requestJson, true); |
| | | if (revertObj.StateCode.ToUpper () == "SUCCESS") { |
| | | var requestObj2 = new GetSubAccountByDistributedMarkObj () { |
| | | DistributedMark = UserConfig.Instance.CurrentRegion.Id, |
| | | }; |
| | | //var requestObj2 = new GetSubAccountListObj (); |
| | | var requesetJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2); |
| | | var requesetRevertObj2 = MainPage.RequestHttps ("GetSubAccountList", requesetJson2); |
| | | if (requesetRevertObj2.StateCode == "SUCCESS") { |
| | | var requesetRevertObj2 = MainPage.RequestHttps (API.GetSubAccountByDistributedMark, requesetJson2, true); |
| | | if (requesetRevertObj2.StateCode.ToUpper () == "SUCCESS") { |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SubAccountRes>> (requesetRevertObj2.ResponseData.ToString ()); |
| | | subaccountList = responseDataObj; |
| | | Application.RunOnMainThread (() => { |
| | |
| | | addSubaccountList (); |
| | | dialog.Close (); |
| | | }); |
| | | } else { |
| | | //错误提示 |
| | | } |
| | | } else { |
| | | //BindSubAccount错误提示 |
| | | ShowBindSubAccountErrorInfo (revertObj.StateCode); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | //etSubaccountReamrk.EditorEnterAction += (obj) => { |
| | | // etEmail.Foucs = true; |
| | | //}; |
| | | etEmail.EditorEnterAction += (obj) => { |
| | | etSubaccountPassword.Foucs = true; |
| | | }; |
| | | etSubaccountPassword.EditorEnterAction += (obj) => { |
| | | Application.HideSoftInput (); |
| | | }; |
| | | //etEmail.EditorEnterAction += (obj) => { |
| | | // etSubaccountPassword.Foucs = true; |
| | | //}; |
| | | //etSubaccountPassword.EditorEnterAction += (obj) => { |
| | | // Application.HideSoftInput (); |
| | | //}; |
| | | dialog.Show (); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="stateCodeStr"></param> |
| | | void ShowDeletedSubAccountErrorInfo (string stateCodeStr) |
| | | { |
| | | string mes = ""; |
| | | //2020-01-06 待补充 |
| | | if (stateCodeStr == "NoExist") { |
| | | mes = ErrorCode.FailedDelete; |
| | | } else if (stateCodeStr == ErrorCode.NetworkError) { |
| | | mes = ErrorCode.NetworkError; |
| | | } else { |
| | | mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; |
| | | |
| | | } |
| | | if (!string.IsNullOrEmpty (mes)) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | ///(1)Success 则调用此接口成功 |
| | | //(2)ParameterOrEmpty 提供的参数错误,详情见ErrorInfo字段 |
| | | //(3)NoLogin,则响应字段中 [ErrorInfo] 为错误信息为 [无效登录Token!] |
| | | //(4)AccountNoExists 子账号未注册,请绑定已注册的子账号! |
| | | //(5)SameAccount,不能添加自己为子账号! (6)NoExist 用户不存在此住宅 |
| | | //(7)Exist 账号已存在此住宅 |
| | | //(8)Fail 操作失败 |
| | | //(9)BeRestrict 权限不足 |
| | | //(10)NoAddMainAccount 不能绑定主账号 |
| | | // /// </summary> |
| | | /// <param name="stateCodeStr"></param> |
| | | void ShowBindSubAccountErrorInfo (string stateCodeStr) |
| | | { |
| | | string mes = ""; |
| | | //2020-01-06 待补充 |
| | | if (stateCodeStr == "AccountNoExists") { |
| | | mes = ErrorCode.SubAccountNoExists; |
| | | } else if (stateCodeStr == "SameAccount") { |
| | | mes = ErrorCode.SameAccount; |
| | | } else if (stateCodeStr == "Exist") { |
| | | mes = ErrorCode.SubAccountExist; |
| | | } else if (stateCodeStr == "NoAddMainAccount") { |
| | | mes = ErrorCode.NoAddMainAccount; |
| | | } else if (stateCodeStr == ErrorCode.NetworkError) { |
| | | mes = ErrorCode.NetworkError; |
| | | } else { |
| | | mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; |
| | | |
| | | } |
| | | if (!string.IsNullOrEmpty (mes)) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | } |