xm
2020-12-14 d6fb0646531172f23648441c224cdcccd721b894
ZigbeeApp/Shared/Phone/UserCenter/Transfer/TransferResidenceMainForm.cs
New file
@@ -0,0 +1,180 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter.Transfer
{
    /// <summary>
    /// 住宅过户的主界面
    /// </summary>
    public class TransferResidenceMainForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 1:移交给用户  2:授权给调试人员
        /// </summary>
        private int TransferDiv = 0;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_TransferDiv">1:移交给用户  2:授权给调试人员</param>
        public void ShowForm(int i_TransferDiv)
        {
            this.TransferDiv = i_TransferDiv;
            //设置头部信息
            base.SetTitleText(i_TransferDiv == 1
                ? Language.StringByID(R.MyInternationalizationString.HandoverToUser).Replace("{0}", string.Empty)
                : Language.StringByID(R.MyInternationalizationString.AuthorizedToCommissioningPersonnel).Replace("{0}", string.Empty));
            //初始化中部信息
            this.InitMiddleFrame();
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //转移图片
            var btnPictrue = new PicViewControl(804, 268);
            btnPictrue.Gravity = Gravity.CenterHorizontal;
            btnPictrue.Y = Application.GetRealHeight(222);
            btnPictrue.UnSelectedImagePath = "Item/TransferOfResidence.png";
            bodyFrameLayout.AddChidren(btnPictrue);
            //转移住宅到其他Evoyo Home账号
            var btnMsg1 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(90), false);
            btnMsg1.Y = Application.GetRealHeight(593);
            btnMsg1.TextSize = 20;
            btnMsg1.IsBold = true;
            btnMsg1.TextAlignment = TextAlignment.Center;
            btnMsg1.Text = this.TransferDiv == 1 ? "转移住宅到其他用户账号" : "转移住宅到其他调试人员账号";
            bodyFrameLayout.AddChidren(btnMsg1);
            //该操作不可逆,请注意:
            var btnTip = new NormalViewControl(900, 60, true);
            btnTip.X = Application.GetRealWidth(135);
            btnTip.Y = btnMsg1.Bottom + Application.GetRealHeight(257);
            btnTip.TextID = R.MyInternationalizationString.uThisOperationIsIrreversiblePleaseNote;
            bodyFrameLayout.AddChidren(btnTip);
            //1.接收方为有效注册账号
            var btnTipMsg1 = new NormalViewControl(900, 55, true);
            btnTipMsg1.X = btnTip.X;
            btnTipMsg1.Y = btnTip.Bottom + Application.GetRealHeight(30);
            btnTipMsg1.TextSize = 12;
            btnTipMsg1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnTipMsg1.Text = "1.接收方为有效注册账号";
            bodyFrameLayout.AddChidren(btnTipMsg1);
            //2.接收方与转移方不可以为同一个账号
            var btnTipMsg2 = new NormalViewControl(900, 55, true);
            btnTipMsg2.X = btnTip.X;
            btnTipMsg2.Y = btnTipMsg1.Bottom + Application.GetRealHeight(30);
            btnTipMsg2.TextSize = 12;
            btnTipMsg2.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnTipMsg2.Text = "2.接收方与转移方不可以为同一个账号";
            bodyFrameLayout.AddChidren(btnTipMsg2);
            //3.转移成功后,将取消转移方成员对该住宅的使用权
            var btnTipMsg3 = new NormalViewControl(900, 55, true);
            btnTipMsg3.X = btnTip.X;
            btnTipMsg3.Y = btnTipMsg2.Bottom + Application.GetRealHeight(30);
            btnTipMsg3.TextSize = 12;
            btnTipMsg3.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnTipMsg3.Text = "3.转移成功后,将取消转移方成员对该住宅的使用权";
            bodyFrameLayout.AddChidren(btnTipMsg3);
            //输入账号
            var btnInputAccount = new BottomClickButton(372);
            btnInputAccount.Gravity = Gravity.Frame;
            btnInputAccount.X = Application.GetRealWidth(115);
            btnInputAccount.TextID = R.MyInternationalizationString.uInputAccount;
            bodyFrameLayout.AddChidren(btnInputAccount);
            btnInputAccount.ButtonClickEvent += (sender, e) =>
            {
                var form = new TransferResidenceByIdForm();
                form.AddForm(this.TransferDiv);
            };
            //扫描二维码的背景
            var btnScanGroud = new NormalViewControl(429, 184, true);
            btnScanGroud.Y = Application.GetRealHeight(1454);
            btnScanGroud.X = btnInputAccount.Right + Application.GetRealWidth(78);
            btnScanGroud.UnSelectedImagePath = "Item/ScanQrCodeGroud.png";
            bodyFrameLayout.AddChidren(btnScanGroud);
            //扫描二维码
            var btnScanQrCode = new BottomClickButton(372);
            btnScanQrCode.Gravity = Gravity.Frame;
            btnScanQrCode.X = btnScanGroud.X + Application.GetRealWidth(28);
            btnScanQrCode.TextID = R.MyInternationalizationString.uScanQRcode;
            btnScanQrCode.BackgroundColor = UserCenterColor.Current.Transparent;
            btnScanQrCode.UseClickStatu = false;
            bodyFrameLayout.AddChidren(btnScanQrCode);
            btnScanQrCode.ButtonClickEvent += (sender, e) =>
            {
                QRCode.ScanQRcode((qrCode) =>
                {
                    if (string.IsNullOrEmpty(qrCode) == true)
                    {
                        return;
                    }
                    //搜索ID
                    HdlThreadLogic.Current.RunThread(() =>
                    {
                        this.SearchMemberInfo(qrCode);
                    });
                },
                Language.StringByID(R.MyInternationalizationString.uCancel),
                Language.StringByID(R.MyInternationalizationString.uFlashlamp),
                Language.StringByID(R.MyInternationalizationString.uScanQRcode));
            };
        }
        #endregion
        #region ■ 搜索ID_____________________________
        /// <summary>
        /// 搜索指定ID的信息
        /// </summary>
        /// <param name="accountId">成员ID</param>
        /// <param name="txtMsg">信息控件</param>
        private void SearchMemberInfo(string accountId)
        {
            var pra = new AccountInfoPra();
            pra.Account = accountId;
            var byteData = UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string> { "NotCheck" });
            if (byteData == null)
            {
                //异常
                return;
            }
            var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResponsePack>(System.Text.Encoding.UTF8.GetString(byteData));
            if (revertObj.StateCode == "AccountNoExists")
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //账号信息
                    var form = new Member.MemberNotEsixtForm();
                    form.AddForm(Language.StringByID(R.MyInternationalizationString.uAccountInfo));
                });
                return;
            }
            var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(revertObj.ResponseData.ToString());
            infoResult.Account = accountId;
            HdlThreadLogic.Current.RunMain(() =>
            {
                var form2 = new AddMemberInfoForm();
                form2.AddForm(infoResult, this.TransferDiv);
            });
        }
        #endregion
    }
}