From 5dde755029a86cf8e7052f4878e7c64b94715c38 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 13 六月 2020 18:25:05 +0800
Subject: [PATCH] '首页完善'

---
 WindowsFormsApp1/Main.cs |  268 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 222 insertions(+), 46 deletions(-)

diff --git a/WindowsFormsApp1/Main.cs b/WindowsFormsApp1/Main.cs
index 436e801..ff2e208 100644
--- a/WindowsFormsApp1/Main.cs
+++ b/WindowsFormsApp1/Main.cs
@@ -1,5 +1,8 @@
 锘縰sing HZH_Controls.Controls;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using System;
+using System.CodeDom;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -10,6 +13,7 @@
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using WindowsFormsApp1.entity;
+using WindowsFormsApp1.utils;
 using WindowsFormsApp1.utils.ui;
 
 namespace WindowsFormsApp1
@@ -22,9 +26,53 @@
             InitSkin();
             InitDataGridView();
             InitData();
-            SetClassData();
             initTextBox();
+         
+
+            //
+
+            FirstOrderSubInfo goods = new FirstOrderSubInfo();
+            goods.Title = "鎷夐潰璇磋睔楠ㄧ暘鑼勮偉鐗�3琚嬪崐骞查矞闈㈤�熼鏂逛究闈㈢伀閿呴潰闈炴补鐐告场闈究闈㈢伀閿呴潰闈炴补鐐告场闈究闈㈢伀閿呴潰闈炴补鐐告场闈�";
+            List<String> imgList = new List<String>();
+            imgList.Add("https://img.alicdn.com/imgextra/i1/725677994/O1CN013XSsBA28vIkpIkQwp_!!725677994.jpg_430x430q90.jpg");
+            imgList.Add("https://img.alicdn.com/imgextra/i4/725677994/O1CN01iTYmFx28vIjvvoUOn_!!725677994.jpg_430x430q90.jpg");
+            goods.ImgList = imgList;
+            SetGoodsDetail(goods);
         }
