修复上货页面绑定多次bug

This commit is contained in:
chfei committed 2026-09-21 11:08:45 +08:00
1 parent 2bb20fc107
commit 93d2956d95
1 file changed
+41 -40
@@ -644,48 +644,32 @@ namespace TemuKJD.WXForms.ProductForms
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_checked_shop_dic", dicCheckedShopId); NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_checked_shop_dic", dicCheckedShopId);
} }
private void btnRefreshShop_Click(object sender, EventArgs e) private async void btnRefreshShop_Click(object sender, EventArgs e)
{ {
pbLoadingShop.Visible = true; pbLoadingShop.Visible = true;
RefreshDbProdGroupAndCate(); RefreshDbProdGroupAndCate();
RefreshShopLogin(); RefreshShopLogin();
} }
private void UserSelectDbProductForm_VisibleChanged(object sender, EventArgs e) private async void UserSelectDbProductForm_VisibleChanged(object sender, EventArgs e)
{ {
if (Visible == true) if (Visible == true)
{ {
RefreshShopLogin(); RefreshShopLogin();
updateAuthor(); updateAuthor();
RefreshDbProdGroupAndCate(InitWaitingProductConfigBinding); RefreshDbProdGroupAndCate();
lblWaitToUp.Text = "待上传 " + lstTemuDBProductSelect.Count + " 件"; lblWaitToUp.Text = "待上传 " + lstTemuDBProductSelect.Count + " 件";
if (!isInit) if (!isInit)
{ {
Task.Run(() => InitWaitingProductConfigBinding();
{
foreach (var shop in GlobalConfig.ValidShopLoginList)
{
//if (shop.LoginStatus == "登录成功")
//{
// var rst = WXPreSale.scanProductPreview(shop);
// if (!rst.Contains("\"code\":0") && !rst.Contains("\"success\":true"))
// {
// WXShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
// }
//}
} }
});
}
isInit = true; isInit = true;
} }
} }
private void RefreshDbProdGroupAndCate(Action call = null) private async void RefreshDbProdGroupAndCate()
{
Task.Run(() =>
{ {
// 同时刷新下商品分组 // 同时刷新下商品分组
//string addUserName = BaseClass.UserAuthority.Contains("商品采集") ? ("admin," + BaseClass.UserName) : "admin"; //string addUserName = BaseClass.UserAuthority.Contains("商品采集") ? ("admin," + BaseClass.UserName) : "admin";
@@ -704,7 +688,7 @@ namespace TemuKJD.WXForms.ProductForms
cmbGroupFilter.Items.Insert(0, "我的商品"); cmbGroupFilter.Items.Insert(0, "我的商品");
})); }));
} }
GetPddProductCate(); await GetPddProductCate();
Invoke(new Action(() => Invoke(new Action(() =>
{ {
this.btnSwitchCatType.Text = "P"; this.btnSwitchCatType.Text = "P";
@@ -712,15 +696,15 @@ namespace TemuKJD.WXForms.ProductForms
pbLoadingShop.Visible = false; pbLoadingShop.Visible = false;
})); }));
call?.Invoke(); waiting_product_config.Assign(NaiBa.Util.Helper.ConfigHelper.LoadConfig<WaitingProductConfig>(nameof(waiting_product_config)));
}); //call?.Invoke();
} }
/// <summary> /// <summary>
/// 获取商品所有类目 /// 获取商品所有类目
/// </summary> /// </summary>
void GetPddProductCate() async Task GetPddProductCate()
{ {
var pddMainCats = GlobalConfig.PddCatList.Where(c => c.level == 1); var pddMainCats = GlobalConfig.PddCatList.Where(c => c.level == 1);
var mainCatsText = string.Join(",", pddMainCats.Select(c => c.cat_name)) + "," + string.Join(",", pddMainCats.Select(c => c.cat_id)); var mainCatsText = string.Join(",", pddMainCats.Select(c => c.cat_name)) + "," + string.Join(",", pddMainCats.Select(c => c.cat_id));
@@ -729,9 +713,9 @@ namespace TemuKJD.WXForms.ProductForms
var url = BaseClass.BuildObjString("product/get_pdd_product_cates"); var url = BaseClass.BuildObjString("product/get_pdd_product_cates");
var data = UserLogin.GetSignaturex(); var data = UserLogin.GetSignaturex();
var html = GetHtml.PostUtf8(url, data); var html = await GetHtml.PostUtf8Async(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data); html = await GetHtml.PostUtf8Async(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{ {
BaseMsgForm.ShowError("商品类目获取失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); BaseMsgForm.ShowError("商品类目获取失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg"));
@@ -740,18 +724,6 @@ namespace TemuKJD.WXForms.ProductForms
{ {
pdd_product_cates = BaseRegex.GetStringJson(ref html, "data"); pdd_product_cates = BaseRegex.GetStringJson(ref html, "data");
} }
//Invoke(new Action(() =>
//{
// if (cmbSourceType.Text.Trim() != "厂商直采" && cmbSourceType.Text.Trim() != "微信店采" && cmbSourceType.Text.Trim() != "微信小店")
// {
// fillPddCate();
// }
// else
// {
// fillWxCate();
// }
//}));
} }
void fillPddCate() void fillPddCate()
@@ -8287,5 +8259,34 @@ Content-Type: application/octet-stream
get => GetValue<decimal>(); get => GetValue<decimal>();
set => SetValue(value); set => SetValue(value);
} }
public void Assign(WaitingProductConfig config)
{
if (config == null || ReferenceEquals(config, this)) return;
IdFilter = config.IdFilter;
SearchGoodsName = config.SearchGoodsName;
SourceType = config.SourceType;
GroupFilter = config.GroupFilter;
Hot = config.Hot;
WxSafe = config.WxSafe;
CateFilter1 = config.CateFilter1;
CateFilter2 = config.CateFilter2;
CateFilter3 = config.CateFilter3;
Notes = config.Notes;
JstInitSet = config.JstInitSet;
AddCount = config.AddCount;
SkipQualification = config.SkipQualification;
RandomFissionProduct = config.RandomFissionProduct;
RandomFissionProductCount = config.RandomFissionProductCount;
WXComplateProd = config.WXComplateProd;
UpdateInDaysChecked = config.UpdateInDaysChecked;
UpdateInDays = config.UpdateInDays;
UpdateInDaysType = config.UpdateInDaysType;
FilterViewUvChecked = config.FilterViewUvChecked;
FilterViewUv = config.FilterViewUv;
FilterSaleCountNumChecked = config.FilterSaleCountNumChecked;
FilterSaleCountNum = config.FilterSaleCountNum;
}
} }
} }