tzy
2021-05-25 65bcedda4d8e3ff6500dbf59a4e607d96e469375
HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/Transfer/TransferInputPage.cs
@@ -1,159 +1,160 @@
using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Stan;
namespace HDL_ON.UI
{
    /// <summary>
    /// 过户输入账号界面
    /// </summary>
    public class TransferInputPage : FrameLayout
    public class TransferInputPage : EditorCommonForm
    {
        /// <summary>
        ///
        /// </summary>
        FrameLayout bodyView;
        #region ■ 变量声明___________________________
        public TransferInputPage()
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            bodyView = this;
            //过户
            base.SetTitleText(Language.StringByID(StringId.Transfer));
            //初始化中部信息
            this.InitMiddleFrame();
        }
        /// <summary>
        ///
        /// 初始化中部信息
        /// </summary>
        public void LoadPage()
        private void InitMiddleFrame()
        {
            BackgroundColor = CSS_Color.BackgroundColor;
            //清空bodyFrame
            this.ClearBodyFrame();
            new TopViewDiv(bodyView, Language.StringByID(StringId.Transfer)).LoadTopView();
            //白色背景
            var frameBack = new FrameLayout();
            frameBack.Y = Application.GetRealHeight(8);
            frameBack.BackgroundColor = CSS_Color.MainBackgroundColor;
            bodyFrameLayout.AddChidren(frameBack);
            #region 账号填写
            var accountView = new FrameLayout()
            //请输入接收方账号
            var rowInput = new FrameRowControl();
            rowInput.Height = Application.GetRealHeight(50);
            frameBack.AddChidren(rowInput);
            //图标
            rowInput.AddLeftIcon(24, "LoginIcon/AccountIcon.png");
            //输入框
            var txtInput = rowInput.AddLeftInput(string.Empty, 300);
            txtInput.PlaceholderText = Language.StringByID(StringId.PleaseInputReceiverAccount);
            //底线
            rowInput.AddBottomLine();
            //变更容器高度
            frameBack.Height = rowInput.Bottom + Application.GetRealHeight(10);
            //过户
            var btnMigrate = new BottomClickButton(220);
            btnMigrate.TextID = StringId.Transfer;
            btnMigrate.Y = frameBack.Bottom + Application.GetRealHeight(79);
            bodyFrameLayout.AddChidren(btnMigrate);
            btnMigrate.ButtonClickEvent += (sender, e) =>
            {
                Y = Application.GetRealHeight(72),
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS_Color.MainBackgroundColor
            };
            bodyView.AddChidren(accountView);
                string account = txtInput.Text.Trim();
                if (account == string.Empty)
                {
                    return;
                }
                if (account == UserInfo.Current.userEmailInfo || account == UserInfo.Current.userMobileInfo)
                {
                    //不能自己过户给自己
                    HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(StringId.YouCannotTransferOwnershipToYourself));
                    return;
                }
                //搜索账号信息
                var accountInfo = this.SearchAccountInfoByAccount(account);
                if (accountInfo == null)
                {
                    return;
                }
            var btnAccountIcon = new Button()
                this.CloseForm();
                var form = new TransferUserConfirmPage();
                form.AddForm(accountInfo);
            };
            //扫描二维码
            var btnQrcode = new NormalViewControl(220, 32, true);
            btnQrcode.Y = btnMigrate.Bottom + Application.GetRealWidth(6);
            btnQrcode.TextColor = CSS_Color.MainColor;
            btnQrcode.Gravity = Gravity.CenterHorizontal;
            btnQrcode.TextAlignment = TextAlignment.Center;
            btnQrcode.TextID = StringId.ScanQRCoden;
            bodyFrameLayout.AddChidren(btnQrcode);
            btnQrcode.ButtonClickEvent += (sender, e) =>
            {
                X = Application.GetRealWidth(16),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(24),
                Height = Application.GetMinRealAverage(24),
                UnSelectedImagePath = "LoginIcon/AccountIcon.png",
                Scan.OpenScan((scanString) =>
                {
                    if (string.IsNullOrEmpty(scanString) == true)
                    {
                        return;
                    }
                    if (scanString == UserInfo.Current.userEmailInfo || scanString == UserInfo.Current.userMobileInfo)
                    {
                        //不能自己过户给自己
                        HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(StringId.YouCannotTransferOwnershipToYourself));
                        return;
                    }
                    //搜索账号信息
                    var accountInfo = this.SearchAccountInfoByAccount(scanString);
                    if (accountInfo == null)
                    {
                        return;
                    }
                    this.CloseForm();
                    var form = new TransferUserConfirmPage();
                    form.AddForm(accountInfo);
                });
            };
            accountView.AddChidren(btnAccountIcon);
            var etAccount = new EditText()
            {
                X = Application.GetRealWidth(52),
                Width = Application.GetRealWidth(307),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                PlaceholderTextColor = CSS_Color.PromptingColor1,
                PlaceholderText = "请输入接收方账号",
            };
            accountView.AddChidren(etAccount);
            var btnLine = new Button()
            {
                BackgroundColor = CSS_Color.DividingLineColor,
                Height = Application.GetRealHeight(1),
                Y = accountView.Height - Application.GetRealHeight(1),
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(343),
            };
            accountView.AddChidren(btnLine);
            #endregion
            #region 账号填写
            var accountConfirmView = new FrameLayout()
            {
                Y = accountView.Bottom,
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS_Color.MainBackgroundColor
            };
            bodyView.AddChidren(accountConfirmView);
            var btnAccountConfirmIcon = new Button()
            {
                X = Application.GetRealWidth(16),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(24),
                Height = Application.GetMinRealAverage(24),
                UnSelectedImagePath = "LoginIcon/AccountIcon.png",
            };
            accountConfirmView.AddChidren(btnAccountConfirmIcon);
            var etAccountConfirm = new EditText()
            {
                X = Application.GetRealWidth(52),
                Width = Application.GetRealWidth(307),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                PlaceholderTextColor = CSS_Color.PromptingColor1,
                PlaceholderText = "请再次输入接收方账号",
            };
            accountConfirmView.AddChidren(etAccountConfirm);
            //var btnLine2 = new Button()
            //{
            //    BackgroundColor = CSS_Color.DividingLineColor,
            //    Height = Application.GetRealHeight(1),
            //    Y = accountConfirmView.Height - Application.GetRealHeight(1),
            //};
            //accountConfirmView.AddChidren(btnLine2);
            #endregion
            var btnTip = new Button()
            {
                Y = accountConfirmView.Bottom + Application.GetRealHeight(12),
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(343),
                TextAlignment = TextAlignment.TopLeft,
                TextColor = CSS_Color.AuxiliaryColor2,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = "*请确认账号无误,在数据转移过程中不可取消操作",
                IsMoreLines = true
            };
            bodyView.AddChidren(btnTip);
            var btnConfirm = new ConfirmButton()
            {
                Y = Application.GetRealHeight(251),
                Text = "过户",
            };
            bodyView.AddChidren(btnConfirm);
            btnConfirm.MouseUpEventHandler = (sender, e) => {
                var skipPage = new TransferUserConfirmPage();
                MainPage.BasePageView.AddChidren(skipPage);
                skipPage.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            Button btnEmailOption = new Button()
            {
                Y = btnConfirm.Bottom + Application.GetRealWidth(6),
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealWidth(32),
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.MainColor,
                Gravity = Gravity.CenterHorizontal,
                TextAlignment = TextAlignment.Center,
                Text = "扫描二维码过户"
            };
            bodyView.AddChidren(btnEmailOption);
        }
        #endregion
        #region ■ 搜索账号___________________________
        /// <summary>
        /// 搜索账号信息
        /// </summary>
        /// <param name="i_account">搜索的账号</param>
        /// <returns></returns>
        private AccountInfoResult SearchAccountInfoByAccount(string i_account)
        {
            var result = new DAL.Server.HttpServerRequest().GetMemberInfoByAccount(i_account);
            if (result.Code == DAL.Server.StateCode.ACCOUNT_NOT_EXIST)
            {
                //目标账号并不存在
                HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(StringId.TargetAcountDoesNotExist));
                return null;
            }
            if (result.Code != DAL.Server.StateCode.SUCCESS)
            {
                DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                return null;
            }
            var accountInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(result.Data.ToString());
            accountInfo.Account = i_account;
            if (accountInfo.MemberName == string.Empty)
            {
                accountInfo.MemberName = accountInfo.Account;
            }
            return accountInfo;
        }
        #endregion
    }
}