diff --git a/29WxOrder/29WxOrder.csproj b/29WxOrder/29WxOrder.csproj
index 9427498..75fc514 100644
--- a/29WxOrder/29WxOrder.csproj
+++ b/29WxOrder/29WxOrder.csproj
@@ -51,7 +51,7 @@
true
- bin\x64\Release\
+ ..\bin\
TRACE
true
pdbonly
@@ -59,6 +59,7 @@
7.3
prompt
true
+ 4
true
diff --git a/29WxOrder/FactoryExportForms/FactoryExportForm.cs b/29WxOrder/FactoryExportForms/FactoryExportForm.cs
index 481ef7a..a8db5af 100644
--- a/29WxOrder/FactoryExportForms/FactoryExportForm.cs
+++ b/29WxOrder/FactoryExportForms/FactoryExportForm.cs
@@ -18,6 +18,7 @@ using Work;
using Work.Api;
using Work.BaseForms;
using AllBase.Helper;
+using AllBase.Model.Local;
namespace _29WxOrder.FactoryExportForms
{
diff --git a/29WxOrder/MainForm.cs b/29WxOrder/MainForm.cs
index 70701ea..6976f33 100644
--- a/29WxOrder/MainForm.cs
+++ b/29WxOrder/MainForm.cs
@@ -42,6 +42,7 @@ using Work.BaseForms;
using Work.BuyUsers;
using _29WxOrder.MyControl;
using Work.BLL;
+using AllBase.Model.Local;
namespace _29WxOrder
{
diff --git a/29WxOrder/OrderForms/AfterSaleOrderListForm.cs b/29WxOrder/OrderForms/AfterSaleOrderListForm.cs
index 0f68a71..58ad075 100644
--- a/29WxOrder/OrderForms/AfterSaleOrderListForm.cs
+++ b/29WxOrder/OrderForms/AfterSaleOrderListForm.cs
@@ -3,6 +3,7 @@ using _29WxOrder.ShopForms;
using AllBase;
using AllBase.DouYinModel.Result;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using NaiBa.Util;
using NaiBa.Util.Helper;
diff --git a/29WxOrder/OrderForms/AfterSaleReturnRefundForm.cs b/29WxOrder/OrderForms/AfterSaleReturnRefundForm.cs
index cc9b11e..aee12d9 100644
--- a/29WxOrder/OrderForms/AfterSaleReturnRefundForm.cs
+++ b/29WxOrder/OrderForms/AfterSaleReturnRefundForm.cs
@@ -1,5 +1,6 @@
using AllBase;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using DevComponents.DotNetBar;
using Newtonsoft.Json.Linq;
diff --git a/29WxOrder/OrderForms/BuyOrderForms.cs b/29WxOrder/OrderForms/BuyOrderForms.cs
index 3a820db..b5e6089 100644
--- a/29WxOrder/OrderForms/BuyOrderForms.cs
+++ b/29WxOrder/OrderForms/BuyOrderForms.cs
@@ -24,6 +24,7 @@ using Work.Api;
using Work.BaseForms;
using Work.BuyUsers;
using Work.Pinduoduo;
+using AllBase.Model.Local;
namespace _29WxOrder.OrderForms
{
@@ -43,7 +44,7 @@ namespace _29WxOrder.OrderForms
public delegate void delegateClick(object sender, EventArgs e);
public string order_id;
public DouYinOrderModel orderDetail;
- public AllBase.Model.Result.ShopLoginInfo shop;
+ public ShopLoginInfo shop;
public string webUrl = "https://yangkeduo.com/goods.html?goods_id=";
public static string PddUid = "";
public string detailHtml = "";//商品详情
diff --git a/29WxOrder/OrderForms/BuyOrderListForm.cs b/29WxOrder/OrderForms/BuyOrderListForm.cs
index e202ea5..68e05b2 100644
--- a/29WxOrder/OrderForms/BuyOrderListForm.cs
+++ b/29WxOrder/OrderForms/BuyOrderListForm.cs
@@ -1,6 +1,7 @@
using AllBase;
using AllBase.DouYinModel.Result;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
diff --git a/29WxOrder/OrderForms/OrderEdit.cs b/29WxOrder/OrderForms/OrderEdit.cs
index 4cba167..c216972 100644
--- a/29WxOrder/OrderForms/OrderEdit.cs
+++ b/29WxOrder/OrderForms/OrderEdit.cs
@@ -1,6 +1,7 @@
using AllBase;
using AllBase.DouYinModel.Result;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using Newtonsoft.Json.Linq;
using System;
diff --git a/29WxOrder/OrderForms/RemarkEditForm.cs b/29WxOrder/OrderForms/RemarkEditForm.cs
index 5e20c2a..f5736fc 100644
--- a/29WxOrder/OrderForms/RemarkEditForm.cs
+++ b/29WxOrder/OrderForms/RemarkEditForm.cs
@@ -1,6 +1,7 @@
using AllBase;
using AllBase.DouYinModel.Result;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
diff --git a/29WxOrder/OrderForms/SendOrderListForms.cs b/29WxOrder/OrderForms/SendOrderListForms.cs
index aa04b81..ffaa3af 100644
--- a/29WxOrder/OrderForms/SendOrderListForms.cs
+++ b/29WxOrder/OrderForms/SendOrderListForms.cs
@@ -2,6 +2,7 @@
using AllBase;
using AllBase.DouYinModel.Result;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json;
diff --git a/29WxOrder/OrderForms/SuccessOrderListForm.cs b/29WxOrder/OrderForms/SuccessOrderListForm.cs
index dc5c53a..3bf3115 100644
--- a/29WxOrder/OrderForms/SuccessOrderListForm.cs
+++ b/29WxOrder/OrderForms/SuccessOrderListForm.cs
@@ -20,6 +20,7 @@ using Work;
using Work.Api;
using Work.BaseForms;
using Work.BuyUsers;
+using AllBase.Model.Local;
namespace _29WxOrder.OrderForms
{
diff --git a/29WxOrder/ShopForms/ShopBrower.cs b/29WxOrder/ShopForms/ShopBrower.cs
index e1d5cfb..4086192 100644
--- a/29WxOrder/ShopForms/ShopBrower.cs
+++ b/29WxOrder/ShopForms/ShopBrower.cs
@@ -19,6 +19,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Work.BaseForms;
+using AllBase.Model.Local;
namespace _29WxOrder.ShopForms
{
diff --git a/29WxOrderWpf/29WxOrderWpf.csproj b/29WxOrderWpf/29WxOrderWpf.csproj
index 2910c37..3d47928 100644
--- a/29WxOrderWpf/29WxOrderWpf.csproj
+++ b/29WxOrderWpf/29WxOrderWpf.csproj
@@ -40,7 +40,7 @@
true
full
false
- ..\..\KJD Cef138\Bin\
+ ..\Bin\
DEBUG;TRACE
prompt
4
@@ -49,7 +49,7 @@
x64
pdbonly
true
- ..\..\KJD Cef138\Bin\
+ ..\Bin\
TRACE
prompt
4
@@ -99,14 +99,15 @@
BaseMsgWindow.xaml
+
-
- PDDBuyerOrderListCtrl.xaml
+
+ PDDBuyerOrderReadCtrl.xaml
PDDBuyerSelectCtrl.xaml
@@ -145,7 +146,7 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
@@ -325,10 +326,13 @@
-
+
-
+
+
+
+
diff --git a/29WxOrderWpf/CefHelper/WPFCEFBrowser.cs b/29WxOrderWpf/CefHelper/WPFCEFBrowser.cs
new file mode 100644
index 0000000..1e1ebba
--- /dev/null
+++ b/29WxOrderWpf/CefHelper/WPFCEFBrowser.cs
@@ -0,0 +1,573 @@
+using CefSharp;
+using CefSharp.Handler;
+using CefSharp.Wpf;
+using NaiBa.Util;
+using NaiBa.Util.Extension;
+using NaiBa.Util.Helper;
+using NaiBa.Util.Model;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Work._29Tools.CefTools;
+
+namespace _29WxOrderWpf.CefHelper
+{
+ public class WPFCEFBrowser
+ {
+ public static bool IsKeepGlobalCookie = true; // true 的时候,cookie 会保存在硬盘上,cookie 是持久化的
+ public static string CefGlobalCachePath = Path.Combine(FileHelper.GetApplicationDir(), "cef_temp");
+ public static string CefMemoryCachePath = Path.Combine(CefGlobalCachePath, "memory");
+
+ public static void Init(string userAgent = "")
+ {
+ // 必须在主线程进行初始化
+
+ if (NaiBaGlobalConfig.IsDevelopment)
+ {
+ FileHelper.DeleteFolder(CefGlobalCachePath);
+ }
+ FileHelper.CreateDirectory(CefGlobalCachePath);
+
+ CefSharpSettings.WcfEnabled = false;
+ CefSettings settings = new CefSettings
+ {
+ IgnoreCertificateErrors = false,
+ Locale = "zh-CN",
+ PersistSessionCookies = true,
+ //PersistUserPreferences = true, //cef138
+ LogFile = Path.Combine(CefGlobalCachePath, "debug.log"),
+ LogSeverity = NaiBaGlobalConfig.IsDevelopment ? LogSeverity.Verbose : LogSeverity.Error,
+ CachePath = IsKeepGlobalCookie ? CefGlobalCachePath : string.Empty,
+ RootCachePath = IsKeepGlobalCookie ? CefGlobalCachePath : string.Empty
+ };
+
+ settings.UserAgent = string.IsNullOrEmpty(userAgent) ? NaiBaGlobalConfig.UserAgent : userAgent;
+
+ settings.CefCommandLineArgs.Add("disable-gpu", "1");
+ settings.CefCommandLineArgs.Add("--ignore-ssl-errors");
+ settings.CefCommandLineArgs.Add("--disable-web-security");
+ settings.CefCommandLineArgs.Add("--allow-file-access-from-files"); // 允许通过 file:/// 协议访问 Worker
+ System.Net.IWebProxy webProxy = NaiBaGlobalConfig.GetDevelopProxy();
+ if (webProxy != null)
+ {
+ if (NaiBaGlobalConfig.IsDevelopment)
+ {
+ bool isSetFiddlerProxy = false; // 由于店铺可能绑定了代理,浏览器不设置 Fiddler 代理
+ if (isSetFiddlerProxy)
+ {
+ string address = ReflectionHelper.GetObjectPropertyValue(webProxy, "Address").ParseToString();
+ if (!address.IsNullOrEmpty())
+ {
+ address = address.Trim('/');
+ // Don't set any proxy during initialize,becuase once setting,it couldn't be changed at runtime
+ settings.CefCommandLineArgs.Add("--proxy-server", address);
+ }
+ }
+ }
+ }
+ var rst = Cef.Initialize(settings);
+ }
+
+ ///
+ /// 关闭所有Cef进程
+ ///
+ public static void ShutDown()
+ {
+ Cef.Shutdown();
+ }
+
+ public static ChromiumWebBrowser CreateChromiumWebBrowser(string url, bool isGlobal = true, bool isPopupNewWindow = true)
+ {
+ ChromiumWebBrowser cefBrowser = new ChromiumWebBrowser(url);
+ if (!isGlobal)
+ {
+ cefBrowser.RequestContext = new RequestContext(GetRequestContextIsolateSettings());
+ }
+ cefBrowser.BrowserSettings = new BrowserSettings
+ {
+ Javascript = CefState.Enabled,
+ JavascriptAccessClipboard = CefState.Enabled,
+ JavascriptCloseWindows = CefState.Enabled,
+ JavascriptDomPaste = CefState.Enabled,
+ LocalStorage = CefState.Enabled,
+
+
+ //Plugins = CefState.Disabled, //cef138
+ //FileAccessFromFileUrls = CefState.Enabled, //cef138
+ //UniversalAccessFromFileUrls = CefState.Enabled //cef138
+ };
+ cefBrowser.KeyboardHandler = new KeyboardHandler();
+ cefBrowser.MenuHandler = new LocalMenuHandler();
+ cefBrowser.LifeSpanHandler = new LocalLifeSpanHandler(isPopupNewWindow ? PopWindowType.NewWindow : PopWindowType.SelfWindow);
+ return cefBrowser;
+ }
+
+ public static RequestContextSettings GetRequestContextIsolateSettings()
+ {
+ RequestContextSettings requestContextSettings = new RequestContextSettings()
+ {
+ PersistSessionCookies = true,
+ CookieableSchemesExcludeDefaults = false,
+ };
+ //requestContextSettings.PersistSessionCookies = false;
+ //requestContextSettings.PersistUserPreferences = false; // cef138
+ return requestContextSettings;
+ }
+
+ public static void CheckCefPlatform()
+ {
+ string executingFolder = FileHelper.GetApplicationDir();
+ //If libcef.dll doesn't exist in our executing folder then we'll copy the files
+ //For this method the user must have write permissions to the executing folder.
+ if (!File.Exists(Path.Combine(executingFolder, "libcef.dll")))
+ {
+ var libPath = Path.Combine(executingFolder, Environment.Is64BitProcess ? "x64" : "x86");
+
+ if (Directory.Exists(libPath))
+ {
+ FileHelper.MoveFolder(libPath, executingFolder);
+ }
+
+ string dir = executingFolder + "x86";
+ if (Directory.Exists(dir))
+ {
+ Directory.Delete(dir, recursive: true);
+ }
+ dir = executingFolder + "x64";
+ if (Directory.Exists(dir))
+ {
+ Directory.Delete(dir, recursive: true);
+ }
+ }
+ }
+
+ public static async Task SetProxyAsync(ChromiumWebBrowser cefWebBrowser, string proxyUrl)
+ {
+ bool isUseProxy = false;
+ await Cef.UIThreadTaskFactory.StartNew(() =>
+ {
+ try
+ {
+ var rc = cefWebBrowser.GetBrowser().GetHost().RequestContext;
+ var dict = new Dictionary();
+ if (string.IsNullOrEmpty(proxyUrl))
+ {
+ dict.Add("mode", "system");
+ }
+ else
+ {
+ var objProxy = HttpHelper.ResoveProxyServer(proxyUrl);
+ if (objProxy.Tag == 1)
+ {
+ BaseProxyServer baseProxyServer = objProxy.Data;
+ if (!baseProxyServer.Username.IsNullOrEmpty() && !baseProxyServer.Password.IsNullOrEmpty())
+ {
+ LocalRequestHandler customRequestHandler = cefWebBrowser.RequestHandler as LocalRequestHandler;
+ if (customRequestHandler != null)
+ {
+ customRequestHandler.UserName = baseProxyServer.Username;
+ customRequestHandler.Password = baseProxyServer.Password;
+ }
+ }
+ proxyUrl = string.Format("http://{0}:{1}", baseProxyServer.ServerIP, baseProxyServer.ServerPort);
+ }
+ dict.Add("mode", "fixed_servers"); // fixed_servers,pac_script,auto_detect,system,direct
+ dict.Add("server", proxyUrl);
+ }
+ string error;
+
+ bool success = rc.SetPreference("proxy", dict, out error);
+ if (success)
+ {
+ isUseProxy = true;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteWithTime(ex);
+ }
+ });
+ return isUseProxy;
+ }
+
+ public static string ParseCookieListToString(List cookieList)
+ {
+ string cookies = string.Empty;
+ foreach (Cookie cookie in cookieList)
+ {
+ cookies += string.Format("{0}={1};", cookie.Name, cookie.Value);
+ }
+ return cookies;
+ }
+
+ public static List GetCookieList(string domains = "", ICookieManager cookieManager = null)
+ {
+ if (cookieManager == null)
+ {
+ cookieManager = Cef.GetGlobalCookieManager();
+ }
+ LocalCookieVisitor visitor = new LocalCookieVisitor();
+ if (cookieManager.VisitAllCookies(visitor))
+ {
+ visitor.WaitForAllCookie();
+ }
+ if (string.IsNullOrEmpty(domains))
+ {
+ return visitor.CookieList;
+ }
+ else
+ {
+ List list = new List();
+ foreach (string domain in domains.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
+ {
+ list.AddRange(visitor.CookieList.Where(p => p.Domain != null && p.Domain.Contains(domain.Trim())).ToList());
+ }
+ return list;
+ }
+ }
+
+ public static string GetCookie(string domains = "", ICookieManager cookieManager = null)
+ {
+ List cookieList = GetCookieList(domains, cookieManager);
+ string cookies = ParseCookieListToString(cookieList);
+ return cookies;
+ }
+
+ public static async Task SetCookieAsync(string domain, string cookies, ICookieManager cookieManager = null)
+ {
+ try
+ {
+ foreach (string cookie in cookies.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
+ {
+ int i = cookie.IndexOf('=');
+ if (i > 0)
+ {
+ string name = cookie.Substring(0, i).ToString().Trim();
+ string value = cookie.Substring(i + 1).ToString().Trim();
+ if (name.ToLower() == "expires" || name.ToLower() == "path" || name.ToLower() == "domain")
+ {
+ continue;
+ }
+ Cookie newCookie = new Cookie
+ {
+ Domain = domain,
+ Name = name,
+ Value = value,
+ Path = "/"
+ };
+ if (cookieManager == null)
+ {
+ bool result = await Cef.GetGlobalCookieManager().SetCookieAsync("http://" + domain, newCookie);
+ }
+ else
+ {
+ bool result = await cookieManager.SetCookieAsync("http://" + domain, newCookie);
+ }
+ }
+ }
+ }
+ catch { }
+ }
+
+ public static async Task SetCookieAsync(string cookieList, ICookieManager cookieManager = null)
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(cookieList))
+ {
+ List list = JsonConvert.DeserializeObject>(cookieList);
+ foreach (Cookie cookie in list)
+ {
+ cookie.Secure = false;
+ if (cookieManager == null)
+ {
+ bool result = await Cef.GetGlobalCookieManager().SetCookieAsync("http://" + cookie.Domain.Trim('.'), cookie);
+ }
+ else
+ {
+ bool result = await cookieManager.SetCookieAsync("http://" + cookie.Domain.Trim('.'), cookie);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteWithTime(ex);
+ }
+ }
+
+ public static async Task DeleteCookieAsync(ICookieManager cookieManager, string domain = "", string name = "")
+ {
+ string url = string.Empty;
+ if (!string.IsNullOrEmpty(domain))
+ {
+ url = "http://" + domain;
+ }
+ if (cookieManager == null)
+ {
+ int result = await Cef.GetGlobalCookieManager().DeleteCookiesAsync(url, name);
+ }
+ else
+ {
+ int result = await cookieManager.DeleteCookiesAsync(url, name);
+ }
+ }
+
+ public static void DeleteCookie(ICookieManager cookieManager, string domain = "", string name = "")
+ {
+ string url = string.Empty;
+ if (!string.IsNullOrEmpty(domain))
+ {
+ url = "http://" + domain;
+ }
+ if (cookieManager == null)
+ {
+ bool result = Cef.GetGlobalCookieManager().DeleteCookies(url, name);
+ }
+ else
+ {
+ bool result = cookieManager.DeleteCookies(url, name);
+ }
+ }
+
+ public static void ExecJavascript(ChromiumWebBrowser cefWebBrowser, string js)
+ {
+ // cef138
+ //List frameIdentifierList = cefWebBrowser.GetBrowser().GetFrameIdentifiers();
+ //foreach (long identifier in frameIdentifierList)
+ List frameIdentifierList = cefWebBrowser.GetBrowser().GetFrameIdentifiers();
+ foreach (string identifier in frameIdentifierList)
+ {
+ //IFrame frame = cefWebBrowser.GetBrowser().GetFrame(identifier);
+ IFrame frame = cefWebBrowser.GetBrowser().GetFrameByIdentifier(identifier);
+ if (frame.IsMain)
+ {
+ frame.ExecuteJavaScriptAsync(js);
+ break;
+ }
+ }
+ }
+
+ public static void ExecJavascript(ChromiumWebBrowser cefWebBrowser, string expectUrl, string js, Func checkUrl)
+ {
+ // cef138
+ //List frameIdentifierList = cefWebBrowser.GetBrowser().GetFrameIdentifiers();
+ //foreach (long identifier in frameIdentifierList)
+ List frameIdentifierList = cefWebBrowser.GetBrowser().GetFrameIdentifiers();
+ foreach (string identifier in frameIdentifierList)
+ {
+ //IFrame frame = cefWebBrowser.GetBrowser().GetFrame(identifier);
+ IFrame frame = cefWebBrowser.GetBrowser().GetFrameByIdentifier(identifier);
+ if (checkUrl(frame.Url, expectUrl))
+ {
+ frame.ExecuteJavaScriptAsync(js);
+ break;
+ }
+ }
+ }
+
+ public static void ExecJavascriptEqualsUrl(ChromiumWebBrowser cefWebBrowser, string url, string js)
+ {
+ ExecJavascript(cefWebBrowser, url, js, (frameUrl, expectUrl) =>
+ {
+ if (frameUrl.Equals(expectUrl))
+ {
+ return true;
+ }
+ else
+ {
+ return true;
+ }
+ });
+ }
+
+ public static void ExecJavascriptStartsWithUrl(ChromiumWebBrowser cefWebBrowser, string url, string js)
+ {
+ ExecJavascript(cefWebBrowser, url, js, (frameUrl, expectUrl) =>
+ {
+ if (frameUrl.StartsWith(expectUrl))
+ {
+ return true;
+ }
+ else
+ {
+ return true;
+ }
+ });
+ }
+
+ public static void ExecJavascriptContainsUrl(ChromiumWebBrowser cefWebBrowser, string url, string js)
+ {
+ ExecJavascript(cefWebBrowser, url, js, (frameUrl, expectUrl) =>
+ {
+ if (frameUrl.Contains(expectUrl))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ });
+ }
+
+ public static JavascriptResponse EvaluateScript(ChromiumWebBrowser cefWebBrowser, string js)
+ {
+ JavascriptResponse javascriptResponse = null;
+ Task task = Task.Run(async () =>
+ {
+ javascriptResponse = await cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(js);
+ return javascriptResponse;
+ });
+ task.Wait();
+ return javascriptResponse;
+ }
+
+ public static async Task EvaluateScriptAsync(ChromiumWebBrowser cefWebBrowser, string js)
+ {
+ JavascriptResponse javascriptResponse = await cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(js);
+ return javascriptResponse;
+ }
+
+ public static async Task EvaluateScriptAsync(ChromiumWebBrowser cefWebBrowser, string url, string js, Func checkUrl)
+ {
+ // cef138
+ JavascriptResponse javascriptResponse = new JavascriptResponse();
+ //List frameIdentifierList = cefWebBrowser.GetBrowser().GetFrameIdentifiers();
+ //foreach (long identifier in frameIdentifierList)
+ List frameIdentifierList = cefWebBrowser.GetBrowser().GetFrameIdentifiers();
+ foreach (string identifier in frameIdentifierList)
+ {
+ //IFrame frame = cefWebBrowser.GetBrowser().GetFrame(identifier);
+ IFrame frame = cefWebBrowser.GetBrowser().GetFrameByIdentifier(identifier);
+ if (checkUrl(frame.Url, url))
+ {
+ javascriptResponse = await frame.EvaluateScriptAsync(js);
+ }
+ }
+ return javascriptResponse;
+ }
+
+ public static string GetElementLocation(ChromiumWebBrowser cefWebBrowser, string elementIdOrClass)
+ {
+ string js = @"function getElementLocation() {
+ var element = document.getElementById('{0}');
+ if (element == null || element == undefined) {
+ var elements = document.getElementsByClassName('{0}');
+ if(elements){
+ element = elements[0];
+ }
+ }
+ if (element == null || element == undefined)
+ {
+ return '0,0,0,0';
+ }
+ return element.getBoundingClientRect().left.toString() + ',' + element.getBoundingClientRect().top.toString() + ',' + (element.width?element.width.toString():element.getBoundingClientRect().width) + ',' + (element.height?element.height.toString():element.getBoundingClientRect().height);
+ }
+ getElementLocation();
+ ";
+ string formatJs = js.Replace("{0}", elementIdOrClass);
+ Task task = cefWebBrowser.EvaluateScriptAsync(formatJs);
+ task.Wait(2000);
+ string location = task.Result.Result.ParseToString();
+ return location;
+ }
+
+ public static LocationPoint GetElementLocationPoint(ChromiumWebBrowser cefWebBrowser, string elementIdOrClass)
+ {
+ LocationPoint locationPoint = new LocationPoint();
+ string location = GetElementLocation(cefWebBrowser, elementIdOrClass);
+ if (location.Contains(","))
+ {
+ string[] xy = location.Split(',');
+ locationPoint.Left = xy[0].DecimalPointParseToInt();
+ locationPoint.Top = xy[1].DecimalPointParseToInt();
+ locationPoint.Width = xy[2].DecimalPointParseToInt();
+ locationPoint.Height = xy[3].DecimalPointParseToInt();
+ }
+ return locationPoint;
+ }
+
+ public static void SimulateMouseLeftClick(IBrowserHost host, int x, int y)
+ {
+ Random random = new Random(Guid.NewGuid().GetHashCode());
+ host.SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.None); // 按下鼠标左键
+ Thread.Sleep(75 + random.Next(50));
+ host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None); // 松开鼠标左键
+ Thread.Sleep(300);
+ }
+
+ ///
+ /// 模拟鼠标滑动
+ ///
+ ///
+ /// 左边缘Left
+ /// 左边缘Top
+ /// 右边缘Left
+ /// 右边缘Top
+ /// 滑块的宽度
+ /// 滑块的高度
+ public static void SimulateMouseMove(IBrowserHost host, int fromX, int fromY, int toX, int toY, int slideWidth = 0, int slideHeight = 0)
+ {
+ Thread.Sleep(RandomHelper.GetRandom(0, 50));
+ int randomX = 0;
+ int randomY = 0;
+ if (slideWidth == 0)
+ {
+ randomX = -2 + RandomHelper.GetRandom(0, 5);
+ }
+ else
+ {
+ randomX = RandomHelper.GetRandom(0, slideWidth);
+ }
+ if (slideHeight == 0)
+ {
+ randomY = -2 + RandomHelper.GetRandom(0, 5);
+ }
+ else
+ {
+ randomY = RandomHelper.GetRandom(0, slideHeight);
+ }
+ int x = fromX + randomX;
+ int y = fromY + randomY;
+
+ host.SendMouseClickEvent(x, y, MouseButtonType.Left, false, 1, CefEventFlags.None); // 按下鼠标左键
+ Thread.Sleep(200 + RandomHelper.GetRandom(0, 200));
+
+ int times = 0;
+ while (x < toX - 4) // 后半部分
+ {
+ times++;
+ x += 4 + RandomHelper.GetRandom(0, 4);
+ y = y - 1 + RandomHelper.GetRandom(0, 3);
+ Thread.Sleep(6 + times / 6 + RandomHelper.GetRandom(0, 4));
+ host.SendMouseMoveEvent(x, y, false, CefEventFlags.LeftMouseButton); // 移动鼠标
+ }
+
+ x = toX - 1 + RandomHelper.GetRandom(0, 3);
+ Thread.Sleep(100 + RandomHelper.GetRandom(0, 100));
+ host.SendMouseMoveEvent(x, y, false, CefEventFlags.LeftMouseButton); // 移动鼠标
+
+ Thread.Sleep(400 + RandomHelper.GetRandom(0, 600));
+ host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, 1, CefEventFlags.None); // 抬起鼠标左键
+ }
+
+ public static void SimulateInputChar(IBrowserHost host, int key)
+ {
+ Random random = new Random();
+ host.SendKeyEvent(new KeyEvent() { WindowsKeyCode = key, Type = KeyEventType.KeyDown });
+ Thread.Sleep(10 + random.Next(10));
+
+ host.SendKeyEvent(new KeyEvent() { WindowsKeyCode = key, Type = KeyEventType.Char });
+ Thread.Sleep(50 + random.Next(40));
+
+ host.SendKeyEvent(new KeyEvent() { WindowsKeyCode = key, Type = KeyEventType.KeyUp });
+ Thread.Sleep(50 + random.Next(40));
+ }
+ }
+}
diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderListCtrl.xaml b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderListCtrl.xaml
deleted file mode 100644
index cf19bb3..0000000
--- a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderListCtrl.xaml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderListCtrl.xaml.cs b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderListCtrl.xaml.cs
deleted file mode 100644
index 43ad91e..0000000
--- a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderListCtrl.xaml.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace _29WxOrderWpf.Ctrls.BuyerCtrls
-{
- ///
- /// PDDBuyerOrderListCtrl.xaml 的交互逻辑
- ///
- public partial class PDDBuyerOrderListCtrl : UserControl
- {
- public PDDBuyerOrderListCtrl()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml
new file mode 100644
index 0000000..bf459a8
--- /dev/null
+++ b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs
new file mode 100644
index 0000000..1039034
--- /dev/null
+++ b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs
@@ -0,0 +1,133 @@
+using _29WxOrderWpf.CefHelper;
+using AllBase;
+using AllBase.Model;
+using AllBase.Model.Result;
+using CefSharp;
+using CefSharp.Handler;
+using CefSharp.Wpf;
+using NaiBa.Util;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Work._29Tools.CefTools;
+
+namespace _29WxOrderWpf.Ctrls.BuyerCtrls
+{
+ ///
+ /// PDDBuyerOrderReadCtrl.xaml 的交互逻辑
+ ///
+ public partial class PDDBuyerOrderReadCtrl : UserControl
+ {
+ ChromiumWebBrowser cefWebBrowser = null;
+ public bool AutoReadBuyerOrder = true;
+ ConcurrentList lstPddBuyerOrderInfoLite { get; set; } = new ConcurrentList();
+
+ public PDDBuyerOrderReadCtrl()
+ {
+ InitializeComponent();
+ }
+
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ InitCef();
+ }
+
+ public void InitCef()
+ {
+ //CefSharp.Wpf.ChromiumWebBrowser cefWebBrowser = new CefSharp.Wpf.ChromiumWebBrowser();
+ //cefWebBrowser.Address = "https://www.baidu.com";
+ cefWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser("https://www.baidu.com", false);
+ Grid.SetRow(cefWebBrowser, 0);
+ this.GridCef.Children.Add(cefWebBrowser);
+
+ LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
+ resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
+ resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
+ cefWebBrowser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
+ var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
+ cefWebBrowser.LifeSpanHandler = lifeSapnHandler;
+ cefWebBrowser.KeyboardHandler = new KeyboardHandler();
+ cefWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
+ cefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
+ cefWebBrowser.LoadError += CefWebBrowser_LoadError;
+
+
+
+ //Task.Run(() =>
+ //{
+ //Thread.Sleep(2000);
+ //Dispatcher.Invoke(new Action(() => {
+ // browser.Visibility = Visibility.Hidden;
+ //}));
+ //Thread.Sleep(1000);
+ //Dispatcher.Invoke(new Action(() => {
+
+ // browser.Address = "https://www.sina.com.cn";
+
+
+ // //}));
+ // //Thread.Sleep(3000);
+ // //var jsStr = @"window.scrollTo(0, document.body.scrollHeight);";
+ // //var client = browser.GetDevToolsClient();
+ // //if (client != null)
+ // //{
+ // // var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
+ // // //result.Wait(5000);
+ // // //string resultStr = result.Result.Result.Value.ParseToString();
+ // // ////if (resultStr.ParseToInt() > 0)
+ // // //{
+ // // // CEFBrowser.DeleteCookie(browser.GetCookieManager(null));
+ // // // //return;
+ // // //}
+ // //}
+ // //Dispatcher.Invoke(new Action(() => {
+ // //}));
+ // //Thread.Sleep(3000);
+ // //Dispatcher.Invoke(new Action(() => {
+ // // browser.Visibility = Visibility.Visible;
+ // //}));
+ //});
+ }
+
+ private void CefWebBrowser_LoadError(object sender, LoadErrorEventArgs e)
+ {
+ }
+ private void CefWebBrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
+ {
+ }
+ private void CefWebBrowser_AddressChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ }
+
+
+ private bool RequestHandler_BeforeResourceLoad(object sender, string url, string postData, IRequest request)
+ {
+ return false;
+ }
+ private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
+ {
+ }
+
+ private void chkAutoReadBuyerOrder_CheckedChanged(object sender, RoutedEventArgs e)
+ {
+ AutoReadBuyerOrder = chkAutoReadBuyerOrder.IsChecked == true;
+ }
+
+ private void btnSendBuyerOrder_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml
index 0bf85ac..77fe485 100644
--- a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml
+++ b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml
@@ -12,6 +12,7 @@
+
diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml.cs b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml.cs
index f89df0c..9e92cf0 100644
--- a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml.cs
+++ b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerSelectCtrl.xaml.cs
@@ -1,6 +1,7 @@
using _29WxOrderWpf.BaseWindows;
using AllBase;
using AllBase.Helper;
+using AllBase.Model.Local;
using AllBase.Model.Result;
using System;
using System.Collections.Generic;
@@ -154,5 +155,15 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
// GetPddBuyer();
//});
}
+
+ private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (MainWindow.Instance.pddBuyerOrderReadCtrl.Visibility != Visibility.Visible)
+ MainWindow.Instance.pddBuyerOrderReadCtrl.Visibility = Visibility.Visible;
+ if (Panel.GetZIndex(MainWindow.Instance.pddBuyerOrderReadCtrl) < 1)
+ Panel.SetZIndex(MainWindow.Instance.pddBuyerOrderReadCtrl, 1);
+ else
+ Panel.SetZIndex(MainWindow.Instance.pddBuyerOrderReadCtrl, -1);
+ }
}
}
diff --git a/29WxOrderWpf/Ctrls/OrderCtrls/OrderListCtrl.xaml b/29WxOrderWpf/Ctrls/OrderCtrls/OrderListCtrl.xaml
index 2cb2db1..b1bba65 100644
--- a/29WxOrderWpf/Ctrls/OrderCtrls/OrderListCtrl.xaml
+++ b/29WxOrderWpf/Ctrls/OrderCtrls/OrderListCtrl.xaml
@@ -63,21 +63,25 @@
-
-
+
@@ -140,7 +144,8 @@
-
+