广告直通车功能 2修复活动勾选问题 3加入发货台功能完成20%
This commit is contained in:
1 parent
a6b36c64b0
commit
e2b37df00b
35 files changed
+6832
-236
No files matched your search
@@ -32,6 +32,10 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
public partial class AdminShopLoginForm : LRBaseForm
|
||||
{
|
||||
public int CloseAfterSecond { get; set; }
|
||||
/// <summary>
|
||||
/// 推广直通车登录
|
||||
/// </summary>
|
||||
public bool IsAdsLogin { get; set; } = false;
|
||||
public EnumOpenType openType = EnumOpenType.manage;
|
||||
public bool isMultiLogin = false;
|
||||
public string MultiLoginCookieName = "";
|
||||
@@ -234,7 +238,7 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
List<Cookie> cookieList2 = CEFBrowser.GetCookieList(shopCookieHead2, cefWebBrowser.GetCookieManager(null)); // cef138
|
||||
if (cookieList2 != null && cookieList2.Count > 0)
|
||||
{
|
||||
for(int i =0; i < cookieList2.Count; i++)
|
||||
for(int i = 0; i < cookieList2.Count; i++)
|
||||
{
|
||||
var cookie = cookieList2[i];
|
||||
cookies2 += cookie.Name + "=" + cookie.Value + "; ";
|
||||
@@ -280,24 +284,104 @@ namespace TemuKJD.KJDForms.AdminForms
|
||||
ShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
|
||||
}
|
||||
OnSaveComplete(shop);
|
||||
if (this.Created && this.chkCloseAfterLogin.Checked)
|
||||
if (!IsAdsLogin)
|
||||
{
|
||||
//Invoke(new Action(() => { this.Close(); }));
|
||||
if (this.Created && this.chkCloseAfterLogin.Checked)
|
||||
Invoke(new Action(() => { this.Close(); }));
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAdsLogin && !string.IsNullOrEmpty(shop.ad_seller_unique_id) && 1 == 2)
|
||||
{
|
||||
var obtainCodeRst = ShopListForm.GetObtainCode(shop);
|
||||
var obtainCode = BaseRegex.GetStringJson(ref obtainCodeRst, "code");
|
||||
//https://ads.temu.com/login.html?
|
||||
//redirectUrl=https%3A%2F%2Fads.temu.com%2Findex.html%3FadAreaOverride%3D2&userType=1&mallType=0
|
||||
//&ticket=Zjze2NHyZFaGP88ROyjN19a47ae59611391a296ae6403bbbfa39e9046ceba744aafe8227fd6
|
||||
//&adSellerUniqueId=eyJ1IjoiTVF3NFRGVmN2ZUVyZG1USDdOQ2o5dz09IiwidiI6MX0%3D&source=2&seller_source=11&adAreaOverride=2
|
||||
string url = "https://ads.temu.com/login.html?" +
|
||||
"redirectUrl=https%3A%2F%2Fads.temu.com%2Findex.html%3FadAreaOverride%3D2&userType=1&mallType=0&ticket=" + obtainCode +
|
||||
"&adSellerUniqueId=" + shop.ad_seller_unique_id + "&source=2&seller_source=11&adAreaOverride=2";
|
||||
cefWebBrowser.Load(url);
|
||||
}
|
||||
else if (IsAdsLogin)
|
||||
{
|
||||
cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sGetElementWithText);
|
||||
|
||||
//点击商品推广按钮
|
||||
var adsJsStr = "window.scrollTo(0, document.body.scrollHeight);";
|
||||
var adsResponse = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(adsJsStr);
|
||||
adsResponse.Wait(1000);
|
||||
Thread.Sleep(Randomx.GetId(500, 1000));
|
||||
|
||||
adsJsStr = "var clickItem = getElementWithText('商品推广'); " +
|
||||
"clickItem.click()";
|
||||
adsResponse = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(adsJsStr);
|
||||
adsResponse.Wait(1000);
|
||||
Thread.Sleep(Randomx.GetId(500, 1000));
|
||||
|
||||
// 模拟人为点击一次,否则窗口不跳转
|
||||
var host = cefWebBrowser.GetBrowser().GetHost();
|
||||
int x = Randomx.GetId(50, 200);
|
||||
int y = Randomx.GetId(1, 10);
|
||||
// 按下鼠标左键
|
||||
host.SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.None);
|
||||
Thread.Sleep(50 + Randomx.GetId(200));
|
||||
host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None);
|
||||
Thread.Sleep(Randomx.GetId(100, 500));
|
||||
|
||||
//点击确认授权并前往按钮
|
||||
adsJsStr = "var clickItem = getElementWithText('确认授权并前往'); " +
|
||||
"clickItem.parentElement.click();";
|
||||
adsResponse = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(adsJsStr);
|
||||
adsResponse.Wait(1000);
|
||||
Thread.Sleep(Randomx.GetId(300, 800));
|
||||
}
|
||||
}
|
||||
|
||||
if (1 == 1 && this.shop != null && currentUrl.StartsWith("https://ads.temu.com/index.html?adAreaOverride="))
|
||||
{
|
||||
if (!cefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||
continue;
|
||||
|
||||
if (openType != EnumOpenType.login)
|
||||
continue;
|
||||
|
||||
if (!lstShopCompany.Any(c => c.AccountId == shop.ShopId))
|
||||
continue;
|
||||
|
||||
shop.ad_url = txtAddress.Text;
|
||||
string cookiesAds = "";
|
||||
List<Cookie> cookieAdsList = CEFBrowser.GetCookieList("ads.temu.com", cefWebBrowser.GetCookieManager(null));
|
||||
if (cookieAdsList != null && cookieAdsList.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < cookieAdsList.Count; i++)
|
||||
{
|
||||
var cookie = cookieAdsList[i];
|
||||
cookiesAds += cookie.Name + "=" + cookie.Value + "; ";
|
||||
}
|
||||
cookiesAds = cookiesAds.Trim().TrimEnd(';');
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(cookiesAds))
|
||||
{
|
||||
shop.ad_login_status = "在线";
|
||||
shop.ad_cookie = cookiesAds;
|
||||
StartUp.SaveLocalShopLoginInfo(); // 店铺保存到本地
|
||||
ShopListForm.UpdateServerShopAdsCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
|
||||
OnSaveComplete(shop);
|
||||
if (this.Created && this.chkCloseAfterLogin.Checked)
|
||||
{
|
||||
Invoke(new Action(() => { this.Close(); }));
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
var obtainCodeRst = ShopListForm.GetObtainCode(shop);
|
||||
var obtainCode = BaseRegex.GetStringJson(ref obtainCodeRst, "code");
|
||||
//https://ads.temu.com/login.html?
|
||||
//redirectUrl=https%3A%2F%2Fads.temu.com%2Findex.html%3FadAreaOverride%3D2&userType=1&mallType=0
|
||||
//&ticket=Zjze2NHyZFaGP88ROyjN19a47ae59611391a296ae6403bbbfa39e9046ceba744aafe8227fd6
|
||||
//&adSellerUniqueId=eyJ1IjoiTVF3NFRGVmN2ZUVyZG1USDdOQ2o5dz09IiwidiI6MX0%3D&source=2&seller_source=11&adAreaOverride=2
|
||||
string url = "https://ads.temu.com/login.html?" +
|
||||
"redirectUrl=https%3A%2F%2Fads.temu.com%2Findex.html%3FadAreaOverride%3D2&userType=1&mallType=0&ticket=" + obtainCode +
|
||||
"&source=2&seller_source=11&adAreaOverride=2";
|
||||
cefWebBrowser.Load(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user