admin
2020-06-17 9d3d08ba960fc739498b0648d57eaf2c50a40fd1
WindowsFormsApp1/Main.cs
@@ -10,10 +10,12 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.entity;
using WindowsFormsApp1.utils;
using WindowsFormsApp1.utils.tb;
using WindowsFormsApp1.utils.ui;
namespace WindowsFormsApp1
@@ -27,17 +29,6 @@
            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);
        }
@@ -45,31 +36,14 @@
        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);
            this.sdljGoodsTimer.Interval = 1000*60*5;
            this.sdljGoodsTimer.Start();
            this.tabControl1.SendToBack();
            this.label11.BringToFront();
        }
@@ -120,7 +94,10 @@
            }
            SetClassData(goodsClassList);
            SetGoodsData(false, goodsList);
            var hasMore=  obj["data"]["hasMore"];
            SetGoodsData((bool) hasMore, goodsList);
        }
        private void searchSuccess(String result)
@@ -134,17 +111,18 @@
            OnSuccess onSuccess = searchSuccess;
            ApiUtil.searchGoods("", info, page, onSuccess);
            ApiUtil.searchGoods( classType, info, page, onSuccess);
        }
        int page = 1;
        private  List<FirstOrderSubInfo> infoList;
        //设置列表的数据
        private void SetGoodsData(bool  hasMore, List<FirstOrderSubInfo> infoList) {
            this.infoList = 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[0].Value = info.Index;
                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;
@@ -174,41 +152,6 @@
        }
        //设置商品详情
        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;
@@ -242,8 +185,20 @@
            this.ucHorizontalList1.SetSelect(lstHL[p].Key);
        }
        int classType = 0;
        private void click_Class(object sender, EventArgs e) {
            Console.WriteLine("分类点击");
            KS_Controls.Controls.KSHorizontalListItem item = (KS_Controls.Controls.KSHorizontalListItem) sender;
            int key=  Convert.ToInt32(item.DataSource.Key);
            if (classType == key) {
                return;
            }
            Console.WriteLine("分类:" + item.DataSource.Key);
            page = 1;
            SearchInfo searchInfo = getSearchFilter();
            classType = Convert.ToInt32(item.DataSource.Key);
            searchInfo.Key = this.ucTextBoxEx1.InputText;
            search(page, searchInfo);
        }
@@ -274,7 +229,9 @@
        //筛选
        private void button1_Click_1(object sender, EventArgs e)
        {
            page = 1;
            SearchInfo searchInfo = getSearchFilter();
            classType = 0;
            search(page, searchInfo);
            Console.WriteLine(JsonConvert.SerializeObject(searchInfo));
        }
@@ -283,10 +240,45 @@
        //搜索
        private void button5_Click_2(object sender, EventArgs e)
        {
            classType = 0;
            page = 1;
            SearchInfo searchInfo = getSearchFilter();
            searchInfo.Key = this.ucTextBoxEx1.InputText;
            search(page, searchInfo);
        }
        //下一页
        private void next_Click(object sender, EventArgs e)
        {
            page++;
            SearchInfo searchInfo = getSearchFilter();
            searchInfo.Key = this.ucTextBoxEx1.InputText;
            search(page, searchInfo);
        }
        //上一页
        private void before_Click(object sender, EventArgs e)
        {
            page--;
            SearchInfo searchInfo = getSearchFilter();
            searchInfo.Key = this.ucTextBoxEx1.InputText;
            search(page, searchInfo);
        }
        //选中某一行
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int index= e.RowIndex;
            if (index > -1&& this.infoList!=null)
            {
                if (this.infoList.Count > index)
                {
                }
            }
        }
        /**
         * 
@@ -294,6 +286,34 @@
         * 商品结束
         * 
         * 
         */
        private void getSDLJGoods(object sender, EventArgs e) {
            Console.WriteLine("getSDLJGoods");
            if (Login.loginContainer != null)
                foreach (int key in Login.loginContainer.Keys)
                {
                    String baseUrl = null;
                    if (Constant.sdljBaseUrl.ContainsKey(key))
                    {
                        baseUrl = Constant.sdljBaseUrl[key];
                    }
                    if (baseUrl == null || baseUrl.Trim().Length == 0)
                        continue;
                    Thread thread = new Thread(()=> {
                        Console.WriteLine("执行线程");
                        new SDLJGoodsManager().StartRequestGoods(baseUrl, key);
                    });
                    thread.Start();
                }
        }
        /*
         *
         *刷新Cookie结束
         *
         */
