This commit is contained in:
chfei committed 2026-11-10 15:10:53 +08:00
commit 34ea4f8a27
12 files changed
+1538 -1073

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -33,7 +33,10 @@ namespace TemuKJD.WXForms.ShopForms
private static WXShopListForm _instance = null;
public static WXShopListForm Instance { get { if (_instance == null) { _instance = new WXShopListForm(); } return _instance; } set { _instance = value; } }
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 isCancel = false;
#region 服务端店铺管理
public static void UpdateShop()
@@ -1315,6 +1318,98 @@ namespace TemuKJD.WXForms.ShopForms
numAddTopUp.Value = 1;
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
{
@@ -34,6 +34,8 @@ namespace TemuKJD.WXForms.ShopForms
{
public static WXShopMultiLoginForm shopMultiLoginFormInstance { get; set; } = null;
public bool isAutoLogin = false;
public int CloseAfterSecond { get; set; }
public EnumOpenType openType = EnumOpenType.manage;
public bool isMultiLogin = false;
@@ -100,6 +102,26 @@ namespace TemuKJD.WXForms.ShopForms
{
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,12 +438,18 @@ namespace TemuKJD.WXForms.ShopForms
Thread.Sleep(Randomx.GetId(2500, 5000));
}
if (!this.Created)
return;
Invoke(new Action(() =>
{
btnRefreshNum.Enabled = true;
pbLoading.Visible = false;
BaseMsgForm.ShowInfo("操作完成!");
if (this.isAutoLogin)
this.Close();
else
BaseMsgForm.ShowInfo("操作完成!");
}));
});
}
@@ -448,8 +476,15 @@ namespace TemuKJD.WXForms.ShopForms
string refere = "https://store.weixin.qq.com/shop/home";
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, refere);
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
{