wjc
2023-03-30 cae4d4b5b508a666fbd0dff3c2a981fdff841bc8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 我的二维码页面
    /// </summary>
    public class DeliveryQrCodePage : FrameLayout
    {
        FrameLayout bodyView;
 
        public DeliveryQrCodePage()
        {
            bodyView = this;
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="isStartCheckResidenceThread">是否开启住宅监听线程,没有住宅的时候别人扫码添加你为成员的时候调用</param>
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(StringId.ResidentialDelivery)).LoadTopView();
 
            int backViewHeight = Application.GetRealHeight(132) + Application.GetRealWidth(266);
            FrameLayout backView = new FrameLayout()
            {
                Y = Application.GetRealHeight(144),
                Gravity = Gravity.CenterHorizontal,
                Height = Application.GetRealWidth(288),
                Width = Application.GetRealWidth(288),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(8),
            };
            bodyView.AddChidren(backView);
 
          
 
            var btnHomeName = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = backView.Bottom + Application.GetRealWidth(12),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(60),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                Text = Entity.DB_ResidenceData.Instance.CurrentRegion.homeName,
                IsBold = true,
                IsMoreLines = true,
 
            };
            bodyView.AddChidren(btnHomeName);
 
          
 
            //二维码
            int codeWidth = Application.GetRealWidth(266);
            ImageView codeImage = new ImageView()
            {
                Gravity = Gravity.Center,
                Height = codeWidth,
                Width = codeWidth,
                ImageBytes = Scan.BytesFromText(Entity.DB_ResidenceData.Instance.CurrentRegion.deliverUrl,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);
 
 
         
        }
 
        /// <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();
        }
    }
}