JLChen
2020-12-21 8677d9602ffa36554b2f0923f978bd3c054a905d
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
using System;
using Shared;
using HDL_ON.UI.CSS;
using System.Collections.Generic;
using System.Threading;
using HDL_ON.DAL.Server;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 功能介绍
    /// </summary>
    public class FunctionIntroductionPage : FrameLayout
    {
        FrameLayout bodyView;
        /// <summary>
        /// 
        /// </summary>
        FrameLayout emptyTipFrameLayout;
        /// <summary>
        /// 当前
        /// </summary>
        VerticalScrolViewLayout bodyScrolView;
        /// <summary>
        /// 内容为空提示View
        /// </summary>
        FrameLayout emptyTipView;
        /// <summary>
        /// 功能介绍List
        /// </summary>
        List<APPFunctionURLInfo> functionURLInfoList = new List<APPFunctionURLInfo>();
 
        /// <summary>
        /// 
        /// </summary>
        public FunctionIntroductionPage()
        {
            bodyView = this;
        }
 
        /// <summary>
        /// 
        /// </summary>
        public void LoadPage()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.FunctionIntroduced)).LoadTopView();
 
            int bodyY = Application.GetRealHeight(64);
            bodyScrolView = new VerticalScrolViewLayout()
            {
                Y = bodyY,
                Height = bodyView.Height - bodyY,
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(bodyScrolView);
 
            //AddEmptyTipView();
            //
            GetFunctionIntroductionList();
        }
 
        /// <summary>
        /// 添加内容为空提示页面
        /// </summary>
        void AddEmptyTipView()
        {
            emptyTipView = new FrameLayout()
            {
                Height = bodyScrolView.Height,
                Width = bodyScrolView.Width,
            };
            bodyScrolView.AddChidren(emptyTipView);
 
            var tipView = new EmptyTipView()
            {
                Gravity = Gravity.Center
            };
            emptyTipView.AddChidren(tipView);
        }
 
        /// <summary>
        /// 加载功能介绍列表查询
        /// </summary>
        /// <param name="VerticalScrolViewMiddle"></param>
        void AddRowView(VerticalScrolViewLayout VerticalScrolViewMiddle, APPFunctionURLInfo functionInfo)
        {
            var rowView = new FrameLayout()
            {
                Height = Application.GetRealWidth(54),
            };
            VerticalScrolViewMiddle.AddChidren(rowView);
 
            //标题
            var btnTilte = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealWidth(8),
                Width = Application.GetRealWidth(320),
                Height = Application.GetRealWidth(20),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                Text = functionInfo.Title
            };
            rowView.AddChidren(btnTilte);
 
            //副标题
            var btnSubtitle = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = btnTilte.Bottom + Application.GetRealWidth(4),
                Width = Application.GetRealWidth(320),
                Height = Application.GetRealWidth(14),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                //Text = functionInfo.CreateTime
            };
 
            rowView.AddChidren(btnSubtitle);
 
            var btnGo = new Button()
            {
                X = Application.GetRealWidth(343),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(16),
                Height = Application.GetRealWidth(16),
                UnSelectedImagePath = "Public/Right.png",
            };
 
            rowView.AddChidren(btnGo);
 
            var lineView = new LineView(rowView.Height);
            rowView.AddChidren(lineView);
 
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                new WebViewDialog().LoadPage(functionInfo.Title, functionInfo.Url);
            };
 
            btnTilte.MouseUpEventHandler = eventHandler;
            btnSubtitle.MouseUpEventHandler = eventHandler;
            btnGo.MouseUpEventHandler = eventHandler;
 
            if (Language.CurrentLanguage == "Chinese")
            {
                btnSubtitle.Text = Utlis.UnixToDateTimeWithFormatMS(functionInfo.CreateTime, "MM月dd日");
            }
            else
            {
                btnSubtitle.Text = Utlis.UnixToDateTimeWithFormatMS(functionInfo.CreateTime, "MM/dd");
            }
                
        }
 
        /// <summary>
        /// 功能介绍列表查询
        /// </summary>
        void GetFunctionIntroductionList()
        {
            bodyScrolView.RemoveAll();
            if (functionURLInfoList == null)
            {
                functionURLInfoList = new List<APPFunctionURLInfo>();
            }
            else
            {
                functionURLInfoList.Clear();
            }
 
            var waitPage = new Loading();
            bodyView.AddChidren(waitPage);
            waitPage.Start(Language.StringByID(StringId.PleaseWait));
 
            new Thread(() =>
            {
                try
                {
 
                    Dictionary<string, object> AppName = new Dictionary<string, object>();
                    //ON_Plus 2
                    AppName.Add("appName", 2);
 
                    var requestJson = HttpUtil.GetSignRequestJson(AppName);
 
                    var result = HttpUtil.RequestHttpsPost(NewAPI.API_POST_FunctionIntroductionList, requestJson);
                    if (result.Code == StateCode.SUCCESS)
                    {
                        functionURLInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<APPFunctionURLInfo>>(result.Data.ToString());
                        Application.RunOnMainThread(() =>
                        {
                            if (functionURLInfoList != null && functionURLInfoList.Count > 0)
                            {
                                //加载刷新List
                                LoadAPPFunctionURLInfoView(functionURLInfoList);
                            }
                            else
                            {
                                AddEmptyTipView();
                            }
                        });
                    }
                    else
                    {
                        Application.RunOnMainThread(() =>
                        {
                            AddEmptyTipView();
                        });
                        IMessageCommon.Current.ShowErrorInfoAlter(result.Code);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        if (waitPage != null)
                        {
                            waitPage.RemoveFromParent();
                            waitPage = null;
                        }
                    });
                }
            })
            { IsBackground = true }.Start();
        }
 
        /// <summary>
        /// 加载功能介绍CellView
        /// </summary>
        void LoadAPPFunctionURLInfoView(List<APPFunctionURLInfo> mList)
        {
            foreach (var info in mList)
            {
                AddRowView(bodyScrolView, info);
            }
        }
 
        //#region 测试
        //List<APPFunctionURLInfo> list = new List<APPFunctionURLInfo>();
        ///// <summary>
        ///// 
        ///// </summary>
        //void TestLoad()
        //{
        //    list.Add(new APPFunctionURLInfo()
        //    {
        //        Title = "HDL ON PRO 1.0.10 主要更新",
        //        CreateTime = "11月26",
        //        Url = Constant.URL_PRIVACYPOLICY,
        //    });
 
        //    list.Add(new APPFunctionURLInfo()
        //    {
        //        Title = "HDL ON PRO 1.0.09 主要更新",
        //        CreateTime = "10月26",
        //        Url = Constant.URL_PRIVACYPOLICY,
        //    });
 
        //    list.Add(new APPFunctionURLInfo()
        //    {
        //        Title = "HDL ON PRO 1.0.08 主要更新",
        //        CreateTime = "09月26",
        //        Url = Constant.URL_PRIVACYPOLICY,
        //    });
 
        //    foreach (var info in list)
        //    {
        //        AddRowView(bodyScrolView, info);
        //    }
        //}
        //#endregion
    }
 
 
    /// <summary>
    /// 功能介绍网页信息
    /// </summary>
    [System.Serializable]
    public class APPFunctionURLInfo
    {
        /// <summary>
        /// 功能介绍标题
        /// </summary>
        public string Title;
        /// <summary>
        /// 功能介绍发布事件
        /// </summary>
        public long CreateTime;
        /// <summary>
        /// 功能介绍对应的HTML地址
        /// </summary>
        public string Url;
    }
}