广告直通车功能 2修复活动勾选问题 3加入发货台功能完成20%
This commit is contained in:
1 parent
a6b36c64b0
commit
e2b37df00b
35 files changed
+6832
-236
No files matched your search
@@ -33,18 +33,24 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
{
|
||||
login,
|
||||
manage,
|
||||
ads, // 广告登录
|
||||
}
|
||||
public partial class ShopLoginForm : LRBaseForm
|
||||
{
|
||||
public static ShopLoginForm shopLoginInstance { get; set; } = null;
|
||||
|
||||
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 = "";
|
||||
public string InitUrl = "";
|
||||
private string shopCookieHead = "kuajingmaihuo.com";
|
||||
private string shopCookieHead2 = "temu.com";
|
||||
private string shopCookieHead3 = "ads.temu.com";
|
||||
private string shopLoginUrl = "http://seller.kuajingmaihuo.com/login";
|
||||
private string shopMainUrl = "https://seller.kuajingmaihuo.com";
|
||||
private string shopMainUrl2 = "https://agentseller.temu.com";
|
||||
@@ -222,10 +228,29 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
else
|
||||
{
|
||||
var cookie2 = shop.Cookies2;
|
||||
//var cookie2Lst = cookie2.Split(new string[] { ";", " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
//cookie2 = "";
|
||||
//foreach (var item in cookie2Lst)
|
||||
//{
|
||||
// if (item.StartsWith("mallid="))
|
||||
// cookie2 += "mallid=" + shop.ShopId + ";";
|
||||
// else
|
||||
// cookie2 += item + ";";
|
||||
//}
|
||||
var t = CEFBrowser.SetCookieAsync(shopCookieHead2, cookie2, cefWebBrowser.GetCookieManager(null));
|
||||
t.Wait(5000);
|
||||
cefWebBrowser.Load("https://agentseller.temu.com");
|
||||
}
|
||||
|
||||
Thread.Sleep(500);
|
||||
if (!string.IsNullOrEmpty(shop.ShopId))
|
||||
{
|
||||
var storageJsCode = "window.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');\r\n";
|
||||
storageJsCode += "window.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');\r\n";
|
||||
while (!cefWebBrowser.IsBrowserInitialized || !cefWebBrowser.GetBrowser().MainFrame.IsValid || cefWebBrowser.IsLoading)
|
||||
Thread.Sleep(20);
|
||||
cefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(storageJsCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -299,14 +324,106 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
}
|
||||
StartUp.SaveLocalShopLoginInfo(); // 店铺保存到本地
|
||||
ShopListForm.UpdateServerShopCookies(shop); // 店铺cookie写入服务端,多店共用一个登录账号一组cookie
|
||||
if (!IsAdsLogin)
|
||||
{
|
||||
OnSaveComplete(shop);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -443,6 +560,14 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
t2.Wait(5000);
|
||||
}
|
||||
|
||||
if (this.openType == EnumOpenType.ads)
|
||||
{
|
||||
var cookieAds = shop.ad_cookie;
|
||||
var t2 = CEFBrowser.SetCookieAsync(shopCookieHead3, cookieAds, cefWebBrowser.GetCookieManager(null));
|
||||
t2.Wait(5000);
|
||||
cefWebBrowser.Load(InitUrl);
|
||||
}
|
||||
|
||||
//根据登录的具体店铺设置local storage
|
||||
if (!string.IsNullOrEmpty(shop.ShopId))
|
||||
{
|
||||
@@ -510,11 +635,13 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
|
||||
{
|
||||
if (this.Created)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
currentUrl = e.Address;
|
||||
txtAddress.Text = e.Address;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void CefWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
|
||||
@@ -1102,5 +1229,14 @@ function getElementWithText(sText)
|
||||
ReturnPackageDetailForm form = new ReturnPackageDetailForm(this.shop);
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void txtAddress_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (txtAddress.Text.Contains("&adSellerUniqueId="))
|
||||
{
|
||||
string address = txtAddress.Text.Trim();
|
||||
shop.ad_seller_unique_id = BaseRegex.GetStringQuery(ref address, "adSellerUniqueId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user