admin
2020-06-13 5dde755029a86cf8e7052f4878e7c64b94715c38
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
using 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;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.entity;
using WindowsFormsApp1.utils;
using WindowsFormsApp1.utils.ui;
 
namespace WindowsFormsApp1
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
            InitSkin();
            InitDataGridView();
            InitData();
            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);
            ex.PromptText = text;
        }
 
        private void initTextBox() {
            setTextBoxPrompt(this.textBox1,"最小值");
            setTextBoxPrompt(this.textBox2, "最大值");
            setTextBoxPrompt(this.textBox3, "最小值");
            setTextBoxPrompt(this.textBox4, "最大值");
            setTextBoxPrompt(this.textBox5, "最小值");
            setTextBoxPrompt(this.textBox6, "最大值");
            setTextBoxPrompt(this.textBox7, "最小值");
            setTextBoxPrompt(this.textBox8, "最大值");
            setTextBoxPrompt(this.textBox9, "最小值");
            setTextBoxPrompt(this.textBox10, "最大值");
            setTextBoxPrompt(this.textBox11, "最小值");
            setTextBoxPrompt(this.textBox12, "最大值");
        }
 
        /**
         * 
         * 
         * 商品开始
         * 
         * 
         * 
         */
 
        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")
            {
                //解析分类
                var array = JArray.Parse(obj["data"]["goodsClass"].ToString());
                goodsClassList = array.ToObject<List<GoodsClass>>();
 
                //解析数据
                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 (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[8].Value = "加入引单库";
                this.dataGridView1.Rows[index].Cells[9].Value = "加入实拍库";
            }
 
            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() {
            this.dataGridView1.Columns[0].Width=40;
            this.dataGridView1.Columns[1].Width = 280;
            this.dataGridView1.Columns[2].Width = 70;
            this.dataGridView1.Columns[3].Width = 70;
            this.dataGridView1.Columns[4].Width = 75;
            this.dataGridView1.Columns[5].Width = 70;
            this.dataGridView1.Columns[6].Width = 55;
            this.dataGridView1.Columns[7].Width = 65;
            this.dataGridView1.Columns[8].Width = 75;
            this.dataGridView1.Columns[9].Width = 75;
        }
 
 
 
 
        private void SetClassData(List<GoodsClass> goodsClassList) {
            List<KeyValuePair<string, string>> lstHL = new List<KeyValuePair<string, string>>();
            int p = 0;
            int i = 0;
            foreach (GoodsClass goodsClass in goodsClassList)
            {
             
                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);
        }
 
        /**
         * 
         * 
         * 商品结束
         * 
         * 
         */
 
 
 
        private void button1_Click(object sender, EventArgs e)
        {
 
        }
 
        /*
        *淘宝登录
        */
        private void tbLogin_Click(object sender, EventArgs e)
        {
            TBLogin tbLogin = new TBLogin();
            tbLogin.Tag = "http://www.taobao.com";
            tbLogin.ShowDialog();            
        }
 
        //用户登录
        private void login_Click(object sender, EventArgs e) { 
 
        }
 
        private void button5_Click(object sender, EventArgs e)
        {
 
        }
 
        private void groupBox3_Enter(object sender, EventArgs e)
        {
 
        }
 
        private void label9_Click(object sender, EventArgs e)
        {
 
        }
 
        private void label13_Click(object sender, EventArgs e)
        {
 
        }
 
        private void label7_Click(object sender, EventArgs e)
        {
 
        }
 
        private void label12_Click(object sender, EventArgs e)
        {
 
        }
 
        private void label14_Click(object sender, EventArgs e)
        {
 
        }
 
        private void textBox5_TextChanged(object sender, EventArgs e)
        {
 
        }
 
        private void textBox6_TextChanged(object sender, EventArgs e)
        {
 
        }
 
        private void label24_Click(object sender, EventArgs e)
        {
 
        }
 
        private void radioButton9_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void radioButton7_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void radioButton8_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void checkBox7_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void checkBox6_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void button6_Click(object sender, EventArgs e)
        {
 
        }
 
        private void button5_Click_1(object sender, EventArgs e)
        {
 
        }
 
 
        private void label3_Click(object sender, EventArgs e)
        {
 
        }
 
        private void button8_Click(object sender, EventArgs e)
        {
 
        }
 
        private void groupBox9_Enter(object sender, EventArgs e)
        {
 
        }
 
        private void Main_Load(object sender, EventArgs e)
        {
 
 
        }
 
        private void bindingNavigatorMovePreviousItem_Click(object sender, EventArgs e)
        {
 
        }
 
        private void label11_Click(object sender, EventArgs e)
        {
 
        }
 
        private void textBox15_TextChanged(object sender, EventArgs e)
        {
 
        }
 
        private void tabPage1_Click(object sender, EventArgs e)
        {
 
 
 
        }
 
        private void button9_Click(object sender, EventArgs e)
        {
 
        }
 
        /**////是否符合指定的正则表达式
        static public bool Validate(string str, string regexStr)
        {
            Regex regex = new Regex(regexStr);
            Match match = regex.Match(str);
            if (match.Success)
                return true;
            else
                return false;
        }
 
 
    }
}