wxr
2021-07-01 adc150efb13a0506f45a3c344c3ee2ef2dba8e90
HDL_ON/UI/UI2/4-PersonalCenter/MyQRCodePage.cs
New file
@@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    /// <summary>
    /// 我的二维码页面
    /// </summary>
    public class MyQRCodePage : FrameLayout
    {
        FrameLayout bodyView;
        public MyQRCodePage()
        {
            bodyView = this;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="isStartCheckResidenceThread">是否开启住宅监听线程,没有住宅的时候别人扫码添加你为成员的时候调用</param>
        public void LoadPage(bool isStartCheckResidenceThread = false)
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(StringId.MyQRcode)).LoadTopView();
            int backViewHeight = Application.GetRealHeight(132) + Application.GetRealWidth(266);
            FrameLayout backView = new FrameLayout()
            {
                Y = Application.GetRealHeight(144),
                X = Application.GetRealWidth(20),
                Height = backViewHeight,
                Width = Application.GetRealWidth(335),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(8),
            };
            bodyView.AddChidren(backView);
            #region 头像、昵称、帐号
            FrameLayout headView = new FrameLayout()
            {
                Y = Application.GetRealHeight(16),
                Height = Application.GetRealHeight(60),
            };
            backView.AddChidren(headView);
            ImageView headImage = new ImageView()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetMinRealAverage(60),
                Height = Application.GetMinRealAverage(60),
                Radius = (uint)Application.GetMinRealAverage(30),
                ImagePath = UserInfo.Current.headImagePagePath,
            };
            headView.AddChidren(headImage);
            //用户名称
            var btnUserName = new Button()
            {
                X = headImage.Right + Application.GetRealWidth(12),
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(30),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.UsersWhoNameIsEmpty,
                IsBold = true
            };
            headView.AddChidren(btnUserName);
            if (!string.IsNullOrEmpty(UserInfo.Current.userName))
            {
                btnUserName.Text = UserInfo.Current.userName;
            }
            //用户帐号
            var btnEmail = new Button()
            {
                X = headImage.Right + Application.GetRealWidth(12),
                Y = btnUserName.Bottom,
                Height = Application.GetRealHeight(30),
                TextAlignment = TextAlignment.TopLeft,
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = UserInfo.Current.AccountString
            };
            headView.AddChidren(btnEmail);
            #endregion
            //二维码
            int codeWidth = Application.GetRealWidth(266);
            ImageView codeImage = new ImageView()
            {
                X = Application.GetRealWidth(35),
                Y = Application.GetRealHeight(104),
                Height = codeWidth,
                Width = codeWidth,
                ImageBytes = Scan.BytesFromText(UserInfo.Current.AccountString, codeWidth, codeWidth),
            };
            backView.AddChidren(codeImage);
            ////二维码中心头像
            //int imageWidth = Application.GetMinRealAverage(60);
            //int imageX = codeImage.X + (codeWidth - imageWidth) / 2;
            //int imageY = codeImage.Y + (codeWidth - imageWidth) / 2;
            //ImageView headImage2 = new ImageView()
            //{
            //    X = imageX,
            //    Y = imageY,
            //    Width = imageWidth,
            //    Height = imageWidth,
            //    ImagePath = UserInfo.Current.headImagePagePath,
            //    BorderColor = CSS_Color.MainBackgroundColor,
            //    BorderWidth = (uint)Application.GetRealWidth(2),
            //    Radius = (uint)Application.GetMinRealAverage(30),
            //};
            //backView.AddChidren(headImage2);
            if (isStartCheckResidenceThread)
            {
                //开启检测住宅是否已经添加了的线程
                this.StartCheckResidenceThread();
            }
        }
        /// <summary>
        /// 开启检测住宅是否已经添加了的线程
        /// </summary>
        private void StartCheckResidenceThread()
        {
            //获取住宅列表的参数
            var requestJson = DAL.Server.HttpUtil.GetSignRequestJson(new DAL.Server.GetHomeListObj() { homeType = HomeTypeEnum.ALL.ToString() });
            new System.Threading.Thread(() =>
            {
                while (this.Parent != null)
                {
                    System.Threading.Thread.Sleep(4000);
                    if (this.Parent == null)
                    {
                        break;
                    }
                    //访问云端获取列表
                    var resultObj = DAL.Server.HttpUtil.RequestHttpsPost(DAL.Server.NewAPI.API_POST_Gethomepager, requestJson);
                    if (resultObj.Code == DAL.Server.StateCode.SUCCESS)
                    {
                        var homeList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>>(resultObj.Data.ToString());
                        if (homeList == null || homeList.Count == 0)
                        {
                            //如果还没有住宅的话,继续下一次检测
                            continue;
                        }
                        //调用On原来的方法,刷新住宅列表及其缓存
                        var pm = new DAL.Server.HttpServerRequest();
                        pm.GetHomePager();
                        Application.RunOnMainThread(() =>
                        {
                            if (this.Parent == null)
                            {
                                return ;
                            }
                            //跳转页面----
                            MainPage.GoUserPage(true, false, () =>
                            {
                                //显示欢迎回家的弹窗界面
                                var form = new WellcomToHomeForm();
                                form.ShowForm();
                            });
                        });
                        break;
                    }
                }
            })
            { IsBackground = true }.Start();
        }
    }
}