列表shift多选,修复客服无法筛选店铺bug
This commit is contained in:
1 parent
b27c473c99
commit
679bae7c42
11 files changed
+272
-110
No files matched your search
@@ -820,6 +820,7 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
shopMultiLoginForm.openType = EnumOpenType.multi_login;
|
||||
//shopMultiLoginForm.WindowState = FormWindowState.Maximized;
|
||||
shopMultiLoginForm.ShowDialog();
|
||||
RefreshDataGridView(true, shopMultiLoginForm.lstSwitchShop.ToList());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
+20
-3
@@ -32,6 +32,7 @@
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WXShopMultiLoginForm));
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.pbLoading = new System.Windows.Forms.PictureBox();
|
||||
this.dgvShop = new TemuKJD.UserComponent.DataGridViewEx();
|
||||
this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.colShopLoginName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
@@ -50,6 +51,7 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvShop)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
|
||||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
@@ -73,12 +75,25 @@
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White;
|
||||
this.splitContainer1.Panel2.Controls.Add(this.pbLoading);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.dgvShop);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1438, 659);
|
||||
this.splitContainer1.SplitterDistance = 1106;
|
||||
this.splitContainer1.SplitterDistance = 1108;
|
||||
this.splitContainer1.SplitterWidth = 3;
|
||||
this.splitContainer1.TabIndex = 4;
|
||||
//
|
||||
// pbLoading
|
||||
//
|
||||
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue;
|
||||
this.pbLoading.Location = new System.Drawing.Point(139, 304);
|
||||
this.pbLoading.Name = "pbLoading";
|
||||
this.pbLoading.Size = new System.Drawing.Size(50, 50);
|
||||
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pbLoading.TabIndex = 676;
|
||||
this.pbLoading.TabStop = false;
|
||||
this.pbLoading.Visible = false;
|
||||
//
|
||||
// dgvShop
|
||||
//
|
||||
this.dgvShop.AllowUserToAddRows = false;
|
||||
@@ -112,7 +127,7 @@
|
||||
this.dgvShop.ReadOnly = true;
|
||||
this.dgvShop.RowHeadersWidth = 25;
|
||||
this.dgvShop.RowTemplate.Height = 23;
|
||||
this.dgvShop.Size = new System.Drawing.Size(329, 659);
|
||||
this.dgvShop.Size = new System.Drawing.Size(327, 659);
|
||||
this.dgvShop.TabIndex = 7;
|
||||
//
|
||||
// colSelect
|
||||
@@ -277,7 +292,7 @@
|
||||
this.btnRefreshNum.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
|
||||
this.btnRefreshNum.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
|
||||
this.btnRefreshNum.TabIndex = 442;
|
||||
this.btnRefreshNum.Text = "自动切换登录";
|
||||
this.btnRefreshNum.Text = "自动批量登录";
|
||||
this.btnRefreshNum.Click += new System.EventHandler(this.btnRefreshNum_Click);
|
||||
//
|
||||
// WXShopMultiLoginForm
|
||||
@@ -297,6 +312,7 @@
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvShop)).EndInit();
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.PerformLayout();
|
||||
@@ -329,5 +345,6 @@
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn colCanUse;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colMessage;
|
||||
private DevComponents.DotNetBar.PanelEx btnRefreshNum;
|
||||
private System.Windows.Forms.PictureBox pbLoading;
|
||||
}
|
||||
}
|
||||
@@ -40,16 +40,16 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
public string MultiLoginCookieName = "";
|
||||
public string InitUrl = "";
|
||||
public ChromiumWebBrowser cefWebBrowser = null;
|
||||
public ShopLoginInfo mainShop = null;
|
||||
public ConcurrentList<ShopLoginInfo> lstSwitchShop = new ConcurrentList<ShopLoginInfo>();
|
||||
public ConcurrentList<ShopSwitchInfo> lstSwitchInfo = new ConcurrentList<ShopSwitchInfo>();
|
||||
|
||||
const string DefaultUrl = "https://store.weixin.qq.com/shop/home";
|
||||
const string shopLoginUrl = "https://store.weixin.qq.com/shop?redirect_url=%2Fhome";
|
||||
private string currentUrl = "";
|
||||
|
||||
private string shopCookieHead = "store.weixin.qq.com";
|
||||
private ShopLoginInfo mainShop = null;
|
||||
private ConcurrentList<ShopCompany> lstShopCompany = new ConcurrentList<ShopCompany>();
|
||||
private ConcurrentList<ShopLoginInfo> lstSwitchShop = new ConcurrentList<ShopLoginInfo>();
|
||||
private ConcurrentList<ShopSwitchInfo> lstSwitchInfo = new ConcurrentList<ShopSwitchInfo>();
|
||||
|
||||
|
||||
public WXShopMultiLoginForm(ShopLoginInfo shopInfo)
|
||||
@@ -328,52 +328,91 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
|
||||
private void btnRefreshNum_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (var shop in lstSwitchShop)
|
||||
pbLoading.Visible = true;
|
||||
btnRefreshNum.Enabled = false;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var switchInfo = lstSwitchInfo.FirstOrDefault(s => s.appid == shop.ShopId);
|
||||
var row = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
|
||||
Invoke(new Action(() =>
|
||||
foreach (var shop in lstSwitchShop)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "-";
|
||||
}));
|
||||
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
if (shop.LoginStatus == "登录成功")
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
var switchInfo = lstSwitchInfo.FirstOrDefault(s => s.appid == shop.ShopId);
|
||||
var row = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colMessage"].Value = "登录成功";
|
||||
row.Cells["colMessage"].Value = "-";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
string jsStr1 = @"document.getElementsByClassName('shop-info-popover')[0].style ='';
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
if (shop.LoginStatus == "登录成功")
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colMessage"].Value = "登录成功";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
string jsStr1 = @"document.getElementsByClassName('shop-info-popover')[0].style ='';
|
||||
var divLst = document.getElementsByClassName('shop-info-popover')[0].getElementsByTagName('div');
|
||||
for (i=0; i<divLst.length; i++){
|
||||
if(divLst[i].innerHTML.indexOf('切换店铺') >= 0){
|
||||
divLst[i].click();
|
||||
//return 'success'
|
||||
}
|
||||
}";
|
||||
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
|
||||
t1.Wait(5000);
|
||||
}";
|
||||
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
|
||||
t1.Wait(5000);
|
||||
|
||||
Thread.Sleep(Randomx.GetId(500, 1000));
|
||||
jsStr1 = @"for (i=0; i<divLst.length; i++){
|
||||
Thread.Sleep(Randomx.GetId(500, 1000));
|
||||
jsStr1 = @"for (i=0; i<divLst.length; i++){
|
||||
if(divLst[i].innerHTML.indexOf('" + switchInfo.nickname + @"') >= 0){
|
||||
divLst[i].click();
|
||||
}
|
||||
}";
|
||||
t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
|
||||
t1.Wait(5000);
|
||||
t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr1);
|
||||
t1.Wait(5000);
|
||||
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
Thread.Sleep(Randomx.GetId(3000, 3500));
|
||||
|
||||
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
|
||||
break;
|
||||
}
|
||||
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
|
||||
var cookies = cookieList.Where(c => c.Domain == this.shopCookieHead).ToList();
|
||||
if (!cookies.Any(c => c.Name == "biz_ticket"))
|
||||
{
|
||||
cookies.Add(new CefSharp.Cookie()
|
||||
{
|
||||
Name = "biz_ticket",
|
||||
Value = "",
|
||||
Domain = "store.weixin.qq.com",
|
||||
Expires = null,
|
||||
HttpOnly = true,
|
||||
Path = "/",
|
||||
Priority = CefSharp.Enums.CookiePriority.Medium,
|
||||
SameSite = CefSharp.Enums.CookieSameSite.Unspecified,
|
||||
Secure = true,
|
||||
});
|
||||
}
|
||||
|
||||
WXShopUpdateCookieForm.CheckCookieUpdate(shop, cookies);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
bool canUse = shop.LoginStatus == "登录成功";
|
||||
row.Cells["colMessage"].Value = canUse ? "登录成功" : "登录失败,请稍后重试";
|
||||
row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线";
|
||||
row.Cells["colCanUse"].Value = canUse;
|
||||
displayAuthStatus(shop);
|
||||
}));
|
||||
Thread.Sleep(Randomx.GetId(2500, 5000));
|
||||
}
|
||||
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
btnRefreshNum.Enabled = true;
|
||||
pbLoading.Visible = false;
|
||||
BaseMsgForm.ShowInfo("操作完成!");
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
void displayAuthStatus(ShopLoginInfo shop)
|
||||
|
||||
@@ -110,15 +110,15 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
string RK = BaseRegex.GetStringCookie(ref txt, "RK").ParseToString().Trim('\'');
|
||||
string yyb_muid = BaseRegex.GetStringCookie(ref txt, "yyb_muid").ParseToString().Trim('\'');
|
||||
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "_qimei_uuid42", Value = _qimei_uuid42, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "_qpsvr_localtk", Value = _qpsvr_localtk, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
//cookieLst.Add(new CefSharp.Cookie() { Name = "_qimei_uuid42", Value = _qimei_uuid42, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
//cookieLst.Add(new CefSharp.Cookie() { Name = "_qpsvr_localtk", Value = _qpsvr_localtk, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_magic", Value = biz_magic, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_rand", Value = biz_rand, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_ticket", Value = biz_ticket, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "biz_token", Value = biz_token, Domain = "store.weixin.qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "ptcz", Value = ptcz, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "RK", Value = RK, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
cookieLst.Add(new CefSharp.Cookie() { Name = "yyb_muid", Value = yyb_muid, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
//cookieLst.Add(new CefSharp.Cookie() { Name = "ptcz", Value = ptcz, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
//cookieLst.Add(new CefSharp.Cookie() { Name = "RK", Value = RK, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
//cookieLst.Add(new CefSharp.Cookie() { Name = "yyb_muid", Value = yyb_muid, Domain = ".qq.com", Expires = DateTime.Now.AddMonths(1) });
|
||||
|
||||
if (string.IsNullOrEmpty(biz_magic))
|
||||
{
|
||||
@@ -126,6 +126,17 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
return false;
|
||||
}
|
||||
|
||||
string chkRst = CheckCookieUpdate(shopLoginInfo, cookieLst);
|
||||
if (!string.IsNullOrEmpty(chkRst))
|
||||
{
|
||||
BaseMsgForm.ShowError(chkRst);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string CheckCookieUpdate(ShopLoginInfo shopLoginInfo, List<CefSharp.Cookie> cookieLst)
|
||||
{
|
||||
// 建立一个临时店铺并用这个店铺去登录
|
||||
var cookieShop = new ShopLoginInfo();
|
||||
cookieShop.Cookies = JsonHelper.SerializeObject(cookieLst);
|
||||
@@ -137,8 +148,7 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
var indexEnd = data.IndexOf(";window.__USE_VITE__=");
|
||||
if (index < 1000)
|
||||
{
|
||||
BaseMsgForm.ShowError("cookie已失效!");
|
||||
return false;
|
||||
return "cookie已失效!";
|
||||
}
|
||||
var dataStr = data.Substring(index, indexEnd - index);
|
||||
dataStr = GetHtml.Unicode2String(dataStr);
|
||||
@@ -147,15 +157,14 @@ namespace TemuKJD.WXForms.ShopForms
|
||||
var nickName = BaseRegex.GetStringJson(ref data, "nickName");
|
||||
if (shopLoginInfo.ShopId != shopId)
|
||||
{
|
||||
BaseMsgForm.ShowError("cookie与店铺不匹配,请核对店铺!");
|
||||
return false;
|
||||
return "cookie与店铺不匹配,请核对店铺!";
|
||||
}
|
||||
|
||||
shopLoginInfo.Cookies = JsonHelper.SerializeObject(cookieLst);
|
||||
shopLoginInfo.ShopAccount = nickName;
|
||||
shopLoginInfo.LoginStatus = "登录成功";
|
||||
WXShopListForm.UpdateServerShopCookies(shopLoginInfo); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
|
||||
return true;
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1385,7 +1385,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
List<string> notesLst = notes.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
foreach(DataGridViewRow row in dgvShop.Rows)
|
||||
{
|
||||
if (string.IsNullOrEmpty(notes) || notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString()) && row.Cells["colShopName"].Value.ParseToString().Contains(shopName))
|
||||
if ((string.IsNullOrEmpty(notes) || notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString())) && row.Cells["colShopName"].Value.ParseToString().Contains(shopName))
|
||||
{
|
||||
row.Visible = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user