自动批量登录

This commit is contained in:
wule committed 2026-11-09 16:54:40 +08:00
1 parent 82adb510be
commit 6754342366
4 files changed
+303 -29

No files matched your search

+85
View File
@@ -496,6 +496,91 @@ namespace TemuKJD.BLL
return result; return result;
} }
public static async Task<string> WeiXinGetResponseAsync(ShopLoginInfo shop, string _url, string referer = "", bool isGetDocument = false)
{
string biz_magic = "";
string cookies = "";
try
{
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(shop?.Cookies.ParseToString());
if (cookieLst == null)
cookieLst = new List<CefSharp.Cookie>();
foreach (var cook in cookieLst)
{
if (cook.Name.StartsWith("biz"))
cookies += cook.Name + "=" + cook.Value + ";";
}
var bizMagicCookie = cookieLst.FirstOrDefault(c => c.Name == "biz_magic");
if (bizMagicCookie != null)
biz_magic = bizMagicCookie.Value;
}
catch { }
HttpWebResponse response = null;
string result;
try
{
string url = _url;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
if (isGetDocument)
{
request.Headers.Add("sec-ch-ua", @"""Not)A;Brand"";v=""8"", ""Chromium"";v=""138""");
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
request.Headers.Add("Upgrade-Insecure-Requests", @"1");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
request.Headers.Set(HttpRequestHeader.Cookie, cookies);
request.Headers.Add("Sec-Fetch-Site", @"none");
request.Headers.Add("Sec-Fetch-Mode", @"navigate");
request.Headers.Add("Sec-Fetch-User", @"?1");
request.Headers.Add("Sec-Fetch-Dest", @"document");
}
else
{
request.Headers.Add("wecom_magic", @"");
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
request.Headers.Add("supplier_magic", @"");
request.Headers.Add("sec-ch-ua", @"""Not)A;Brand"";v=""8"", ""Chromium"";v=""138""");
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.Headers.Add("potter-scene", @"weixinShop");
request.Headers.Add("biz_magic", biz_magic);
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("talent_magic", @"");
request.Headers.Add("mcn_magic", @"");
request.Headers.Set(HttpRequestHeader.Cookie, cookies);
request.Headers.Add("Sec-Fetch-Site", @"same-origin");
request.Headers.Add("Sec-Fetch-Mode", @"cors");
request.Headers.Add("Sec-Fetch-Dest", @"empty");
request.Referer = referer;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br, zstd");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
}
response = (HttpWebResponse)await request.GetResponseAsync();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = GetProxyHtml.ReadResponse(response);
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = GetProxyHtml.ReadResponse(response);
return result;
}
public static string kdniaoPostResponse(string _url, string _data, string referer, Dictionary<string, object> reqDic, string kdnAuth = null, string kdnAuthKey = "Auth") public static string kdniaoPostResponse(string _url, string _data, string referer, Dictionary<string, object> reqDic, string kdnAuth = null, string kdnAuthKey = "Auth")
{ {
HttpWebResponse response = null; HttpWebResponse response = null;
+88 -29
View File
@@ -38,6 +38,8 @@
this.btnEdit = new DevComponents.DotNetBar.PanelEx(); this.btnEdit = new DevComponents.DotNetBar.PanelEx();
this.btnLoginSelect = new TemuKJD.UserControls.ButtonEx(); this.btnLoginSelect = new TemuKJD.UserControls.ButtonEx();
this.panel4 = new System.Windows.Forms.Panel(); this.panel4 = new System.Windows.Forms.Panel();
this.btnCancel = new DevComponents.DotNetBar.PanelEx();
this.btnAutoBatchLogin = new DevComponents.DotNetBar.PanelEx();
this.btnBatchRenewal = new DevComponents.DotNetBar.PanelEx(); this.btnBatchRenewal = new DevComponents.DotNetBar.PanelEx();
this.btnOpenOrderPage = new DevComponents.DotNetBar.PanelEx(); this.btnOpenOrderPage = new DevComponents.DotNetBar.PanelEx();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
@@ -170,19 +172,19 @@
this.panel5.Controls.Add(this.btnCheck); this.panel5.Controls.Add(this.btnCheck);
this.panel5.Controls.Add(this.btnEdit); this.panel5.Controls.Add(this.btnEdit);
this.panel5.Controls.Add(this.btnLoginSelect); this.panel5.Controls.Add(this.btnLoginSelect);
this.panel5.Location = new System.Drawing.Point(1142, 3); this.panel5.Location = new System.Drawing.Point(1166, 3);
this.panel5.Name = "panel5"; this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(249, 40); this.panel5.Size = new System.Drawing.Size(225, 40);
this.panel5.TabIndex = 1; this.panel5.TabIndex = 1;
// //
// btnCheck // btnCheck
// //
this.btnCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.btnCheck.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.btnCheck.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCheck.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnCheck.Cursor = System.Windows.Forms.Cursors.Hand; this.btnCheck.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnCheck.DisabledBackColor = System.Drawing.Color.Empty; this.btnCheck.DisabledBackColor = System.Drawing.Color.Empty;
this.btnCheck.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnCheck.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCheck.Location = new System.Drawing.Point(98, 10); this.btnCheck.Location = new System.Drawing.Point(82, 10);
this.btnCheck.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnCheck.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnCheck.Name = "btnCheck"; this.btnCheck.Name = "btnCheck";
this.btnCheck.Size = new System.Drawing.Size(60, 23); this.btnCheck.Size = new System.Drawing.Size(60, 23);
@@ -203,12 +205,12 @@
// //
// btnEdit // btnEdit
// //
this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.btnEdit.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.btnEdit.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnEdit.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnEdit.Cursor = System.Windows.Forms.Cursors.Hand; this.btnEdit.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnEdit.DisabledBackColor = System.Drawing.Color.Empty; this.btnEdit.DisabledBackColor = System.Drawing.Color.Empty;
this.btnEdit.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnEdit.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnEdit.Location = new System.Drawing.Point(33, 10); this.btnEdit.Location = new System.Drawing.Point(17, 10);
this.btnEdit.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnEdit.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnEdit.Name = "btnEdit"; this.btnEdit.Name = "btnEdit";
this.btnEdit.Size = new System.Drawing.Size(60, 23); this.btnEdit.Size = new System.Drawing.Size(60, 23);
@@ -229,12 +231,13 @@
// //
// btnLoginSelect // btnLoginSelect
// //
this.btnLoginSelect.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.btnLoginSelect.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.btnLoginSelect.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnLoginSelect.Cursor = System.Windows.Forms.Cursors.Hand; this.btnLoginSelect.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnLoginSelect.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnLoginSelect.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnLoginSelect.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnLoginSelect.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnLoginSelect.ForeColor = System.Drawing.Color.White; this.btnLoginSelect.ForeColor = System.Drawing.Color.White;
this.btnLoginSelect.Location = new System.Drawing.Point(163, 9); this.btnLoginSelect.Location = new System.Drawing.Point(147, 9);
this.btnLoginSelect.Margin = new System.Windows.Forms.Padding(2); this.btnLoginSelect.Margin = new System.Windows.Forms.Padding(2);
this.btnLoginSelect.Name = "btnLoginSelect"; this.btnLoginSelect.Name = "btnLoginSelect";
this.btnLoginSelect.Size = new System.Drawing.Size(66, 25); this.btnLoginSelect.Size = new System.Drawing.Size(66, 25);
@@ -245,6 +248,8 @@
// //
// panel4 // panel4
// //
this.panel4.Controls.Add(this.btnCancel);
this.panel4.Controls.Add(this.btnAutoBatchLogin);
this.panel4.Controls.Add(this.btnBatchRenewal); this.panel4.Controls.Add(this.btnBatchRenewal);
this.panel4.Controls.Add(this.btnOpenOrderPage); this.panel4.Controls.Add(this.btnOpenOrderPage);
this.panel4.Controls.Add(this.tableLayoutPanel1); this.panel4.Controls.Add(this.tableLayoutPanel1);
@@ -252,9 +257,61 @@
this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel4.Location = new System.Drawing.Point(3, 3); this.panel4.Location = new System.Drawing.Point(3, 3);
this.panel4.Name = "panel4"; this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(1133, 40); this.panel4.Size = new System.Drawing.Size(1157, 40);
this.panel4.TabIndex = 0; this.panel4.TabIndex = 0;
// //
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.CanvasColor = System.Drawing.SystemColors.Control;
this.btnCancel.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnCancel.DisabledBackColor = System.Drawing.Color.Empty;
this.btnCancel.Location = new System.Drawing.Point(959, 9);
this.btnCancel.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(31, 23);
this.btnCancel.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnCancel.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.btnCancel.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(185)))), ((int)(((byte)(215)))), ((int)(((byte)(255)))));
this.btnCancel.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
this.btnCancel.Style.BorderColor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnCancel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.btnCancel.Style.GradientAngle = 90;
this.btnCancel.StyleMouseDown.Alignment = System.Drawing.StringAlignment.Center;
this.btnCancel.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnCancel.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnCancel.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnCancel.StyleMouseOver.ForeColor.Color = System.Drawing.Color.White;
this.btnCancel.TabIndex = 823;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnAutoBatchLogin
//
this.btnAutoBatchLogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnAutoBatchLogin.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnAutoBatchLogin.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnAutoBatchLogin.DisabledBackColor = System.Drawing.Color.Empty;
this.btnAutoBatchLogin.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAutoBatchLogin.Location = new System.Drawing.Point(875, 9);
this.btnAutoBatchLogin.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnAutoBatchLogin.Name = "btnAutoBatchLogin";
this.btnAutoBatchLogin.Size = new System.Drawing.Size(84, 23);
this.btnAutoBatchLogin.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnAutoBatchLogin.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnAutoBatchLogin.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnAutoBatchLogin.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnAutoBatchLogin.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnAutoBatchLogin.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnAutoBatchLogin.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnAutoBatchLogin.Style.GradientAngle = 90;
this.btnAutoBatchLogin.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnAutoBatchLogin.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnAutoBatchLogin.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnAutoBatchLogin.TabIndex = 819;
this.btnAutoBatchLogin.Text = "自动批量登录";
this.btnAutoBatchLogin.Click += new System.EventHandler(this.btnAutoBatchLogin_Click);
//
// btnBatchRenewal // btnBatchRenewal
// //
this.btnBatchRenewal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnBatchRenewal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -262,10 +319,10 @@
this.btnBatchRenewal.Cursor = System.Windows.Forms.Cursors.Hand; this.btnBatchRenewal.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnBatchRenewal.DisabledBackColor = System.Drawing.Color.Empty; this.btnBatchRenewal.DisabledBackColor = System.Drawing.Color.Empty;
this.btnBatchRenewal.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnBatchRenewal.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnBatchRenewal.Location = new System.Drawing.Point(935, 9); this.btnBatchRenewal.Location = new System.Drawing.Point(1004, 9);
this.btnBatchRenewal.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnBatchRenewal.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnBatchRenewal.Name = "btnBatchRenewal"; this.btnBatchRenewal.Name = "btnBatchRenewal";
this.btnBatchRenewal.Size = new System.Drawing.Size(79, 23); this.btnBatchRenewal.Size = new System.Drawing.Size(58, 23);
this.btnBatchRenewal.Style.Alignment = System.Drawing.StringAlignment.Center; this.btnBatchRenewal.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnBatchRenewal.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.btnBatchRenewal.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnBatchRenewal.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.btnBatchRenewal.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
@@ -289,10 +346,10 @@
this.btnOpenOrderPage.Cursor = System.Windows.Forms.Cursors.Hand; this.btnOpenOrderPage.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOpenOrderPage.DisabledBackColor = System.Drawing.Color.Empty; this.btnOpenOrderPage.DisabledBackColor = System.Drawing.Color.Empty;
this.btnOpenOrderPage.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnOpenOrderPage.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOpenOrderPage.Location = new System.Drawing.Point(1018, 9); this.btnOpenOrderPage.Location = new System.Drawing.Point(1065, 9);
this.btnOpenOrderPage.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnOpenOrderPage.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnOpenOrderPage.Name = "btnOpenOrderPage"; this.btnOpenOrderPage.Name = "btnOpenOrderPage";
this.btnOpenOrderPage.Size = new System.Drawing.Size(106, 23); this.btnOpenOrderPage.Size = new System.Drawing.Size(83, 23);
this.btnOpenOrderPage.Style.Alignment = System.Drawing.StringAlignment.Center; this.btnOpenOrderPage.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnOpenOrderPage.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.btnOpenOrderPage.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnOpenOrderPage.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); this.btnOpenOrderPage.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
@@ -347,7 +404,7 @@
this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(767, 40); this.tableLayoutPanel1.Size = new System.Drawing.Size(774, 40);
this.tableLayoutPanel1.TabIndex = 375; this.tableLayoutPanel1.TabIndex = 375;
// //
// cmbGroup // cmbGroup
@@ -358,10 +415,10 @@
this.cmbGroup.DropDownWidth = 1; this.cmbGroup.DropDownWidth = 1;
this.cmbGroup.FormattingEnabled = true; this.cmbGroup.FormattingEnabled = true;
this.cmbGroup.IntegralHeight = false; this.cmbGroup.IntegralHeight = false;
this.cmbGroup.Location = new System.Drawing.Point(385, 8); this.cmbGroup.Location = new System.Drawing.Point(388, 8);
this.cmbGroup.Margin = new System.Windows.Forms.Padding(0, 0, 0, 4); this.cmbGroup.Margin = new System.Windows.Forms.Padding(0, 0, 0, 4);
this.cmbGroup.Name = "cmbGroup"; this.cmbGroup.Name = "cmbGroup";
this.cmbGroup.Size = new System.Drawing.Size(74, 25); this.cmbGroup.Size = new System.Drawing.Size(75, 25);
this.cmbGroup.TabIndex = 803; this.cmbGroup.TabIndex = 803;
this.cmbGroup.Text = "全部"; this.cmbGroup.Text = "全部";
// //
@@ -384,10 +441,10 @@
this.cmbNotes.DropDownWidth = 1; this.cmbNotes.DropDownWidth = 1;
this.cmbNotes.FormattingEnabled = true; this.cmbNotes.FormattingEnabled = true;
this.cmbNotes.IntegralHeight = false; this.cmbNotes.IntegralHeight = false;
this.cmbNotes.Location = new System.Drawing.Point(276, 8); this.cmbNotes.Location = new System.Drawing.Point(278, 8);
this.cmbNotes.Margin = new System.Windows.Forms.Padding(0, 0, 0, 4); this.cmbNotes.Margin = new System.Windows.Forms.Padding(0, 0, 0, 4);
this.cmbNotes.Name = "cmbNotes"; this.cmbNotes.Name = "cmbNotes";
this.cmbNotes.Size = new System.Drawing.Size(74, 25); this.cmbNotes.Size = new System.Drawing.Size(75, 25);
this.cmbNotes.TabIndex = 413; this.cmbNotes.TabIndex = 413;
this.cmbNotes.Text = "全部"; this.cmbNotes.Text = "全部";
// //
@@ -397,14 +454,14 @@
this.txtShopId.Location = new System.Drawing.Point(46, 8); this.txtShopId.Location = new System.Drawing.Point(46, 8);
this.txtShopId.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.txtShopId.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.txtShopId.Name = "txtShopId"; this.txtShopId.Name = "txtShopId";
this.txtShopId.Size = new System.Drawing.Size(74, 23); this.txtShopId.Size = new System.Drawing.Size(75, 23);
this.txtShopId.TabIndex = 372; this.txtShopId.TabIndex = 372;
// //
// label3 // label3
// //
this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; this.label3.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(123, 11); this.label3.Location = new System.Drawing.Point(124, 11);
this.label3.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3); this.label3.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 17); this.label3.Size = new System.Drawing.Size(44, 17);
@@ -414,17 +471,17 @@
// txtShopName // txtShopName
// //
this.txtShopName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.txtShopName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.txtShopName.Location = new System.Drawing.Point(167, 8); this.txtShopName.Location = new System.Drawing.Point(168, 8);
this.txtShopName.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.txtShopName.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.txtShopName.Name = "txtShopName"; this.txtShopName.Name = "txtShopName";
this.txtShopName.Size = new System.Drawing.Size(74, 23); this.txtShopName.Size = new System.Drawing.Size(75, 23);
this.txtShopName.TabIndex = 374; this.txtShopName.TabIndex = 374;
// //
// label4 // label4
// //
this.label4.Anchor = System.Windows.Forms.AnchorStyles.None; this.label4.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(244, 11); this.label4.Location = new System.Drawing.Point(246, 11);
this.label4.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3); this.label4.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 17); this.label4.Size = new System.Drawing.Size(32, 17);
@@ -438,7 +495,7 @@
this.btnRefreshShop.Cursor = System.Windows.Forms.Cursors.Hand; this.btnRefreshShop.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnRefreshShop.DisabledBackColor = System.Drawing.Color.Empty; this.btnRefreshShop.DisabledBackColor = System.Drawing.Color.Empty;
this.btnRefreshShop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnRefreshShop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnRefreshShop.Location = new System.Drawing.Point(582, 8); this.btnRefreshShop.Location = new System.Drawing.Point(587, 8);
this.btnRefreshShop.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnRefreshShop.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnRefreshShop.Name = "btnRefreshShop"; this.btnRefreshShop.Name = "btnRefreshShop";
this.btnRefreshShop.Size = new System.Drawing.Size(60, 23); this.btnRefreshShop.Size = new System.Drawing.Size(60, 23);
@@ -463,7 +520,7 @@
this.btnEmpty.CanvasColor = System.Drawing.SystemColors.Control; this.btnEmpty.CanvasColor = System.Drawing.SystemColors.Control;
this.btnEmpty.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnEmpty.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnEmpty.DisabledBackColor = System.Drawing.Color.Empty; this.btnEmpty.DisabledBackColor = System.Drawing.Color.Empty;
this.btnEmpty.Location = new System.Drawing.Point(706, 8); this.btnEmpty.Location = new System.Drawing.Point(711, 8);
this.btnEmpty.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnEmpty.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnEmpty.Name = "btnEmpty"; this.btnEmpty.Name = "btnEmpty";
this.btnEmpty.Size = new System.Drawing.Size(60, 23); this.btnEmpty.Size = new System.Drawing.Size(60, 23);
@@ -490,7 +547,7 @@
this.btnSearch.Cursor = System.Windows.Forms.Cursors.Hand; this.btnSearch.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSearch.DisabledBackColor = System.Drawing.Color.Empty; this.btnSearch.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSearch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnSearch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSearch.Location = new System.Drawing.Point(644, 8); this.btnSearch.Location = new System.Drawing.Point(649, 8);
this.btnSearch.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); this.btnSearch.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.btnSearch.Name = "btnSearch"; this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(60, 23); this.btnSearch.Size = new System.Drawing.Size(60, 23);
@@ -517,10 +574,10 @@
this.cmbSubAccount.DropDownWidth = 1; this.cmbSubAccount.DropDownWidth = 1;
this.cmbSubAccount.FormattingEnabled = true; this.cmbSubAccount.FormattingEnabled = true;
this.cmbSubAccount.IntegralHeight = false; this.cmbSubAccount.IntegralHeight = false;
this.cmbSubAccount.Location = new System.Drawing.Point(506, 8); this.cmbSubAccount.Location = new System.Drawing.Point(510, 8);
this.cmbSubAccount.Margin = new System.Windows.Forms.Padding(0, 0, 0, 4); this.cmbSubAccount.Margin = new System.Windows.Forms.Padding(0, 0, 0, 4);
this.cmbSubAccount.Name = "cmbSubAccount"; this.cmbSubAccount.Name = "cmbSubAccount";
this.cmbSubAccount.Size = new System.Drawing.Size(74, 25); this.cmbSubAccount.Size = new System.Drawing.Size(75, 25);
this.cmbSubAccount.TabIndex = 415; this.cmbSubAccount.TabIndex = 415;
this.cmbSubAccount.Text = "全部"; this.cmbSubAccount.Text = "全部";
// //
@@ -528,7 +585,7 @@
// //
this.label5.Anchor = System.Windows.Forms.AnchorStyles.None; this.label5.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label5.AutoSize = true; this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(462, 11); this.label5.Location = new System.Drawing.Point(466, 11);
this.label5.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3); this.label5.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.label5.Name = "label5"; this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(44, 17); this.label5.Size = new System.Drawing.Size(44, 17);
@@ -539,7 +596,7 @@
// //
this.label6.Anchor = System.Windows.Forms.AnchorStyles.None; this.label6.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label6.AutoSize = true; this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(353, 11); this.label6.Location = new System.Drawing.Point(356, 11);
this.label6.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3); this.label6.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.label6.Name = "label6"; this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(32, 17); this.label6.Size = new System.Drawing.Size(32, 17);
@@ -1213,5 +1270,7 @@
private System.Windows.Forms.DataGridViewLinkColumn colCopyCookies; private System.Windows.Forms.DataGridViewLinkColumn colCopyCookies;
private System.Windows.Forms.DataGridViewLinkColumn colEdit; private System.Windows.Forms.DataGridViewLinkColumn colEdit;
private System.Windows.Forms.DataGridViewLinkColumn colDelete; private System.Windows.Forms.DataGridViewLinkColumn colDelete;
private DevComponents.DotNetBar.PanelEx btnCancel;
private DevComponents.DotNetBar.PanelEx btnAutoBatchLogin;
} }
} }
@@ -33,7 +33,10 @@ namespace TemuKJD.WXForms.ShopForms
private static WXShopListForm _instance = null; private static WXShopListForm _instance = null;
public static WXShopListForm Instance { get { if (_instance == null) { _instance = new WXShopListForm(); } return _instance; } set { _instance = value; } } public static WXShopListForm Instance { get { if (_instance == null) { _instance = new WXShopListForm(); } return _instance; } set { _instance = value; } }
public static bool IsOperate { get; set; } = false; public static bool IsOperate { get; set; } = false;
public List<List<ShopSwitchInfo>> shopSwitchInfoListList { get; set; } = new List<List<ShopSwitchInfo>>();
private bool isLoading { get; set; } = false; private bool isLoading { get; set; } = false;
private bool isCancel = false;
#region 服务端店铺管理 #region 服务端店铺管理
public static void UpdateShop() public static void UpdateShop()
@@ -1315,6 +1318,98 @@ namespace TemuKJD.WXForms.ShopForms
numAddTopUp.Value = 1; numAddTopUp.Value = 1;
pnlTopUp.Visible = true; pnlTopUp.Visible = true;
} }
private async void btnAutoBatchLogin_Click(object sender, EventArgs e)
{
isCancel = false;
shopSwitchInfoListList = new List<List<ShopSwitchInfo>>();
int i = 1;
foreach (var shop in GlobalConfig.ShopLoginList)
{
if (isCancel)
break;
this.statusBar.pgbTaskProgress.Maximum = GlobalConfig.ShopLoginList.Count;
this.statusBar.pgbTaskProgress.Value = i;
this.statusBar.pgbTaskProgress.Text = i + "/" + GlobalConfig.ShopLoginList.Count;
this.statusBar.lblTaskStatus.Text = "第1步(共2步):正在获取批量登录信息 " + i + "/" + GlobalConfig.ShopLoginList.Count;
i++;
if (shop.LoginStatus != "登录成功")
continue;
if (shopSwitchInfoListList.Any(ll => ll.Any(l => l.appid == shop.ShopId)))
continue;
var shopSwitchRst = await WXShopSwitch.getShopSwitchListAsync(shop);
if (!shopSwitchRst.Contains("\"code\":0"))
{
continue;
}
string shopSwitchStr = JsonHelper.SerializeObject(JsonHelper.JObjectParse(shopSwitchRst)["list"]);
shopSwitchInfoListList.Add(JsonHelper.DeserializeJsonToList<ShopSwitchInfo>(shopSwitchStr));
await Task.Delay(100);
}
i = 1;
var waitLoginShopList = GlobalConfig.ShopLoginList.Where(s => s.LoginStatus != "登录成功").ToList();
foreach (var shop in waitLoginShopList)
{
if (isCancel)
break;
this.statusBar.pgbTaskProgress.Maximum = waitLoginShopList.Count;
this.statusBar.pgbTaskProgress.Value = i;
this.statusBar.pgbTaskProgress.Text = i + "/" + waitLoginShopList.Count;
this.statusBar.lblTaskStatus.Text = "第2步(共2步):正在自动批量登录 " + i + "/" + waitLoginShopList.Count;
i++;
// 直接比较相等,但是带入if以后就不相等 ?
if (shop.LoginStatus.Equals("登录成功"))
{
continue;
}
var switchInfoListList = shopSwitchInfoListList.Where(ll => ll.Any(l => l.appid == shop.ShopId)).ToList();
if (switchInfoListList.Count == 0)
continue;
ShopLoginInfo loginShop = null;
foreach (var switchInfoList in switchInfoListList)
{
for (int a = 0; a < 100 && loginShop?.LoginStatus != "登录成功"; a++)
{
loginShop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.LoginStatus == "登录成功" && switchInfoList.Any(l => l.appid == s.ShopId));
if (loginShop == null)
break;
else
{
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { loginShop }, false);
await Task.Delay(100);
}
}
if (loginShop != null)
break;
}
// 店铺不存在或者全部掉线了,继续
if (loginShop?.LoginStatus != "登录成功")
continue;
WXShopMultiLoginForm shopMultiLoginForm = new WXShopMultiLoginForm(loginShop);
shopMultiLoginForm.openType = EnumOpenType.multi_login;
shopMultiLoginForm.isAutoLogin = true;
shopMultiLoginForm.ShowDialog();
RefreshDataGridView(true, shopMultiLoginForm.lstSwitchShop.ToList());
await Task.Delay(500);
}
this.statusBar.lblTaskStatus.Text += isCancel ? " 自动批量登录取消" : " 自动批量登录结束";
}
private void btnCancel_Click(object sender, EventArgs e)
{
isCancel = true;
}
} }
public class ShopRenewResponse public class ShopRenewResponse
{ {
@@ -34,6 +34,8 @@ namespace TemuKJD.WXForms.ShopForms
{ {
public static WXShopMultiLoginForm shopMultiLoginFormInstance { get; set; } = null; public static WXShopMultiLoginForm shopMultiLoginFormInstance { get; set; } = null;
public bool isAutoLogin = false;
public int CloseAfterSecond { get; set; } public int CloseAfterSecond { get; set; }
public EnumOpenType openType = EnumOpenType.manage; public EnumOpenType openType = EnumOpenType.manage;
public bool isMultiLogin = false; public bool isMultiLogin = false;
@@ -100,6 +102,26 @@ namespace TemuKJD.WXForms.ShopForms
{ {
BaseMsgForm.ShowError("切换列表解析失败!"); BaseMsgForm.ShowError("切换列表解析失败!");
} }
if (isAutoLogin)
{
Thread.Sleep(Randomx.GetId(2500, 3500));
while(this.cefWebBrowser == null || this.cefWebBrowser.IsLoading)
{
if (!this.Created)
return;
Thread.Sleep(100);
continue;
}
if (!this.Created)
return;
Invoke(() =>
{
btnRefreshNum_Click(null, null);
});
}
}); });
} }
@@ -416,11 +438,17 @@ namespace TemuKJD.WXForms.ShopForms
Thread.Sleep(Randomx.GetId(2500, 5000)); Thread.Sleep(Randomx.GetId(2500, 5000));
} }
if (!this.Created)
return;
Invoke(new Action(() => Invoke(new Action(() =>
{ {
btnRefreshNum.Enabled = true; btnRefreshNum.Enabled = true;
pbLoading.Visible = false; pbLoading.Visible = false;
if (this.isAutoLogin)
this.Close();
else
BaseMsgForm.ShowInfo("操作完成!"); BaseMsgForm.ShowInfo("操作完成!");
})); }));
}); });
@@ -449,6 +477,13 @@ namespace TemuKJD.WXForms.ShopForms
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, refere); var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, refere);
return result; return result;
} }
public static async Task<string> getShopSwitchListAsync(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodelogin/session/getShopSwitchList?token=&lang=zh_CN";
string refere = "https://store.weixin.qq.com/shop/home";
var result = await WXHttpResponseBLL.WeiXinGetResponseAsync(shop, url, refere);
return result;
}
} }
public class ShopSwitchInfo public class ShopSwitchInfo