黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Suggestion/FeedbackForm.cs
@@ -12,9 +12,9 @@
        #region ■ 变量声明___________________________
        /// <summary>
        /// 0:Bug、1:优化、2:新需求
        /// 1:BUG、2:优化(OPTIMIZE)、3:新需求(REQUIRE)
        /// </summary>
        private int typeMode = 0;
        private string typeMode = string.Empty;
        /// <summary>
        /// 意见反馈剩余次数
        /// </summary>
@@ -53,8 +53,8 @@
            bodyFrameLayout.AddChidren(frameInput);
            //字数
            var btnFild = new NormalViewControl(120, 60, true);
            btnFild.X = frameInput.Width - ControlCommonResourse.XXLeft - Application.GetRealWidth(120);
            var btnFild = new NormalViewControl(150, 60, true);
            btnFild.X = frameInput.Width - HdlControlResourse.XXLeft - Application.GetRealWidth(150);
            btnFild.Y = Application.GetRealHeight(503);
            btnFild.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnFild.TextSize = 12;
@@ -64,7 +64,7 @@
            //您的反馈和意见会让我们变得更好
            var txtInput = new EditTextView();
            txtInput.Width = bodyFrameLayout.Width - ControlCommonResourse.XXLeft * 2;
            txtInput.Width = bodyFrameLayout.Width - HdlControlResourse.XXLeft * 2;
            txtInput.Height = Application.GetRealHeight(470);
            txtInput.Y = Application.GetRealHeight(32);
            txtInput.TextAlignment = TextAlignment.TopLeft;
@@ -74,30 +74,44 @@
            txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uYouSuggestionMsg);
            frameInput.AddChidren(txtInput);
            txtInput.InitIosPlaceholderUILabelWithHeight(Application.GetRealHeight(60));
            txtInput.TextChangeEventHandler += (sender, txtvalue) =>
            //输入值改变事件
            Action<View, string> txtInputChangedEvent = (sender, txtValue) =>
            {
                if (this.suggestionCount <= 0)
                {
                    return;
                }
                int length = txtvalue.Length;
                if (length > 500)
                var newValue = txtValue;
                //如果输入的值,已经大于指定的数,则截取
                if (newValue.Length > 500)
                {
                    if (btnSubmit.CanClick == true) { btnSubmit.CanClick = false; }
                    btnFild.Text = "0";
                    return;
                    //截取指定的byte字节
                    newValue = newValue.Substring(0, 500);
                    txtInput.Text = newValue;
                    //将光标至于最后
#if Android
                    txtInput.SetSelectionEnd();
#endif
                }
                int length = newValue.Length;
                if (length == 0)
                {
                    if (btnSubmit.CanClick == true) { btnSubmit.CanClick = false; }
                }
                else
                {
                    if (btnSubmit.CanClick == false) { btnSubmit.CanClick = true; }
                    if (btnSubmit.CanClick == false)
                    {
                        //变灰色字体
                        btnFild.TextColor = UserCenterColor.Current.TextGrayColor1;
                        btnSubmit.CanClick = true;
                    }
                }
                btnFild.Text = (500 - length).ToString();
            };
            txtInput.TextChangeEventHandler += txtInputChangedEvent;
            var framType = new FrameLayout();
            framType.Height = Application.GetRealHeight(150);
@@ -111,12 +125,12 @@
            //反馈类型
            var btnType = new NormalViewControl(220, 60, true);
            btnType.X = ControlCommonResourse.XXLeft;
            btnType.X = HdlControlResourse.XXLeft;
            btnType.Gravity = Gravity.CenterVertical;
            btnType.TextID = R.MyInternationalizationString.uSuggestionType;
            framType.AddChidren(btnType);
            //Bug
            var frameBug = new FrameLayoutControl();
            var frameBug = new FrameLayoutStatuControl();
            frameBug.UseClickStatu = false;
            frameBug.Width = Application.GetRealWidth(200);
            frameBug.X = Application.GetRealWidth(314);
@@ -140,11 +154,11 @@
                    btnBugIcon.IsSelected = true;
                    btnOptimizationIcon.IsSelected = false;
                    btnDemandIcon.IsSelected = false;
                    this.typeMode = 0;
                    this.typeMode = "BUG";
                }
            };
            //优化
            var frameOptimization = new FrameLayoutControl();
            var frameOptimization = new FrameLayoutStatuControl();
            frameOptimization.UseClickStatu = false;
            frameOptimization.Width = Application.GetRealWidth(200);
            frameOptimization.X = Application.GetRealWidth(524);
