1拼多多商品分组 2拼多多登录逻辑优化

This commit is contained in:
wule committed 2025-10-01 16:05:39 +08:00
1 parent 8fb90422a2
commit 378170ffb5
36 files changed
+4272 -736

No files matched your search

-1
View File
@@ -625,7 +625,6 @@
this.colUpdateCookies.ReadOnly = true;
this.colUpdateCookies.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.colUpdateCookies.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.colUpdateCookies.Visible = false;
//
// colCopyCookies
//
+14 -23
View File
@@ -28,7 +28,8 @@ namespace TemuKJD.PDDForms.ShopForms
public partial class PDDShopListForm : BaseForm
{
public static List<PDDShopListForm> LstShopListFormInatance = new List<PDDShopListForm>();
public static PDDShopListForm Instance { get; set; } = null;
private static PDDShopListForm _instance = null;
public static PDDShopListForm Instance { get { if (_instance == null) { _instance = new PDDShopListForm(); } return _instance; } set { _instance = value; } }
public static bool IsOperate { get; set; } = false;
private bool isLoading { get; set; } = false;
@@ -288,7 +289,10 @@ namespace TemuKJD.PDDForms.ShopForms
{
//CheckShopListLogin(new string[] { (obj as DouShopLoginInfo).LoginName });
StartUp.SaveLocalShopLoginInfo();
btnRefreshCookie_Click(null, null);
Invoke(new Action(() =>
{
btnRefreshCookie_Click(null, null);
}));
});
}
@@ -571,7 +575,7 @@ namespace TemuKJD.PDDForms.ShopForms
if (shop != null)
{
var loginResult = GetShopStatus(shop);
var loginResult = CheckShopLogin(shop);
if (!loginResult.Contains("\"success\":true"))
{
shop.Cookies = "empty=true;";
@@ -589,26 +593,6 @@ namespace TemuKJD.PDDForms.ShopForms
sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
}
//loginResult = PDDShopListForm.GetShopStatus2(shop);
//if (!loginResult.Contains("\"success\":true"))
//{
// shop.Cookies2 = "empty=true;";
// foreach (var sc in campanys)
// {
// sc.LoginStatus2 = "国际版未登录";
// sc.Cookies2 = "empty=true;";
// }
//}
//else
//{
// foreach (var sc in campanys)
// {
// sc.LoginStatus2 = "国际版在线";
// sc.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
// }
//}
//if (!string.IsNullOrEmpty(loginResult))
// shop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
StartUp.SaveLocalShopLoginInfo();
}
@@ -633,6 +617,13 @@ namespace TemuKJD.PDDForms.ShopForms
return HttpResponseBLL.PDDPostResponse(shop, url, body, refere);
}
public static string CheckShopLogin(ShopLoginInfo shop, string refere = "https://mms.pinduoduo.com/home/")
{
string url = "https://mms.pinduoduo.com/janus/api/checkLogin";
string body = @"{}";
return HttpResponseBLL.PDDPostResponse(shop, url, body, refere);
}
/// <summary>
/// 获取国际版登录状态
/// </summary>
+137 -80
View File
@@ -32,6 +32,7 @@ namespace TemuKJD.PDDForms.ShopForms
{
login,
manage,
refresh_cookie,
}
public partial class PDDShopLoginForm : LRBaseForm
{
@@ -122,99 +123,147 @@ namespace TemuKJD.PDDForms.ShopForms
if (!cefWebBrowser.GetBrowser().MainFrame.IsValid)
continue;
if (openType == EnumOpenType.refresh_cookie)
{
string cookies = "";
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
foreach (var cookie in cookieList)
{
cookie.Domain = cookie.Domain.Replace(".mms.pinduoduo.com", "mms.pinduoduo.com");
}
List<Cookie> cookieListNew = new List<Cookie>();
if (cookieList != null && cookieList.Count > 0)
{
foreach (var cookie in cookieList)
{
//PASS_ID同时出现两个,domain是mms.pinduoduo.com才是能登录店铺后台的
if (cookie.Name == "PASS_ID" && cookie.Domain != "mms.pinduoduo.com"
&& cookieList.Any(c => c.Name == "PASS_ID" && c.Domain == "mms.pinduoduo.com"))
continue;
cookies += cookie.Name + "=" + cookie.Value + "; ";
cookieListNew.Add(cookie);
}
cookies = JsonHelper.SerializeObject(cookieListNew);
if (!string.IsNullOrEmpty(cookies))
{
shop.Cookies = cookies;
shop.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
PDDShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端
if (this.Created && this.chkCloseAfterLogin.Checked)
{
Invoke(new Action(() => { this.Close(); }));
}
else
{
break;
}
}
}
}
if (openType!= EnumOpenType.login)
continue;
if (!lstShopCompany.Any(c => c.LoginName == shop.LoginName))
continue;
string cookies = "";
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
List<Cookie> cookieListNew = new List<Cookie>();
if (cookieList != null && cookieList.Count > 0)
else // 检测到登录成功后
{
string cookies = "";
List<Cookie> cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.GetCookieManager(null));
foreach (var cookie in cookieList)
{
//PASS_ID同时出现两个,domain是mms.pinduoduo.com才是能登录店铺后台的
if (cookie.Name == "PASS_ID" && cookie.Domain != "mms.pinduoduo.com"
&& cookieList.Any(c => c.Name == "PASS_ID" && c.Domain == "mms.pinduoduo.com"))
continue;
cookies += cookie.Name + "=" + cookie.Value + "; ";
cookieListNew.Add(cookie);
cookie.Domain = cookie.Domain.Replace(".mms.pinduoduo.com", "mms.pinduoduo.com");
}
//cookies = cookies.Trim().TrimEnd(';');
cookies = JsonHelper.SerializeObject(cookieListNew);
}
if (!string.IsNullOrEmpty(cookies)
&& lstShopCompany.Any(c => c.LoginName == shop.LoginName))
{
var lstShopCompanyCopy = lstShopCompany.ToList();
lstShopCompanyCopy = lstShopCompanyCopy.Where(l => l.LoginName == shop.LoginName).ToList();
foreach (ShopCompany sc in lstShopCompanyCopy)
List<Cookie> cookieListNew = new List<Cookie>();
if (cookieList != null && cookieList.Count > 0)
{
ShopLoginInfo newShop = new ShopLoginInfo()
foreach (var cookie in cookieList)
{
LoginName = shop.LoginName,
Password = shop.Password,
GroupName = shop.GroupName,
ShopAccount = sc.AccountName,
ShopId = sc.AccountId,
SubUserName = shop.SubUserName,
Notes = shop.Notes,
AntiContents = new NaiBa.Util.ConcurrentList<string> { sc.AntiContent },
};
//PASS_ID同时出现两个,domain是mms.pinduoduo.com才是能登录店铺后台的
if (cookie.Name == "PASS_ID" && cookie.Domain != "mms.pinduoduo.com"
&& cookieList.Any(c => c.Name == "PASS_ID" && c.Domain == "mms.pinduoduo.com"))
continue;
var oldShop = GlobalConfig.ShopLoginList.FirstOrDefault(l =>
l.LoginName == newShop.LoginName);
if (oldShop == null)
cookies += cookie.Name + "=" + cookie.Value + "; ";
cookieListNew.Add(cookie);
}
//cookies = cookies.Trim().TrimEnd(';');
cookies = JsonHelper.SerializeObject(cookieListNew);
}
if (!string.IsNullOrEmpty(cookies)
&& lstShopCompany.Any(c => c.LoginName == shop.LoginName))
{
var lstShopCompanyCopy = lstShopCompany.ToList();
lstShopCompanyCopy = lstShopCompanyCopy.Where(l => l.LoginName == shop.LoginName).ToList();
foreach (ShopCompany sc in lstShopCompanyCopy)
{
GlobalConfig.ShopLoginList.Add(newShop);
ShopBLL.AddServerShop(newShop); // 店铺写入到服务端
ShopLoginInfo newShop = new ShopLoginInfo()
{
LoginName = shop.LoginName,
Password = shop.Password,
GroupName = shop.GroupName,
ShopAccount = sc.AccountName,
ShopId = sc.AccountId,
SubUserName = shop.SubUserName,
Notes = shop.Notes,
AntiContents = new NaiBa.Util.ConcurrentList<string> { sc.AntiContent },
};
var oldShop = GlobalConfig.ShopLoginList.FirstOrDefault(l =>
l.LoginName == newShop.LoginName);
if (oldShop == null)
{
GlobalConfig.ShopLoginList.Add(newShop);
ShopBLL.AddServerShop(newShop); // 店铺写入到服务端
}
else
{
oldShop.LoginName = newShop.LoginName;
oldShop.Password = newShop.Password;
oldShop.GroupName = newShop.GroupName;
oldShop.ShopAccount = newShop.ShopAccount;
oldShop.ShopId = newShop.ShopId;
oldShop.SubUserName = newShop.SubUserName;
oldShop.Notes = newShop.Notes;
oldShop.AntiContents.AddRange(newShop.AntiContents);
while (oldShop.AntiContents.Count > 50)
oldShop.AntiContents.RemoveAt(0);
// 店铺更新写入到服务端
var url = BaseClass.BuildObjString("shop/mdy_shop");
var data = UserLogin.GetSignaturex()
+ "&login_name=" + oldShop.LoginName
+ "&new_shop_id=" + oldShop.ShopId
+ "&shop_account=" + oldShop.ShopAccount;
var result = GetHtml.PostUtf8(url, data);
ShopBLL.MdyAntiContent(oldShop);
}
}
var lstShop = GlobalConfig.ShopLoginList.Where(l => l.LoginName == shop.LoginName).ToList();
foreach (var s in lstShop)
{
s.LoginStatus = "登录成功";
s.Cookies = cookies;
s.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
StartUp.SaveLocalShopLoginInfo(); // 店铺保存到本地
PDDShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
OnSaveComplete(shop);
if (this.Created && this.chkCloseAfterLogin.Checked)
{
Invoke(new Action(() => { this.Close(); }));
}
else
{
oldShop.LoginName = newShop.LoginName;
oldShop.Password = newShop.Password;
oldShop.GroupName = newShop.GroupName;
oldShop.ShopAccount = newShop.ShopAccount;
oldShop.ShopId = newShop.ShopId;
oldShop.SubUserName = newShop.SubUserName;
oldShop.Notes = newShop.Notes;
oldShop.AntiContents.AddRange(newShop.AntiContents);
while (oldShop.AntiContents.Count > 50)
oldShop.AntiContents.RemoveAt(0);
// 店铺更新写入到服务端
var url = BaseClass.BuildObjString("shop/mdy_shop");
var data = UserLogin.GetSignaturex()
+ "&login_name=" + oldShop.LoginName
+ "&new_shop_id=" + oldShop.ShopId
+ "&shop_account=" + oldShop.ShopAccount;
var result = GetHtml.PostUtf8(url, data);
ShopBLL.MdyAntiContent(oldShop);
break;
}
}
var lstShop = GlobalConfig.ShopLoginList.Where(l => l.LoginName == shop.LoginName).ToList();
foreach(var s in lstShop)
{
s.LoginStatus = "登录成功";
s.Cookies = cookies;
s.LastRefreshDate = DateTime.Now.ToString("yyyyMMdd");
}
StartUp.SaveLocalShopLoginInfo(); // 店铺保存到本地
PDDShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
OnSaveComplete(shop);
if (this.Created && this.chkCloseAfterLogin.Checked)
{
Invoke(new Action(() => { this.Close(); }));
}
else
break;
}
}
}
@@ -429,7 +478,7 @@ namespace TemuKJD.PDDForms.ShopForms
private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
{
if (this.Created)
if (this.Created && !this.IsDisposed)
Invoke(new Action(() =>
{
currentUrl = e.Address;
@@ -497,7 +546,11 @@ namespace TemuKJD.PDDForms.ShopForms
Task.Run(() =>
{
GetAntiContentsTimes++;
Invoke(new Action(() => { try { this.TitleText = "店铺登录 - " + GetAntiContentsTimes; } catch { return; } }));
if (this.Created && !this.IsDisposed)
Invoke(new Action(() =>
{
try { this.TitleText = "店铺登录 - " + GetAntiContentsTimes; } catch { return; }
}));
shop.AntiContents.Add(antiContent);
while (shop.AntiContents.Count > 50)
shop.AntiContents.RemoveAt(0);
@@ -515,9 +568,13 @@ namespace TemuKJD.PDDForms.ShopForms
var data = responseData;
if (this.shop != null && data.Contains("\"success\":true"))
{
var username = BaseRegex.GetStringJson(ref data, "username");
var maskMobile = BaseRegex.GetStringJson(ref data, "mobile");
maskMobile = maskMobile.Split('*').Last();
if (!string.IsNullOrEmpty(maskMobile) && shop.LoginName.EndsWith(maskMobile))
if (string.IsNullOrWhiteSpace(maskMobile) || string.IsNullOrWhiteSpace(username))
return;
if (shop.LoginName.EndsWith(maskMobile) || shop.LoginName == username)
{
lstShopCompany.Clear();
var jObj = JObject.Parse(data);
@@ -1124,7 +1181,7 @@ function getElementWithText(sText)
}
var newData = JsonHelper.SerializeObject(prodParamObj);
var saveProdRst = prodUserSelectForm.save_goods_edit_data(shop, newData, goodsId, commitId, false, "edit");
var saveProdRst = prodUserSelectForm.save_goods_edit_data(shop, newData, goodsId, commitId, true, "edit");
if (!saveProdRst.Contains("\"success\":true"))
{
var error = BaseRegex.GetStringJson(ref saveProdRst, "error_msg");
@@ -1134,7 +1191,7 @@ function getElementWithText(sText)
return;
}
Thread.Sleep(Randomx.GetId(100, 600));
var submitProdRst = prodUserSelectForm.submit_goods_edit(shop, goodsId, commitId, false, "edit");
var submitProdRst = prodUserSelectForm.submit_goods_edit(shop, goodsId, commitId, true, "edit");
if (!submitProdRst.Contains("\"success\":true"))
{
var error = BaseRegex.GetStringJson(ref submitProdRst, "error_msg");
+29 -27
View File
@@ -37,6 +37,7 @@
this.txtSubPassId = new System.Windows.Forms.TextBox();
this.txtLoginName = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.btnOk = new TemuKJD.UserControls.ButtonEx();
this.label2 = new System.Windows.Forms.Label();
this.txtSellerTemp = new System.Windows.Forms.TextBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
@@ -44,7 +45,6 @@
this.buttonEx1 = new TemuKJD.UserControls.ButtonEx();
this.label8 = new System.Windows.Forms.Label();
this.txtCookieJs2 = new DevComponents.DotNetBar.Controls.TextBoxX();
this.btnOk = new TemuKJD.UserControls.ButtonEx();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@@ -95,11 +95,11 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(40, 103);
this.label4.Location = new System.Drawing.Point(37, 83);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(60, 34);
this.label4.Size = new System.Drawing.Size(63, 17);
this.label4.TabIndex = 399;
this.label4.Text = " 国内版\r\nCookieJs";
this.label4.Text = "cookie_id";
//
// txtCookieJs1
//
@@ -119,29 +119,31 @@
this.txtCookieJs1.Border.PaddingLeft = 2;
this.txtCookieJs1.Border.PaddingRight = 2;
this.txtCookieJs1.Border.PaddingTop = 2;
this.txtCookieJs1.Location = new System.Drawing.Point(100, 101);
this.txtCookieJs1.Location = new System.Drawing.Point(100, 80);
this.txtCookieJs1.Multiline = true;
this.txtCookieJs1.Name = "txtCookieJs1";
this.txtCookieJs1.Size = new System.Drawing.Size(569, 198);
this.txtCookieJs1.Size = new System.Drawing.Size(569, 219);
this.txtCookieJs1.TabIndex = 398;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(16, 72);
this.label3.Location = new System.Drawing.Point(16, 54);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(84, 17);
this.label3.TabIndex = 397;
this.label3.Text = "SUB_PASS_ID";
this.label3.Visible = false;
//
// txtSubPassId
//
this.txtSubPassId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSubPassId.Location = new System.Drawing.Point(100, 69);
this.txtSubPassId.Location = new System.Drawing.Point(100, 51);
this.txtSubPassId.Name = "txtSubPassId";
this.txtSubPassId.Size = new System.Drawing.Size(569, 23);
this.txtSubPassId.TabIndex = 396;
this.txtSubPassId.Visible = false;
//
// txtLoginName
//
@@ -161,6 +163,23 @@
this.label1.TabIndex = 394;
this.label1.Text = "登录账号";
//
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOk.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnOk.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOk.ForeColor = System.Drawing.Color.White;
this.btnOk.Location = new System.Drawing.Point(614, 0);
this.btnOk.Margin = new System.Windows.Forms.Padding(2);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(55, 26);
this.btnOk.TabIndex = 392;
this.btnOk.Text = "保存";
this.btnOk.UseVisualStyleBackColor = false;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// label2
//
this.label2.AutoSize = true;
@@ -259,31 +278,14 @@
this.txtCookieJs2.TabIndex = 393;
this.txtCookieJs2.Visible = false;
//
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOk.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnOk.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOk.ForeColor = System.Drawing.Color.White;
this.btnOk.Location = new System.Drawing.Point(614, 0);
this.btnOk.Margin = new System.Windows.Forms.Padding(2);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(55, 26);
this.btnOk.TabIndex = 392;
this.btnOk.Text = "保存";
this.btnOk.UseVisualStyleBackColor = false;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// ShopUpdateCookieForm
// PDDShopUpdateCookieForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(700, 407);
this.Controls.Add(this.panel2);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "ShopUpdateCookieForm";
this.Name = "PDDShopUpdateCookieForm";
this.Text = "更新Cookie";
this.TitleText = "更新Cookie";
this.Load += new System.EventHandler(this.ShopUpdateCookieForm_Load);
@@ -15,6 +15,7 @@ using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using Work;
using TemuKJD.BLL;
using CefSharp;
namespace TemuKJD.PDDForms.ShopForms
{
@@ -86,7 +87,7 @@ namespace TemuKJD.PDDForms.ShopForms
cookieVersion = this.radioButton1.Checked ? "国内版" : "国际版";
bool ok1 = false;
bool ok2 = false;
if (this.txtCookieJs1.Text.Contains("SUB_PASS_ID") || !string.IsNullOrWhiteSpace(txtSubPassId.Text))
if ((this.txtCookieJs1.Text.Contains("PASS_ID") && this.txtCookieJs1.Text.Contains("api_uid")) || !string.IsNullOrWhiteSpace(txtSubPassId.Text))
{
ok1 = GetCookie1();
}
@@ -105,53 +106,100 @@ namespace TemuKJD.PDDForms.ShopForms
bool GetCookie1()
{
string txt = this.txtCookieJs1.Text;
txt = txt.Replace("SUB_PASS_ID=;", "").Replace("_nano_fp=;", "").Replace("api_uid=;", "")
.Replace("_bee=;", "").Replace("ru2k=;", "").Replace("_f77=;", "")
.Replace("_a42=;", "").Replace("rckk=;", "").Replace("ru1k=;", "");
txt = txt.Replace("PASS_ID=;", "").Replace("JSESSIONID=;", "").Replace("_nano_fp=;", "").Replace("api_uid=;", "")
.Replace("_bee=;", "").Replace("_f77=;", "").Replace("mms_b84d1838=", "")
.Replace("_a42=;", "").Replace("rckk=;", "").Replace("ru1k=;", "").Replace("ru2k=;", "")
.Replace("webp=;", "").Replace("x-visit-time=;", "");
string api_uid = BaseRegex.GetStringCookie(ref txt, "api_uid").ParseToString().Trim('\'');
string _nano_fp = BaseRegex.GetStringCookie(ref txt, "_nano_fp").ParseToString().Trim('\'');
string _bee = BaseRegex.GetStringCookie(ref txt, "_bee").ParseToString().Trim('\'');
string _f77 = BaseRegex.GetStringCookie(ref txt, "_f77").ParseToString().Trim('\'');
string _a42 = BaseRegex.GetStringCookie(ref txt, "_a42").ParseToString().Trim('\'');
string rckk = BaseRegex.GetStringCookie(ref txt, "rckk").ParseToString().Trim('\'');
string ru1k = BaseRegex.GetStringCookie(ref txt, "ru1k").ParseToString().Trim('\'');
string ru2k = BaseRegex.GetStringCookie(ref txt, "ru2k").ParseToString().Trim('\'');
string SUB_PASS_ID = BaseRegex.GetStringCookie(ref txt, "SUB_PASS_ID").ParseToString().Trim('\'');
string JSESSIONID = BaseRegex.GetStringCookie(ref txt, "JSESSIONID").ParseToString().Trim('\'', '\n', '\r');
string _nano_fp = BaseRegex.GetStringCookie(ref txt, "_nano_fp").ParseToString().Trim('\'', '\n', '\r');
string api_uid = BaseRegex.GetStringCookie(ref txt, "api_uid").ParseToString().Trim('\'', '\n', '\r');
string _bee = BaseRegex.GetStringCookie(ref txt, "_bee").ParseToString().Trim('\'', '\n', '\r');
string _f77 = BaseRegex.GetStringCookie(ref txt, "_f77").ParseToString().Trim('\'', '\n', '\r');
string mms_b84d1838 = BaseRegex.GetStringCookie(ref txt, "mms_b84d1838").ParseToString().Trim('\'', '\n', '\r');
string _a42 = BaseRegex.GetStringCookie(ref txt, "_a42").ParseToString().Trim('\'', '\n', '\r');
string rckk = BaseRegex.GetStringCookie(ref txt, "rckk").ParseToString().Trim('\'', '\n', '\r');
string ru1k = BaseRegex.GetStringCookie(ref txt, "ru1k").ParseToString().Trim('\'', '\n', '\r');
string ru2k = BaseRegex.GetStringCookie(ref txt, "ru2k").ParseToString().Trim('\'', '\n', '\r');
string webp = BaseRegex.GetStringCookie(ref txt, "webp").ParseToString().Trim('\'', '\n', '\r');
string x_visit_time = BaseRegex.GetStringCookie(ref txt, "x-visit-time").ParseToString().Trim('\'', '\n', '\r');
string PASS_ID = BaseRegex.GetStringCookie(ref txt, "PASS_ID").ParseToString().Trim('\'', '\n', '\r');
if (!string.IsNullOrWhiteSpace(this.txtSubPassId.Text))
SUB_PASS_ID = this.txtSubPassId.Text.Trim();
string cookie = "api_uid=" + api_uid + ";" +
"_nano_fp=" + _nano_fp + ";" +
"_bee=" + _bee + ";" +
"_f77=" + _f77 + ";" +
"_a42=" + _a42 + ";" +
"rckk=" + rckk + ";" +
"ru1k=" + ru1k + ";" +
"ru2k=" + ru2k + ";" +
"SUB_PASS_ID=" + SUB_PASS_ID + ";";
PASS_ID = this.txtSubPassId.Text.Trim();
if (string.IsNullOrEmpty(SUB_PASS_ID))
if (string.IsNullOrEmpty(PASS_ID))
{
BaseMsgForm.ShowError("Cookie缺少关键字段,请检查!");
return false;
}
string cookie = "_a42=" + _a42 + ";" +
"_bee=" + _bee + ";" +
"_f77=" + _f77 + ";" +
"_nano_fp=" + _nano_fp + ";" +
"api_uid=" + api_uid + ";" +
"JSESSIONID=" + JSESSIONID + ";" +
"mms_b84d1838=" + mms_b84d1838 + ";" +
"PASS_ID=" + PASS_ID + ";" +
"rckk=" + rckk + ";" +
"ru1k=" + ru1k + ";" +
"ru2k=" + ru2k + ";" +
"webp=" + webp + ";" +
"x-visit-time=" + x_visit_time + ";";
List<Cookie> cookieList = new List<Cookie>();
if (!string.IsNullOrEmpty(_a42))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "_a42", Value = _a42, Expires = DateTime.Now.AddYears(1), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(_bee))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "_bee", Value = _bee, Expires = DateTime.Now.AddYears(1), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(_f77))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "_f77", Value = _f77, Expires = DateTime.Now.AddYears(1), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(_nano_fp))
cookieList.Add(new Cookie() { Domain = "mms.pinduoduo.com", Name = "_nano_fp", Value = _nano_fp, Expires = DateTime.Now.AddDays(400), });
if (!string.IsNullOrEmpty(api_uid))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "api_uid", Value = api_uid, Expires = DateTime.Now.AddDays(400), });
if (!string.IsNullOrEmpty(JSESSIONID))
cookieList.Add(new Cookie() { Domain = "mms.pinduoduo.com", Name = "JSESSIONID", Value = JSESSIONID, HttpOnly = true, });
if (!string.IsNullOrEmpty(mms_b84d1838))
cookieList.Add(new Cookie() { Domain = "mms.pinduoduo.com", Name = "mms_b84d1838", Value = mms_b84d1838, Expires = DateTime.Now.AddDays(100), });
if (!string.IsNullOrEmpty(PASS_ID))
cookieList.Add(new Cookie() { Domain = "mms.pinduoduo.com", Name = "PASS_ID", Value = PASS_ID, Expires = DateTime.Now.AddDays(30), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(rckk))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "rckk", Value = rckk, Expires = DateTime.Now.AddYears(1), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(ru1k))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "ru1k", Value = ru1k, Expires = DateTime.Now.AddYears(1), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(ru2k))
cookieList.Add(new Cookie() { Domain = ".pinduoduo.com", Name = "ru2k", Value = ru2k, Expires = DateTime.Now.AddYears(1), HttpOnly = true, Secure = true, });
if (!string.IsNullOrEmpty(webp))
cookieList.Add(new Cookie() { Domain = "mms.pinduoduo.com", Name = "webp", Value = webp, Expires = DateTime.Now.AddDays(14), Path= "/home" });
if (!string.IsNullOrEmpty(x_visit_time))
cookieList.Add(new Cookie() { Domain = "mms.pinduoduo.com", Name = "x-visit-time", Value = x_visit_time, Expires = DateTime.Now.AddDays(100), });
cookie = JsonHelper.SerializeObject(cookieList);
var cookieShop = new ShopLoginInfo();
cookieShop.Cookies = cookie;
cookieShop.Cookies = JsonHelper.SerializeObject(cookieList);
var data = "";
data = PDDShopListForm.GetShopStatus(cookieShop);
if (!data.Contains("\"success\":true"))
if (!data.Contains("\"success\":true") || data.Contains("会话已过期"))
{
BaseMsgForm.ShowError("cookie已失效!");
return false;
}
var maskMobile = BaseRegex.GetStringJson(ref data, "maskOwnerMobile");
if (!shopLoginInfo.LoginName.EndsWith(maskMobile))
var username = BaseRegex.GetStringJson(ref data, "username");
var maskMobile = BaseRegex.GetStringJson(ref data, "mobile");
var mallName = BaseRegex.GetStringJson(ref data, "mall_name");
maskMobile = maskMobile.Split('*').Last();
if (string.IsNullOrWhiteSpace(maskMobile) || string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(mallName))
{
BaseMsgForm.ShowError("cookie与国内版店铺不匹配,请核对店铺!");
BaseMsgForm.ShowError("店铺信息获取失败!");
return false;
}
if (!shopLoginInfo.LoginName.EndsWith(maskMobile) && shopLoginInfo.LoginName != username && shopLoginInfo.LoginName != mallName)
{
BaseMsgForm.ShowError("cookie与店铺不匹配,请核对店铺!");
return false;
}
@@ -177,8 +225,24 @@ namespace TemuKJD.PDDForms.ShopForms
}
}
shopLoginInfo.Cookies = cookie;
shopLoginInfo.ShopId = username;
shopLoginInfo.ShopAccount = mallName;
shopLoginInfo.LoginStatus = "登录成功";
PDDShopListForm.UpdateServerShopCookies(shopLoginInfo); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
// 店铺更新写入到服务端
var url = BaseClass.BuildObjString("shop/mdy_shop");
var data1 = UserLogin.GetSignaturex()
+ "&login_name=" + shopLoginInfo.LoginName
+ "&new_shop_id=" + shopLoginInfo.ShopId
+ "&shop_account=" + shopLoginInfo.ShopAccount;
var result = GetHtml.PostUtf8(url, data1);
PDDShopListForm.UpdateServerShopCookies(shopLoginInfo); // 店铺cookie写入服务端,不同账号下的同名店铺一起更新cookie
PDDShopLoginForm loginForm = new PDDShopLoginForm(shopLoginInfo);
loginForm.openType = EnumOpenType.refresh_cookie;
loginForm.ShowDialog();
return true;
}