选品数据库列表一次查询200条 优化选品数据库商品图片显示
This commit is contained in:
1 parent
9bf9ca768b
commit
dfcf5e8a2c
4 files changed
+89
-23
No files matched your search
+22
-11
@@ -56,7 +56,8 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
this.colSelect = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.col_db_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.col_product_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.col_main_img = new System.Windows.Forms.DataGridViewImageColumn();
|
||||
this.colImgUrl = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colMainImg = new System.Windows.Forms.DataGridViewImageColumn();
|
||||
this.col_spu_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.col_skc_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.col_cat_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
@@ -321,7 +322,8 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
this.colSelect,
|
||||
this.col_db_id,
|
||||
this.col_product_name,
|
||||
this.col_main_img,
|
||||
this.colImgUrl,
|
||||
this.colMainImg,
|
||||
this.col_spu_id,
|
||||
this.col_skc_id,
|
||||
this.col_cat_name,
|
||||
@@ -339,6 +341,7 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
this.dgvDbProduct.Size = new System.Drawing.Size(1270, 600);
|
||||
this.dgvDbProduct.TabIndex = 6;
|
||||
this.dgvDbProduct.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDbProduct_CellContentClick);
|
||||
this.dgvDbProduct.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dgvDbProduct_Scroll);
|
||||
//
|
||||
// ucSplitPage1
|
||||
//
|
||||
@@ -386,15 +389,22 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
this.col_product_name.Name = "col_product_name";
|
||||
this.col_product_name.ReadOnly = true;
|
||||
//
|
||||
// col_main_img
|
||||
// colImgUrl
|
||||
//
|
||||
this.col_main_img.FillWeight = 60F;
|
||||
this.col_main_img.HeaderText = "主图";
|
||||
this.col_main_img.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom;
|
||||
this.col_main_img.Name = "col_main_img";
|
||||
this.col_main_img.ReadOnly = true;
|
||||
this.col_main_img.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.col_main_img.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
this.colImgUrl.HeaderText = "主图路径";
|
||||
this.colImgUrl.Name = "colImgUrl";
|
||||
this.colImgUrl.ReadOnly = true;
|
||||
this.colImgUrl.Visible = false;
|
||||
//
|
||||
// colMainImg
|
||||
//
|
||||
this.colMainImg.FillWeight = 50F;
|
||||
this.colMainImg.HeaderText = "主图";
|
||||
this.colMainImg.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom;
|
||||
this.colMainImg.Name = "colMainImg";
|
||||
this.colMainImg.ReadOnly = true;
|
||||
this.colMainImg.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
this.colMainImg.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
//
|
||||
// col_spu_id
|
||||
//
|
||||
@@ -512,7 +522,8 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn colSelect;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn col_db_id;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn col_product_name;
|
||||
private System.Windows.Forms.DataGridViewImageColumn col_main_img;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colImgUrl;
|
||||
private System.Windows.Forms.DataGridViewImageColumn colMainImg;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn col_spu_id;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn col_skc_id;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn col_cat_name;
|
||||
|
||||
@@ -101,23 +101,24 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
lstTemuDbProduct.AddRange(list);
|
||||
this.ucSplitPage1.TotalPage = pageCount;
|
||||
|
||||
if (defaultBitmap == null)
|
||||
defaultBitmap = new Bitmap(80, 80);
|
||||
// 获取Bitmap的Graphics对象
|
||||
using (Graphics g = Graphics.FromImage(defaultBitmap))
|
||||
{
|
||||
// 清除整个Bitmap为蓝色
|
||||
g.Clear(Color.White);
|
||||
}
|
||||
foreach (var prod in lstTemuDbProduct)
|
||||
{
|
||||
Image image = null;
|
||||
string imgUrl = prod?.main_img?.Replace("https", "http");
|
||||
string rst = "";
|
||||
if (!string.IsNullOrWhiteSpace(imgUrl))
|
||||
image = GetHtml.GetUrlImg(imgUrl, out rst);
|
||||
if (!string.IsNullOrEmpty(rst))
|
||||
BaseMsgForm.ShowError(rst);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
int rowIndex = this.dgvDbProduct.Rows.Add(
|
||||
false,
|
||||
prod.id,
|
||||
prod.product_name,
|
||||
image, // prod.main_img,
|
||||
prod?.main_img?.Replace("https", "http"),
|
||||
defaultBitmap, // prod.main_img,
|
||||
prod.spu_id,
|
||||
prod.skc_id,
|
||||
prod.cat_name,
|
||||
@@ -128,18 +129,54 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
"删除",
|
||||
"认领");
|
||||
|
||||
dgvDbProduct.Rows[rowIndex].Height = 80;
|
||||
dgvDbProduct.Rows[rowIndex].Height = dgvDbProduct.Columns["colMainImg"].Width;
|
||||
}));
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowDgvImg();
|
||||
this.pbLoading.Visible = false;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public List<TemuDBProduct> GetProductList(out int pageCount, int page = 1, int pageSize = 50)
|
||||
Bitmap defaultBitmap = null;
|
||||
void ShowDgvImg()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach (DataGridViewRow row in this.dgvDbProduct.Rows)
|
||||
{
|
||||
if (row.Cells["colMainImg"].Displayed == false)
|
||||
continue;
|
||||
|
||||
if (row.Cells["colMainImg"].Value != null && row.Cells["colMainImg"].Value != defaultBitmap)
|
||||
continue;
|
||||
|
||||
Image image = null;
|
||||
string imgUrl = row.Cells["colImgUrl"]?.Value.ParseToString();
|
||||
string getImgError = "";
|
||||
if (!string.IsNullOrWhiteSpace(imgUrl))
|
||||
image = GetHtml.GetUrlImg(imgUrl, out getImgError);
|
||||
if (!string.IsNullOrEmpty(getImgError))
|
||||
BaseMsgForm.ShowError(getImgError);
|
||||
|
||||
try
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colMainImg"].Value = image;
|
||||
}));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<TemuDBProduct> GetProductList(out int pageCount, int page = 1, int pageSize = 200)
|
||||
{
|
||||
List<TemuDBProduct> list = new List<TemuDBProduct>();
|
||||
pageCount = 1;
|
||||
@@ -398,5 +435,10 @@ namespace TemuKJD.KJDForms.ProductSelectForms
|
||||
BaseMsgForm.ShowError("请选择商品!");
|
||||
}
|
||||
}
|
||||
|
||||
private void dgvDbProduct_Scroll(object sender, ScrollEventArgs e)
|
||||
{
|
||||
ShowDgvImg();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,10 @@
|
||||
<metadata name="col_product_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="col_main_img.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<metadata name="colImgUrl.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colMainImg.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="col_spu_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
|
||||
@@ -321,6 +321,7 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
+ "&login_name=" + shop.LoginName
|
||||
+ "&login_status=" + shop.LoginStatus
|
||||
+ "&cookie=" + shopCookies.Replace("&", "&").Replace("%", "%").Replace("+", "+")
|
||||
+ "&cookie2=" + shop.Cookies2.Replace("&", "&").Replace("%", "%").Replace("+", "+")
|
||||
+ fTool;
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (!result.Contains("\"code\":200"))
|
||||
@@ -874,6 +875,15 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
else
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=seller.kuajingmaihuo.com;';";
|
||||
}
|
||||
// 全球站cookie
|
||||
foreach (var shopCook in shop?.Cookies2?.Split(';'))
|
||||
{
|
||||
var cookie = shopCook.Trim();
|
||||
if (!cookie.StartsWith("SUB_PASS_ID") && !cookie.StartsWith("mallid") && !cookie.StartsWith("_nano_fp"))
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=.kuajingmaihuo.com;';";
|
||||
else
|
||||
cookJs += "\r\ndocument.cookie='" + cookie + "; domain=seller.kuajingmaihuo.com;';";
|
||||
}
|
||||
cookJs += "\r\nwindow.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');";
|
||||
cookJs += "\r\nsetTimeout(() => { window.location.href='https://seller.kuajingmaihuo.com'; }, 200)";
|
||||
Clipboard.SetDataObject(cookJs);
|
||||
|
||||
Reference in new issue
Block a user