@@ -168,11 +182,11 @@
                    btnBugIcon.IsSelected = false;
                    btnDemandIcon.IsSelected = false;
                    this.typeMode = 1;
                    this.typeMode = "OPTIMIZE";
                }
            };
            //新需求
            var frameDemand = new FrameLayoutControl();
            var frameDemand = new FrameLayoutStatuControl();
            frameDemand.UseClickStatu = false;
            frameDemand.Width = Application.GetRealWidth(200);
            frameDemand.X = Application.GetRealWidth(734);
@@ -196,7 +210,7 @@
                    btnBugIcon.IsSelected = false;
                    btnOptimizationIcon.IsSelected = false;
                    this.typeMode = 2;
                    this.typeMode = "REQUIRE";
                }
            };
@@ -205,16 +219,16 @@
            frameEmail.BackgroundColor = UserCenterColor.Current.White;
            frameEmail.Y = framType.Bottom + Application.GetRealHeight(23);
            bodyFrameLayout.AddChidren(frameEmail);
            //邮箱地址
            var btnEmail = new NormalViewControl(220, 60, true);
            btnEmail.X = ControlCommonResourse.XXLeft;
            btnEmail.Gravity = Gravity.CenterVertical;
            btnEmail.TextID = R.MyInternationalizationString.uEmailAddress;
            frameEmail.AddChidren(btnEmail);
            var txtEmail = new TextInputControl(500, 60, true);
            //联系方式
            var btnContact = new NormalViewControl(220, 60, true);
            btnContact.X = HdlControlResourse.XXLeft;
            btnContact.Gravity = Gravity.CenterVertical;
            btnContact.TextID = R.MyInternationalizationString.uContactInformation;
            frameEmail.AddChidren(btnContact);
            var txtEmail = new TextInputControl(720, 60, true);
            txtEmail.X = Application.GetRealWidth(314);
            txtEmail.Gravity = Gravity.CenterVertical;
            txtEmail.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputYouEmailAddress);
            txtEmail.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputYourContactInformation);
            frameEmail.AddChidren(txtEmail);
            //提交
@@ -224,17 +238,16 @@
            btnSubmit.CanClick = false;
            btnSubmit.ButtonClickEvent += (sender, e) =>
            {
                //如果是虚拟住宅,则此功能无效
                if (Common.Config.Instance.Home.IsVirtually == true)
                {
                    return;
                }
                //上传意见
                this.UploadSuggestion(txtInput.Text, txtEmail.Text);
            };
            var strFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.SuggestionFile);
            if (System.IO.File.Exists(strFile) == false)
            {
                return;
            }
            var data = UserCenterLogic.LoadFileContent(strFile);
            var data = HdlFileLogic.Current.ReadFileTextContent(HdlFileNameResourse.SuggestionFile);
            if (data != null)
            {
                var strNowData = DateTime.Now.ToString("yyyyMMdd");
@@ -263,32 +276,25 @@
        /// <param name="email"></param>
        private void UploadSuggestion(string strContent, string email)
        {
            HdlThreadLogic.Current.RunThread(async() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                var pra = new
                var pra = new { contactWay = email, content = strContent, feedbackType = this.typeMode };
                var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/app/feedback/add", RestSharp.Method.POST, pra);
                //检测状态码
                if (HdlCheckLogic.Current.CheckNetCode(result, ShowNetCodeMode.YES) == false)
                {
                    RequestVersion = Common.CommonPage.RequestVersion,
                    LoginAccessToken = Common.Config.Instance.Token,
                    Content = strContent,
                    OpinionFeedbackType = this.typeMode,
                    Email = email
                };
                var result = await UserCenterLogic.GetResultStatuByRequestHttps("App/AddOpinionFeedback", false, pra);
                if (result == true)
                {
                    //保存次数
                    this.suggestionCount--;
                    var strFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid, DirNameResourse.SuggestionFile);
                    var byteData = System.Text.Encoding.UTF8.GetBytes(this.suggestionCount + DateTime.Now.ToString("yyyyMMdd"));
                    //写入内容
                    Shared.IO.FileUtils.WriteFileByBytes(strFile, byteData);
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //显示成功的界面
                        this.ShowSuccessMsg();
                    });
                    return;
                }
                //保存次数
                this.suggestionCount--;
                //写入内容
                HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.SuggestionFile, this.suggestionCount + DateTime.Now.ToString("yyyyMMdd"));
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //显示成功的界面
                    this.ShowSuccessMsg();
                });
            });
        }