1拼多多商品分组 2拼多多登录逻辑优化
This commit is contained in:
1 parent
8fb90422a2
commit
378170ffb5
36 files changed
+4272
-736
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user