diff --git a/.gitignore b/.gitignore index 9a09230..d1a0fd9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ Bin NotUse obj -.psd \ No newline at end of file +.psd +packages +.user \ No newline at end of file diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index 84c71fa..5177925 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -89,7 +89,7 @@ namespace AllBase public static string OriginUrl = "http://mobile.yangkeduo.com"; public static string NewUrl = "https://yangkeduo.com"; - public static string ServerUrl = "http://localhost:8000"; + public static string ServerUrl = "http://localhost:9000"; /// /// 订单监控延迟 /// @@ -142,7 +142,7 @@ namespace AllBase /// 图片API /// //public static string LoginApiUrl = "http://new.qixiaoke.com/"; - public static string LoginApiUrl = "http://localhost:8000"; + public static string LoginApiUrl = "http://localhost:9000"; public static string BigDataApiUrl = "http://bigdata.qixiaoke.com/"; public static string GateApi = ""; public static string QqGroupNum = ""; diff --git a/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs b/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs index 4837043..6f39a31 100644 --- a/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs +++ b/TEMUKJD/KJDForms/ShopForms/ShopListForm.cs @@ -218,12 +218,14 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms /// 店铺名称 /// cookies /// 工具名称(可不填写) - public static void AddServerDouShopCookies(string shopName, string shopCookies, string fromTool = null) + public static void AddServerShopCookies(DouShopLoginInfo shop, string shopCookies, string fromTool = null) { var fTool = string.IsNullOrEmpty(fromTool) ? "" : "&from_tool=" + fromTool; - var url = BaseClass.BuildObjString("shop&act=add_shop_cookie"); + var url = BaseClass.BuildObjString("shop/mdy_shop"); var data = UserLogin.GetSignaturex() - + "&shop_name=" + shopName + + "&login_name=" + shop.LoginName + + "&shop_id=" + shop.ShopAccountId + + "&shop_account=" + shop.ShopAccount + "&cookie=" + shopCookies.Replace("&", "&").Replace("%", "%").Replace("+", "+") + fTool; var result = GetHtml.PostUtf8(url, data); @@ -517,18 +519,18 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms if (shop != null) { retryLogin: - var loginResult = GetShopStatus(shop); + var loginResult = "\"code\":0";//GetShopStatus(shop); if (loginResult.Contains("\"code\":0")) { shop.LoginStatus = "登录成功"; - var shopId = BaseRegex.GetStringJson(ref loginResult, "id"); - var shopToken = BaseRegex.GetStringJson(ref loginResult, "token"); - var shopName = BaseRegex.GetStringJson(ref loginResult, "shop_name"); - var mobile = BaseRegex.GetStringJson(ref loginResult, "mobile"); - if (!string.IsNullOrEmpty(shopId)) shop.ShopAccountId = shopId; - if (!string.IsNullOrEmpty(shopToken)) shop.ShopToken = shopToken; - if (!string.IsNullOrEmpty(shopName)) shop.ShopAccount = shopName; - if (!string.IsNullOrEmpty(mobile)) shop.Mobile = mobile; + //var shopId = BaseRegex.GetStringJson(ref loginResult, "id"); + //var shopToken = BaseRegex.GetStringJson(ref loginResult, "token"); + //var shopName = BaseRegex.GetStringJson(ref loginResult, "shop_name"); + //var mobile = BaseRegex.GetStringJson(ref loginResult, "mobile"); + //if (!string.IsNullOrEmpty(shopId)) shop.ShopAccountId = shopId; + //if (!string.IsNullOrEmpty(shopToken)) shop.ShopToken = shopToken; + //if (!string.IsNullOrEmpty(shopName)) shop.ShopAccount = shopName; + //if (!string.IsNullOrEmpty(mobile)) shop.Mobile = mobile; } else if (loginResult.Contains("未登录")) { @@ -720,7 +722,15 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms switch (headerText) { case "检测": - CheckShopLoginAsync(new string[] { loginName }); + //CheckShopLoginAsync(new string[] { loginName }); + IsOperate = true; + { + ShopLoginForm shopLoginForm = new ShopLoginForm(shop); + shopLoginForm.openType = EnumOpenType.manage; + shopLoginForm.SaveComplete += shopLoginForm_SaveComplete; + shopLoginForm.ShowDialog(); + IsOperate = false; + } break; case "删除": if (BaseMsgForm.ShowConfirm("确定删除店铺吗?删除后不可恢复!").DialogResult == DialogResult.Cancel) @@ -736,37 +746,40 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms break; case "登录": IsOperate = true; - ShopLoginForm shopLoginForm = new ShopLoginForm(shop); - shopLoginForm.SaveComplete += shopLoginForm_SaveComplete; - shopLoginForm.ShowDialog(); - IsOperate = false; - break; - case "多重登录": - IsOperate = true; - ShopLoginForm shopMultiLoginForm = new ShopLoginForm(shop); - shopMultiLoginForm.isMultiLogin = true; - shopMultiLoginForm.SaveComplete += shopLoginForm_SaveComplete; - shopMultiLoginForm.ShowDialog(); - IsOperate = false; - break; - case "接口授权": - case "上货授权": - IsOperate = true; - //GetHtml.OpenUrl("https://fuwu.jinritemai.com/authorize?service_id=815"); - ShopAuthForm shopAuthForm = new ShopAuthForm(shop); - shopAuthForm.SaveComplete += shopLoginForm_SaveComplete; - shopAuthForm.ShowDialog(); - IsOperate = false; - break; - case "拍单授权": - IsOperate = true; - //GetHtml.OpenUrl("https://fuwu.jinritemai.com/detail?from=fuwu_market_orderDetail&service_id=20896"); - ShopAuthForm shopAuthForm1 = new ShopAuthForm(shop); - shopAuthForm1.shopAuthUrl = "https://fuwu.jinritemai.com/authorize?service_id=20896"; - shopAuthForm1.SaveComplete += shopLoginForm_SaveComplete; - shopAuthForm1.ShowDialog(); + { + ShopLoginForm shopLoginForm = new ShopLoginForm(shop); + shopLoginForm.openType = EnumOpenType.login; + shopLoginForm.SaveComplete += shopLoginForm_SaveComplete; + shopLoginForm.ShowDialog(); + } IsOperate = false; break; + //case "多重登录": + // IsOperate = true; + // ShopLoginForm shopMultiLoginForm = new ShopLoginForm(shop); + // shopMultiLoginForm.isMultiLogin = true; + // shopMultiLoginForm.SaveComplete += shopLoginForm_SaveComplete; + // shopMultiLoginForm.ShowDialog(); + // IsOperate = false; + // break; + //case "接口授权": + //case "上货授权": + // IsOperate = true; + // //GetHtml.OpenUrl("https://fuwu.jinritemai.com/authorize?service_id=815"); + // ShopAuthForm shopAuthForm = new ShopAuthForm(shop); + // shopAuthForm.SaveComplete += shopLoginForm_SaveComplete; + // shopAuthForm.ShowDialog(); + // IsOperate = false; + // break; + //case "拍单授权": + // IsOperate = true; + // //GetHtml.OpenUrl("https://fuwu.jinritemai.com/detail?from=fuwu_market_orderDetail&service_id=20896"); + // ShopAuthForm shopAuthForm1 = new ShopAuthForm(shop); + // shopAuthForm1.shopAuthUrl = "https://fuwu.jinritemai.com/authorize?service_id=20896"; + // shopAuthForm1.SaveComplete += shopLoginForm_SaveComplete; + // shopAuthForm1.ShowDialog(); + // IsOperate = false; + // break; default: dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value; break; @@ -830,6 +843,7 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms if (shopInfo != null && !string.IsNullOrEmpty(shopInfo.LoginName) && !string.IsNullOrEmpty(shopInfo.Password)) { ShopLoginForm shopLoginForm = new ShopLoginForm(shopInfo); + shopLoginForm.openType = EnumOpenType.login; shopLoginForm.SaveComplete += shopLoginForm_SaveComplete; shopLoginForm.ShowDialog(); } diff --git a/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.cs b/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.cs index d60b5b6..fb00f1f 100644 --- a/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.cs +++ b/TEMUKJD/KJDForms/ShopForms/ShopLoginForm.cs @@ -26,9 +26,15 @@ using Work.BLL.Tools; namespace LittleRabbit.LittleRabbitForms.ShopForms { + public enum EnumOpenType + { + login, + manage, + } public partial class ShopLoginForm : LRBaseForm { public int CloseAfterSecond { get; set; } + public EnumOpenType openType = EnumOpenType.manage; public bool isMultiLogin = false; public string MultiLoginCookieName = ""; private string shopCookieHead = "kuajingmaihuo.com"; @@ -51,6 +57,12 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms { //this.splitContainer1.SplitterDistance = 674; + if (openType == EnumOpenType.login) + { + this.shop.ShopAccountId = ""; + this.shop.ShopAccount = ""; + } + if (isMultiLogin && shop != null) { this.pnlMultiLogin.Visible = true; @@ -87,25 +99,27 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms while (this.Created) { Thread.Sleep(3000); - if (this.shop != null && currentUrl == shopMainUrl) + //continue; + + if (this.shop != null && currentUrl.TrimEnd('/') == shopMainUrl) { if (!cefWebBrowser.GetBrowser().MainFrame.IsValid) continue; - continue; + if (openType!= EnumOpenType.login) + continue; - var jsStr = "function getShopName() { return document.getElementsByClassName('headerShopName')[0].innerHTML; } getShopName();"; - var response = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr); - response.Wait(5000); - var res = response.Result.Result?.ToString(); - if (res != null && res.Contains("")) + if (string.IsNullOrEmpty(shop.ShopAccountId) || string.IsNullOrEmpty(shop.ShopAccount)) + continue; + + //var jsStr = "function getShopName() { return document.getElementsByClassName('headerShopName')[0].innerHTML; } getShopName();"; + //var response = cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(jsStr); + //response.Wait(5000); + //var res = response.Result.Result?.ToString(); + //if (res != null && res.Contains("")) { - shop.ShopAccount = res.Substring(res.IndexOf("") + 7); - shop.ShopAccount = BaseRegex.FliterHtmlTag(shop.ShopAccount); - //if (shop.ShopName.Contains("") + 1); - //if (shop.ShopName.Contains("")) - // shop.ShopName = shop.ShopName.Substring(0, shop.ShopName.IndexOf("")); + //shop.ShopAccount = res.Substring(res.IndexOf("") + 7); + //shop.ShopAccount = BaseRegex.FliterHtmlTag(shop.ShopAccount); string cookies = ""; List cookieList = CEFBrowser.GetCookieList(shopCookieHead, cefWebBrowser.RequestContext.GetCookieManager(null)); if (cookieList != null && cookieList.Count > 0) @@ -120,16 +134,17 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms cookies = cookies.Trim().TrimEnd(';'); } shop.Cookies = cookies; - if (isMultiLogin) - { - shop.DictMultiCookies[MultiLoginCookieName] = cookies; - } + //if (isMultiLogin) + //{ + // shop.DictMultiCookies[MultiLoginCookieName] = cookies; + //} if (!string.IsNullOrEmpty(shop.Cookies) && !string.IsNullOrEmpty(shop.ShopAccount) && !string.IsNullOrEmpty(shop.ShopAccountId) //&& !string.IsNullOrEmpty(shop.Mobile) - && !string.IsNullOrEmpty(shop.ShopToken)) + //&& !string.IsNullOrEmpty(shop.ShopToken) + ) { shop.LoginStatus = "登录成功"; @@ -137,16 +152,18 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms var shopInfo = GlobalConfig.DouShopLoginList.FirstOrDefault(v => v.ShopAccountId == shop.ShopAccountId); if (shopInfo != null) { - shopInfo.ShopToken = shop.ShopToken; - shopInfo.Mobile = shop.Mobile; + //shopInfo.ShopToken = shop.ShopToken; + //shopInfo.Mobile = shop.Mobile; shopInfo.Cookies = shop.Cookies; shopInfo.Password = shop.Password; + shopInfo.ShopAccountId = shop.ShopAccountId; + shopInfo.ShopAccount = shop.ShopAccount; } else GlobalConfig.DouShopLoginList.Add(shop); StartUp.SaveDouShopLoginInfo(); //ShopListForm.AddServerDouShop(shop); // 店铺写入到服务端 - ShopListForm.AddServerDouShopCookies(shop.ShopAccount, shop.Cookies); // cookie写入到服务端 + ShopListForm.AddServerShopCookies(shop, shop.Cookies); // cookie写入到服务端 OnSaveComplete(shop); if (this.Created && this.chkCloseAfterLogin.Checked) { @@ -232,7 +249,7 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms if (cefWebBrowser == null) { - cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser(shopMainUrl, false); + cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false); CustomResourceRequestHandlerLocal resourceRequestHandler = new CustomResourceRequestHandlerLocal(); resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete; cefWebBrowser.RequestHandler = new CustomRequestHandler(resourceRequestHandler); @@ -252,32 +269,38 @@ namespace LittleRabbit.LittleRabbitForms.ShopForms cookie = shop.DictMultiCookies.Keys.Contains(MultiLoginCookieName) ? shop.DictMultiCookies[MultiLoginCookieName] : ""; var t = CEFBrowser.SetCookieAsync(shopCookieHead, cookie, cefWebBrowser.RequestContext.GetCookieManager(null)); - splitContainer1.Panel1.Controls.Add(cefWebBrowser); Task.Run(() => { + Thread.Sleep(20); + cefWebBrowser.Load(shopMainUrl); + + if (openType != EnumOpenType.login) + return; + for (int i = 0; i < 50; i++) { Thread.Sleep(100); } - if (GlobalConfig.dicLocalStorage != null) - { - Thread.Sleep(500); - string jsCode = "function setStorage() {"; - foreach (var item in GlobalConfig.dicLocalStorage) - { - if (item.Key == "$TCC_CONFIG" || item.Key == "$TCC_CONFIG_operate_config" || item.Key == "menuStyleStr") - continue; + //设置 local storage + //if (GlobalConfig.dicLocalStorage != null) + //{ + // Thread.Sleep(500); + // string jsCode = "function setStorage() {"; + // foreach (var item in GlobalConfig.dicLocalStorage) + // { + // if (item.Key == "$TCC_CONFIG" || item.Key == "$TCC_CONFIG_operate_config" || item.Key == "menuStyleStr") + // continue; - jsCode += "window.localStorage.setItem('" + item.Key + "', '" + item.Value + "');\r\n"; - } - jsCode += "}"; - jsCode += "setStorage();"; - if (cefWebBrowser.GetBrowser().MainFrame.IsValid) - cefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(jsCode); - } + // jsCode += "window.localStorage.setItem('" + item.Key + "', '" + item.Value + "');\r\n"; + // } + // jsCode += "}"; + // jsCode += "setStorage();"; + // if (cefWebBrowser.GetBrowser().MainFrame.IsValid) + // cefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(jsCode); + //} if (!this.Created) return;