lss
2022-05-26 a879e5dac4fc7cee747e25a63002c40462cdaef7
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using System;
using System.Collections.Generic;
using HDL_ON.DAL.Server;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI.UI2.PersonalCenter.Visitor
{
    public class VisitorHistoryPage : FrameLayout
    {
        private FrameLayout bodyView;
        private VerticalScrolViewLayout bodyScrolView;
        private List<VisitorTempPassword> pwdList;
 
        public VisitorHistoryPage()
        {
            bodyView = this;
        }
 
        public void LoadPage()
        {
            pwdList = getVisitorPasswordData();
 
            #region 访客记录按钮
            Action click = () =>
            {
                VisitorHistoryPage page = new VisitorHistoryPage();
                MainPage.BasePageView.AddChidren(page);
                page.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
 
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, "访客记录").LoadTopView(click);
            #endregion
 
            bodyScrolView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                VerticalScrollBarEnabled = false,
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(bodyScrolView);
 
            foreach (VisitorTempPassword temPwd in pwdList)
            {
                FrameLayout itemLayout = new FrameLayout()
                {
                    X = Application.GetRealWidth(16),
                    Height = Application.GetRealWidth(50),
                    Width = Application.GetRealWidth(343),
                };
 
                // 访客二维码Text
                itemLayout.AddChidren(new Button()
                {
                    Height = Application.GetRealWidth(20),
                    Y = Application.GetRealWidth(6),
                    Text = "访客二维码",
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.text1Color,
                    TextSize = CSS_FontSize.TextFontSize,
                });
 
                // 时间Btn
                string startTime = temPwd.validBeginTime.Replace("-", "/");
                string endTime = temPwd.validEndTime.Replace("-", "/");
                itemLayout.AddChidren(new Button()
                {
                    Height = Application.GetRealWidth(14),
                    Y = Application.GetRealWidth(30),
                    Text = "时间:" + startTime + " - " + endTime,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                });
 
                // 后退
                itemLayout.AddChidren(new ImageView()
                {
                    Width = Application.GetRealWidth(16),
                    Height = Application.GetRealWidth(16),
                    Gravity = Gravity.CenterRight,
                    ImagePath = "Public/Right.png",
                });
 
                itemLayout.AddChidren(new Button()
                {
                    Height = Application.GetRealWidth(1),
                    Y = Application.GetRealWidth(49),
                    BackgroundColor = CSS_Color.DividingLineColor,
                });
 
                Button btn = new Button();
                itemLayout.AddChidren(btn);//+= (sender, e)
                btn.MouseUpEventHandler += (sender, e) =>
                {
                    VisitorQRCodePage page = new VisitorQRCodePage(temPwd);
                    MainPage.BasePageView.AddChidren(page);
                    page.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                bodyScrolView.AddChidren(itemLayout);
            }
        }
 
        /// <summary>
        /// 获取访客临时密码列表
        /// </summary>
        private List<VisitorTempPassword> getVisitorPasswordData()
        {
            List<VisitorTempPassword> dataList = new List<VisitorTempPassword>();
            Dictionary<string, object> dictionary = new Dictionary<string, object>();
            dictionary.Add("homeId", Entity.DB_ResidenceData.Instance.CurrentRegion.id);
            dictionary.Add("pageNo", 1);
            dictionary.Add("pageSize", 100);
            dictionary.Add("order", "descending");
            dictionary.Add("sort", "id");
 
            var requestJson = HttpUtil.GetSignRequestJson(dictionary);
            ResponsePackNew pack = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GET_TEMP_PASSWORD_LIST, requestJson);
            if (pack != null)
            {
                if (pack.Code == StateCode.SUCCESS)
                {
                    string json = pack.Data.ToString();
                    var o = Newtonsoft.Json.JsonConvert.DeserializeObject<GetTempPasswordList>(json);
                    dataList = o.list;
                }
            }
            return dataList;
        }
 
        private List<TempPasswordInfo> infoList;
        private void getTestData()
        {
            infoList = new List<TempPasswordInfo>();
            TempPasswordInfo info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
            info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
            info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
            info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
            info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
            info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
            info = new TempPasswordInfo();
            info.homeId = 11111;
            info.deviceId = 11111;
            info.phone = "1234567890";
            info.tempPwd = "134234";
            info.useCount = 10;
            info.validBeginTime = "2022/5/10 14:21:00";
            info.validEndTime = "2022/5/12 14:21:00";
            infoList.Add(info);
 
        }
    }
}