+
+
+        //鍒濆鍖栫毊鑲ら鑹�
+        private void InitSkin()
+        {
+            //this.textBox
+
+        }
+
+        private void InitData()
+        {
+            this.ucHorizontalList1.SelectedItemEvent += new System.EventHandler(this.click_Class);
+
+            List<FirstOrderSubInfo> infoList = new List<FirstOrderSubInfo>();
+
+            for (int i = 0; i < 20; i++)
+            {
+                FirstOrderSubInfo info = new FirstOrderSubInfo();
+                info.ActualPrice = "12.00";
+                info.Commission = "1.02";
+                info.CommissionRate = "20%";
+                info.CouponPrice = "15.00";
+                info.GoodsId = "123456";
+                info.ImgList = new List<string>();
+                info.ImgList.Add("http://");
+                info.LijinAmount = "20.21";
+                info.Title = "娴嬭瘯";
+                info.ZkPrice = "21.02";
+                infoList.Add(info);
+            }
+            SetGoodsData(true, infoList);
+        }
+
+
 
         private void setTextBoxPrompt(TextBoxEx ex,String text) {
             ex.PromptFont = new System.Drawing.Font("寰蒋闆呴粦", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
@@ -44,28 +92,122 @@
             setTextBoxPrompt(this.textBox10, "鏈�澶у��");
             setTextBoxPrompt(this.textBox11, "鏈�灏忓��");
             setTextBoxPrompt(this.textBox12, "鏈�澶у��");
-
-
         }
 
-        private void SetTableData(List<FirstOrderSunInfo> infoList) {
+        /**
+         * 
+         * 
+         * 鍟嗗搧寮�濮�
+         * 
+         * 
+         * 
+         */
+
+        delegate void SetGoodsAndClassDataDelegate(JObject obj);
+
+        void setGoodsAndClassData(JObject obj) {
+            List<GoodsClass> goodsClassList = new List<GoodsClass>();
+            List<FirstOrderSubInfo> goodsList = new List<FirstOrderSubInfo>();
+            if (obj["code"].ToString() == "0")
+            {
+                //瑙f瀽鍒嗙被
+                var array = JArray.Parse(obj["data"]["goodsClass"].ToString());
+                goodsClassList = array.ToObject<List<GoodsClass>>();
+
+                //瑙f瀽鏁版嵁
+                array = JArray.Parse(obj["data"]["goods"].ToString());
+                goodsList = array.ToObject<List<FirstOrderSubInfo>>();
+            }
+
+            SetClassData(goodsClassList);
+            SetGoodsData(false, goodsList);
+        }
+
+        private void searchSuccess(String result)
+        {
+            JObject obj = JObject.Parse(result);
+            this.BeginInvoke(new SetGoodsAndClassDataDelegate(setGoodsAndClassData), obj);
+        }
+
+        private void search(int page, SearchInfo info)
+        {
+
+            OnSuccess onSuccess = searchSuccess;
+
+            ApiUtil.searchGoods("", info, page, onSuccess);
+        }
+
+        int page = 1;
+        //璁剧疆鍒楄〃鐨勬暟鎹�
+        private void SetGoodsData(bool  hasMore, List<FirstOrderSubInfo> infoList) {
             this.dataGridView1.Rows.Clear();
         
-            foreach (FirstOrderSunInfo info in infoList) {
+            foreach (FirstOrderSubInfo info in infoList) {
                 int index = this.dataGridView1.Rows.Add();
                 this.dataGridView1.Rows[index].Cells[0].Value = "1";
-                this.dataGridView1.Rows[index].Cells[1].Value = info.title;
-                this.dataGridView1.Rows[index].Cells[2].Value = info.zkPrice;
-                this.dataGridView1.Rows[index].Cells[3].Value = info.couponPrice;
-                this.dataGridView1.Rows[index].Cells[4].Value = info.lijinAmount;
-                this.dataGridView1.Rows[index].Cells[5].Value = info.actualPrice;
-                this.dataGridView1.Rows[index].Cells[6].Value = info.commission;
-                this.dataGridView1.Rows[index].Cells[7].Value = info.commissionRate;
+                this.dataGridView1.Rows[index].Cells[1].Value = info.Title;
+                this.dataGridView1.Rows[index].Cells[2].Value = info.ZkPrice;
+                this.dataGridView1.Rows[index].Cells[3].Value = info.CouponPrice;
+                this.dataGridView1.Rows[index].Cells[4].Value = info.LijinAmount;
+                this.dataGridView1.Rows[index].Cells[5].Value = info.ActualPrice;
+                this.dataGridView1.Rows[index].Cells[6].Value = info.Commission;
+                this.dataGridView1.Rows[index].Cells[7].Value = info.CommissionRate;
                 this.dataGridView1.Rows[index].Cells[8].Value = "鍔犲叆寮曞崟搴�";
                 this.dataGridView1.Rows[index].Cells[9].Value = "鍔犲叆瀹炴媿搴�";
             }
-           //  DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
-           //  helper.Headers.Add(new DataGridViewHelper.TopHeader(8, 2, "鎿嶄綔"));
+
+            if (hasMore)
+            {
+                this.label36.ForeColor = ColorUtil.GetThemeColor();
+            }
+            else {
+                this.label36.ForeColor = ColorUtil.GetDefaultColor();
+            }
+
+            if (page <= 1)
+            {
+                this.label35.ForeColor = ColorUtil.GetDefaultColor();
+            }
+            else {
+                this.label35.ForeColor = ColorUtil.GetThemeColor();
+            }
+
+        }
+
+        //璁剧疆鍟嗗搧璇︽儏
+        private void SetGoodsDetail(FirstOrderSubInfo info) {
+            //璁剧疆鏍囬
+            this.richTextBox1.Text = info.Title;
+            TextBoxUtil.SetLineSpace(this.richTextBox1,300);
+            if (info.ImgList != null)
+            {
+
+                if (info.ImgList.Count > 0)
+                {
+                    this.pictureBox1.Visible =true;
+                    ImageUtil.DisplayImage(this.pictureBox1, info.ImgList[0]);
+                }
+                else
+                {
+                    this.pictureBox1.Visible = false;
+                }
+
+
+                if (info.ImgList.Count > 1)
+                {
+                    this.pictureBox2.Visible = true;
+                    ImageUtil.DisplayImage(this.pictureBox2, info.ImgList[1]);
+                }
+                else
+                {
+                    this.pictureBox2.Visible = false;
+                }
+
+            }
+            else {
+                this.pictureBox1.Visible = false;
+                this.pictureBox2.Visible = false;
+            }
         }
 
         private void InitDataGridView() {
@@ -81,42 +223,78 @@
             this.dataGridView1.Columns[9].Width = 75;
         }
 
-        //鍒濆鍖栫毊鑲ら鑹�
-        private void InitSkin()
-        {
-            //this.textBox
 
-        }
 
-        private void InitData() {
-            List<FirstOrderSunInfo> infoList = new List<FirstOrderSunInfo>();
 
-            for (int i = 0; i < 20; i++)
-            {
-                FirstOrderSunInfo info = new FirstOrderSunInfo();
-                info.actualPrice = "12.00";
-                info.commission = "1.02";
-                info.commissionRate = "20%";
-                info.couponPrice = "15.00";
-                info.goodsId = "123456";
-                info.imgList = new List<string>();
-                info.imgList.Add("http://");
-                info.lijinAmount = "20.21";
-                info.title = "娴嬭瘯";
-                info.zkPrice = "21.02";
-                infoList.Add(info);
-            }
-            SetTableData(infoList);
-        }
-
-        private void SetClassData() {
+        private void SetClassData(List<GoodsClass> goodsClassList) {
             List<KeyValuePair<string, string>> lstHL = new List<KeyValuePair<string, string>>();
-            for (int i = 0; i < 30; i++)
+            int p = 0;
+            int i = 0;
+            foreach (GoodsClass goodsClass in goodsClassList)
             {
-                lstHL.Add(new KeyValuePair<string, string>(i.ToString(), "閫夐」" + i));
+             
+                lstHL.Add(new KeyValuePair<string, string>(goodsClass.Id+"", goodsClass.Name));
+                if (goodsClass.Selected)
+                    p = i;
+                i++;
             }
             this.ucHorizontalList1.DataSource = lstHL;
+            this.ucHorizontalList1.SetSelect(lstHL[p].Key);
         }
+
+        private void click_Class(object sender, EventArgs e) {
+            Console.WriteLine("鍒嗙被鐐瑰嚮");
+        }
+
+
+        private SearchInfo getSearchFilter()
+        {
+            SearchInfo info = new SearchInfo();
+            info.MinCouponPrice = this.textBox1.Text;
+            info.MaxCouponPrice = this.textBox2.Text;
+
+            info.MinLiJin = this.textBox3.Text;
+            info.MaxLiJin = this.textBox4.Text;
+
+            info.MinActualPrice = this.textBox5.Text;
+            info.MaxActualPrice = this.textBox6.Text;
+
+            info.MinSalesNum = this.textBox7.Text;
+            info.MinSalesNum = this.textBox8.Text;
+
+            info.MinCommission = this.textBox9.Text;
+            info.MaxCommission = this.textBox10.Text;
+
+            info.MinCommissionRate = this.textBox11.Text;
+            info.MaxCommissionRate = this.textBox12.Text;
+
+            return info;
+        }
+
+        //绛涢��
+        private void button1_Click_1(object sender, EventArgs e)
+        {
+            SearchInfo searchInfo = getSearchFilter();
+            search(page, searchInfo);
+            Console.WriteLine(JsonConvert.SerializeObject(searchInfo));
+        }
+
+
+        //鎼滅储
+        private void button5_Click_2(object sender, EventArgs e)
+        {
+            SearchInfo searchInfo = getSearchFilter();
+            searchInfo.Key = this.ucTextBoxEx1.InputText;
+            search(page, searchInfo);
+        }
+
+        /**
+         * 
+         * 
+         * 鍟嗗搧缁撴潫
+         * 
+         * 
+         */
 
 
 
@@ -230,10 +408,6 @@
 
         }
 
-        private void button5_Click_2(object sender, EventArgs e)
-        {
-
-        }
 
         private void label3_Click(object sender, EventArgs e)
         {
@@ -293,5 +467,7 @@
             else
                 return false;
         }
+
+
     }
 }

--
Gitblit v1.8.0