|
|
@ -1,19 +1,9 @@ |
|
|
|
using CefSharp; |
|
|
|
using CefSharp.Wpf; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text; |
|
|
|
using System.Threading; |
|
|
|
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 齐越慧眼.UserControls |
|
|
|
{ |
|
|
@ -25,8 +15,8 @@ namespace 齐越慧眼.UserControls |
|
|
|
ChromiumWebBrowser web; |
|
|
|
public BrowerControl() |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
web = new ChromiumWebBrowser("https://www.taobao.com") |
|
|
|
{ |
|
|
|
BrowserSettings = |
|
|
@ -43,6 +33,11 @@ namespace 齐越慧眼.UserControls |
|
|
|
|
|
|
|
grid.Children.Add(web); |
|
|
|
Loaded += BrowerControl_Loaded; |
|
|
|
|
|
|
|
web.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; |
|
|
|
|
|
|
|
web.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; |
|
|
|
web.JavascriptObjectRepository.Register("hyCoreModel", new CefAsyncJS(), BindingOptions.DefaultBinder); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -120,12 +115,32 @@ namespace 齐越慧眼.UserControls |
|
|
|
/// <returns></returns>
|
|
|
|
private bool AddOptionDiv() |
|
|
|
{ |
|
|
|
///添加js事件
|
|
|
|
DoJavaScript(@"
|
|
|
|
window.optClick= function (ele,type){ |
|
|
|
var itemid= $(ele).parent().parent().find(""a"").attr(""data-nid""); |
|
|
|
var infoDiv=$($(ele).parent().parent().parent().parent().find("".J_IconMoreNew"")); |
|
|
|
var price=infoDiv.find("".g_price"").text(); |
|
|
|
var sales=infoDiv.find("".deal-cnt"").text(); |
|
|
|
var title=infoDiv.find("".title"").text(); |
|
|
|
var img=$(ele).parent().parent().find(""img"").attr(""src""); |
|
|
|
hyCoreModel.setItemData(price+""\r\n""+sales+""\r\n""+title+""\r\n""+img+""\r\n""+itemid); |
|
|
|
}; |
|
|
|
|
|
|
|
DoJavaScript("$('div#mainsrp-itemlist .items .item .pic').before('<div class=\"myitemState falseBg\"><div class=\"stateGraydiv\"></div></div><div class=\"myopdiv\">我擦</div>')"); |
|
|
|
|
|
|
|
");
|
|
|
|
|
|
|
|
///添加css
|
|
|
|
return DoJavaScript(@"$('head').append('<style>
|
|
|
|
DoJavaScript(@"$('div#mainsrp-itemlist .items .item .pic').before('<div class=""myitemState""><div class=""stateGraydiv""></div></div><div class=""myopdiv"">
|
|
|
|
<div class=""bgGreen"" onclick=""optClick(this,1)""></div> |
|
|
|
<div class=""bgPig"" onclick=""optClick(this,2)""></div> |
|
|
|
<div class=""bgZs"" onclick=""optClick(this,3)""></div> |
|
|
|
<div class=""bgYellow"" style=""display:flex"" onclick=""optClick(this,4)"">竞</div> |
|
|
|
|
|
|
|
</div>')");
|
|
|
|
|
|
|
|
|
|
|
|
///添加css
|
|
|
|
return DoJavaScript(@"$('head').append('<style>
|
|
|
|
.myitemState |
|
|
|
{ |
|
|
|
width:100%; |
|
|
@ -166,8 +181,20 @@ namespace 齐越慧眼.UserControls |
|
|
|
|
|
|
|
.myopdiv |
|
|
|
{ |
|
|
|
width:85%; |
|
|
|
height:100%; |
|
|
|
display:none; |
|
|
|
position: absolute; |
|
|
|
top: 0px; |
|
|
|
right:0px; |
|
|
|
} |
|
|
|
|
|
|
|
.myopdiv div { |
|
|
|
width: 23%; |
|
|
|
height: 20%; |
|
|
|
display: inline-block; |
|
|
|
} |
|
|
|
|
|
|
|
.pic-box:hover .myopdiv |
|
|
|
{ |
|
|
|
display:unset; |
|
|
@ -176,10 +203,36 @@ namespace 齐越慧眼.UserControls |
|
|
|
{ |
|
|
|
display:none; |
|
|
|
} |
|
|
|
</style>')".Replace("\n","").Replace("\r\n",""));
|
|
|
|
|
|
|
|
.bgGreen |
|
|
|
{ |
|
|
|
background: rgba(99, 161, 3, 0.8); |
|
|
|
} |
|
|
|
.bgPig |
|
|
|
{ |
|
|
|
background: rgba(236, 128, 141, 0.8); |
|
|
|
} |
|
|
|
.bgZs |
|
|
|
{ |
|
|
|
background: rgba(194, 128, 255, 0.8); |
|
|
|
} |
|
|
|
.bgYellow |
|
|
|
{ |
|
|
|
background: rgba(245, 154, 35, 0.8); |
|
|
|
font-size:20px; |
|
|
|
color:red; |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: center; |
|
|
|
flex-direction: column; |
|
|
|
float: right; |
|
|
|
font-family: ""global-iconfont""; |
|
|
|
font-weight: 999; |
|
|
|
} |
|
|
|
</style>')".Replace("\n", "").Replace("\r\n", ""));
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 执行js
|
|
|
@ -188,7 +241,7 @@ namespace 齐越慧眼.UserControls |
|
|
|
/// <returns></returns>
|
|
|
|
private bool DoJavaScript(string js) |
|
|
|
{ |
|
|
|
js = js.Replace("\n", "").Replace("\r\n", "").Replace(System.Environment.NewLine,"").Replace("\r",""); |
|
|
|
js = js.Replace("\n", "").Replace("\r\n", "").Replace(System.Environment.NewLine, "").Replace("\r", ""); |
|
|
|
Task<JavascriptResponse> task = null; |
|
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
@ -202,4 +255,18 @@ namespace 齐越慧眼.UserControls |
|
|
|
return result.Success; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class CefAsyncJS |
|
|
|
{ |
|
|
|
|
|
|
|
public string getTest() |
|
|
|
{ |
|
|
|
return "我草"; |
|
|
|
} |
|
|
|
public void setItemData(string data) |
|
|
|
{ |
|
|
|
MessageBox.Show(data); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|