| | |
| | | { |
| | | public class SubaccountListView : FrameLayout |
| | | { |
| | | List<SubAccountRes> subaccountList; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | List<ResidenceMemberInfo> subaccountList; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | VerticalScrolViewLayout subaccountListView; |
| | | |
| | | public SubaccountListView (List<SubAccountRes> SubaccountList) |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="SubaccountList"></param> |
| | | public SubaccountListView (List<ResidenceMemberInfo> SubaccountList) |
| | | { |
| | | BackgroundColor = SkinStyle.Current.MainColor; |
| | | subaccountList = SubaccountList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public void ShowSubaccountListView () |
| | | { |
| | | #region ---TopView--- |
| | |
| | | }; |
| | | contentView.AddChidren (subaccountListView); |
| | | |
| | | addSubaccountList (); |
| | | RefreshSubaccountList (); |
| | | |
| | | addTipView (); |
| | | } |
| | |
| | | AddChidren (TipView); |
| | | } |
| | | |
| | | void addSubaccountList () |
| | | /// <summary> |
| | | /// 刷新成员列表View |
| | | /// </summary> |
| | | void RefreshSubaccountList () |
| | | { |
| | | subaccountListView.RemoveAll (); |
| | | if(subaccountList == null) { |
| | | subaccountList = new List<ResidenceMemberInfo> (); |
| | | } |
| | | foreach (var subaccount in subaccountList) { |
| | | //2020-01-07 带确认 |
| | | if (subaccount.AccountType == 2) |
| | | continue; |
| | | ////2020-01-07 带确认 |
| | | //if (subaccount.AccountType == 2) |
| | | // continue; |
| | | |
| | | RowLayout subaccountRowView = new RowLayout () { |
| | | Height = Application.GetRealHeight(110), |
| | | }; |
| | |
| | | if (e) { |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | try { |
| | | |
| | | var requestObj = new DeletedSubAccountObj () { |
| | | SubAccount = subaccount.SubAccountDistributedMark, |
| | | HouseDistributedMark = UserConfig.Instance.CurrentRegion.Id, |
| | | }; |
| | | |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps (API.DeletedSubAccount, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { |
| | | var revertObj = HttpServerRequest.Current.DeleteResidenceMemberAccount (subaccount); |
| | | if (revertObj.Code == StateCode.SUCCESS) { |
| | | Application.RunOnMainThread (() => { |
| | | subaccountList.Remove (subaccount); |
| | | addSubaccountList (); |
| | | RefreshSubaccountList (); |
| | | }); |
| | | } else { |
| | | //错误提示 |
| | | ShowDeletedSubAccountErrorInfo (revertObj.StateCode); |
| | | IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); |
| | | } |
| | | } catch { |
| | | MainPage.FailureToServer (); |
| | |
| | | } |
| | | } |
| | | |
| | | void modifySubaccount (SubAccountRes subaccount) |
| | | /// <summary> |
| | | /// 添加或者修改成员信息,目前修改功能已去掉 |
| | | /// </summary> |
| | | /// <param name="subaccount"></param> |
| | | void modifySubaccount (ResidenceMemberInfo subaccount) |
| | | { |
| | | bool isModify = true; |
| | | if (subaccount == null) { |
| | | subaccount = new SubAccountRes (); |
| | | subaccount = new ResidenceMemberInfo (); |
| | | isModify = false; |
| | | } |
| | | Dialog dialog = new Dialog (); |
| | | FrameLayout subaccountDialogView = new FrameLayout () { |
| | | Width = Application.GetRealWidth (500), |
| | | Height = Application.GetRealHeight (650 - 100), |
| | | //Height = Application.GetRealHeight (650 - 100), |
| | | Height = Application.GetRealHeight (390), |
| | | BackgroundColor = SkinStyle.Current.DialogColor, |
| | | Radius = 5, |
| | | BorderColor = SkinStyle.Current.Transparent, |
| | |
| | | // BorderColor = SkinStyle.Current.DialogTitle, |
| | | // BorderWidth = 2, |
| | | // TextAlignment = TextAlignment.Center, |
| | | // Text = subaccount.Remark, |
| | | // Text = subaccount.nickName, |
| | | //}; |
| | | //subaccountDialogView.AddChidren (etSubaccountReamrk); |
| | | |
| | | |
| | | Button btnEmail = new Button () { |
| | | X = Application.GetRealWidth (40), |
| | | Y = btnTitle.Bottom + Application.GetRealHeight (30), |
| | |
| | | // 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); |
| | | // //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); |
| | |
| | | //} |
| | | MainPage.Loading.Start ("Please wait..."); |
| | | |
| | | subaccount.Account = addSubaccount; |
| | | //subaccount.Account = addSubaccount; |
| | | //subaccount.Remark = addSubaccountReamrk; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | |
| | | // }); |
| | | //} |
| | | } else { |
| | | //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 (API.BindSubAccount, requestJson); |
| | | if (revertObj.StateCode.ToUpper () == StateCode.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 (API.GetSubAccountByDistributedMark, requesetJson2); |
| | | if (requesetRevertObj2.StateCode.ToUpper () == StateCode.SUCCESS) { |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SubAccountRes>> (requesetRevertObj2.ResponseData.ToString ()); |
| | | //添加子账号 |
| | | var revertObj = HttpServerRequest.Current.BindResidenceMemberAccount (addSubaccount, addSubaccount); |
| | | if (revertObj.Code == StateCode.SUCCESS) { |
| | | var revertObj2 = HttpServerRequest.Current.GetResidenceMemberAccount (); |
| | | if (revertObj2.Code == StateCode.SUCCESS) { |
| | | var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>> (revertObj2.Data.ToString ()); |
| | | subaccountList = responseDataObj; |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.addsuccess), |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.AddedSuccessfully), |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | addSubaccountList (); |
| | | RefreshSubaccountList (); |
| | | dialog.Close (); |
| | | }); |
| | | } else { |
| | | //错误提示 |
| | | IMessageCommon.Current.ShowErrorInfoAlter (revertObj2.Code); |
| | | } |
| | | } else { |
| | | //BindSubAccount错误提示 |
| | | ShowBindSubAccountErrorInfo (revertObj.StateCode); |
| | | IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | |
| | | /// <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; |
| | | ///// <summary> |
| | | ///// 获取子账号列表 |
| | | ///// </summary> |
| | | //void GetSubaccountList () |
| | | //{ |
| | | // subaccountListView.RemoveAll (); |
| | | // subaccountList = new List<ResidenceMemberInfo> (); |
| | | |
| | | } |
| | | 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 (); |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // MainPage.Loading.Start ("Please wait..."); |
| | | // System.Threading.Tasks.Task.Run (() => { |
| | | // try { |
| | | // var revertObj = HttpServerRequest.Current.GetResidenceMemberAccount (); |
| | | // if (revertObj.Code == StateCode.SUCCESS) { |
| | | // var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>> (revertObj.Data.ToString ()); |
| | | // subaccountList = responseDataObj; |
| | | // } else { |
| | | // IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); |
| | | // } |
| | | // } catch (Exception ex) { |
| | | // //MainPage.FailureToServer (); |
| | | // Utlis.WriteLine (ex.Message); |
| | | // } finally { |
| | | // Application.RunOnMainThread (() => { |
| | | // RefreshSubaccountList (); |
| | | // MainPage.Loading.Hide (); |
| | | // }); |
| | | // } |
| | | // }); |
| | | //} |
| | | } |
| | | } |