@@ -313,9 +333,54 @@
            tbLogin.ShowDialog();            
        }
        //用户登录
        private void login_Click(object sender, EventArgs e) {
        //设置用户信息
        private void setUserInfo(UserInfo user) {
            this.label37.Visible = true;
            if (user.SdljShareExpireTime == null || DateTime.Now > user.SdljShareExpireTime)
            { //过期
                this.button8.Text = "升级共享";
                this.button8.Click -= new System.EventHandler(this.login_Click);
                this.button8.Click += new System.EventHandler(this.upgrade_Click);//升级
            }
            else {
            }
            this.button8.Text = "升级共享";
            this.label37.Visible = true;
            this.button8.Click -= new System.EventHandler(this.login_Click);
        }
        //用户登录
        private void login_Click(object sender, EventArgs e) {
            LoginNew loginNew = new LoginNew((UserInfo user)=> { //登录成功
                //UI线程
                this.BeginInvoke(new LoginSuccessDelegate((UserInfo user1)=> { //登录
                    setUserInfo(user);
                }));
            });
            FormUtil.ShowDialog(loginNew);
        }
        private void upgrade_Click(object sender, EventArgs e)
        {
            LoginNew loginNew = new LoginNew((UserInfo user) => { //登录成功
                //UI线程
                this.BeginInvoke(new LoginSuccessDelegate((UserInfo user1) => { //登录
                    setUserInfo(user);
                }));
            });
            FormUtil.ShowDialog(loginNew);
        }
        private void button5_Click(object sender, EventArgs e)
@@ -414,10 +479,41 @@
        }
        private void button8_Click(object sender, EventArgs e)
        {
        //推广软件
        private void promotion_Click(object sender, EventArgs e)
        {
            Promotion pt = new Promotion();
            FormUtil.ShowDialog(pt);
        }
        //微信群
        private void wxGroup_Click(object sender, EventArgs e)
        {
            WXGroup pt = new WXGroup();
            FormUtil.ShowDialog(pt);
        }
        //
        //发单机器人
        private void fadanRobot_Click(object sender, EventArgs e) {
            FaDanRobot pt = new FaDanRobot();
            FormUtil.ShowDialog(pt);
        }
        //淘宝授权
        private void tbAuth_Click(object sender, EventArgs e)
        {
            TBAuth login = new TBAuth();
            FormUtil.ShowDialog(login);
        }
        //发单库
        private void fadanKu_Click(object sender, EventArgs e) {
            FaDanKu login = new FaDanKu();
            FormUtil.ShowDialog(login);
        }
        private void groupBox9_Enter(object sender, EventArgs e)
        {
@@ -435,15 +531,6 @@
        }
        private void label11_Click(object sender, EventArgs e)
        {
        }
        private void textBox15_TextChanged(object sender, EventArgs e)
        {
        }
        private void tabPage1_Click(object sender, EventArgs e)
        {
@@ -454,7 +541,9 @@
        private void button9_Click(object sender, EventArgs e)
        {
            //文案编辑
            DocEdit doc=new DocEdit();
            FormUtil.ShowDialog(doc);
        }
        /**////是否符合指定的正则表达式
@@ -468,6 +557,27 @@
                return false;
        }
        //授权登录
        private void button10_Click(object sender, EventArgs e)
        {
            Login login = new Login();
            FormUtil.ShowDialog(login);
        }
        //刷新Cookie
        //TODO
        private void ReFreshCookie() {
            if (Login.loginContainer != null)
                foreach (int key in Login.loginContainer.Keys) {
                    //刷新Cookie
                    Login.loginContainer[key].RefeshCookie();
                }
        }
        private void groupBox4_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(this.BackColor);
        }
    }
}