13 changed files with 978 additions and 12 deletions
@ -0,0 +1,63 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// 此代码由工具生成。
|
|||
// 运行时版本:4.0.30319.42000
|
|||
//
|
|||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
|||
// 重新生成代码,这些更改将会丢失。
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace 齐越慧眼.Properties { |
|||
using System; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
|||
/// </summary>
|
|||
// 此类是由 StronglyTypedResourceBuilder
|
|||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
|||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
|||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] |
|||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
internal class Resources { |
|||
|
|||
private static global::System.Resources.ResourceManager resourceMan; |
|||
|
|||
private static global::System.Globalization.CultureInfo resourceCulture; |
|||
|
|||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
|||
internal Resources() { |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Resources.ResourceManager ResourceManager { |
|||
get { |
|||
if (object.ReferenceEquals(resourceMan, null)) { |
|||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("齐越慧眼.Properties.Resources", typeof(Resources).Assembly); |
|||
resourceMan = temp; |
|||
} |
|||
return resourceMan; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 重写当前线程的 CurrentUICulture 属性,对
|
|||
/// 使用此强类型资源类的所有资源查找执行重写。
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Globalization.CultureInfo Culture { |
|||
get { |
|||
return resourceCulture; |
|||
} |
|||
set { |
|||
resourceCulture = value; |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,120 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
<xsd:attribute ref="xml:space" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
<xsd:attribute ref="xml:space" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
</root> |
@ -0,0 +1,15 @@ |
|||
<UserControl x:Class="齐越慧眼.UserControls.SomeBrowerControl" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:local="clr-namespace:齐越慧眼.UserControls" |
|||
mc:Ignorable="d" |
|||
d:DesignHeight="450" d:DesignWidth="800"> |
|||
<DockPanel> |
|||
<TextBox x:Name="txtUrl" DockPanel.Dock="Top" Keyboard.KeyUp="txtUrl_KeyUp"></TextBox> |
|||
<Grid x:Name="grid" DockPanel.Dock="Bottom" Margin="0 10 0 0"> |
|||
|
|||
</Grid> |
|||
</DockPanel> |
|||
</UserControl> |
@ -0,0 +1,632 @@ |
|||
using CefSharp; |
|||
using CefSharp.Wpf; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text.RegularExpressions; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Input; |
|||
using 齐越慧眼.cefhelper; |
|||
using 齐越慧眼.Models; |
|||
|
|||
namespace 齐越慧眼.UserControls |
|||
{ |
|||
/// <summary>
|
|||
/// BrowerControl.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class SomeBrowerControl : UserControl |
|||
{ |
|||
public HandyControl.Controls.TabItem Tab { get; set; } |
|||
public string Base64Img { get; set; } |
|||
public ExtChromiumBrowser web; |
|||
public SomeBrowerControl(string base64, HandyControl.Controls.TabItem tabItem) |
|||
{ |
|||
InitializeComponent(); |
|||
Tab = tabItem; |
|||
Base64Img = base64; |
|||
web = new ExtChromiumBrowser("https://www.1688.com/") |
|||
{ |
|||
BrowserSettings = |
|||
{ |
|||
DefaultEncoding = "UTF-8", |
|||
Plugins = CefState.Enabled, |
|||
//关于跨域限制
|
|||
//WebSecurity = CefState.Disabled,
|
|||
ApplicationCache = CefState.Enabled, |
|||
LocalStorage = CefState.Enabled |
|||
|
|||
}, |
|||
|
|||
//RequestHandler =new MyRequestHandler()
|
|||
}; |
|||
|
|||
MyResourceRequestHandlerFactory myResourceRequestHandlerFactory = new MyResourceRequestHandlerFactory(this); |
|||
myResourceRequestHandlerFactory.Handlers.TryAdd("test",null); |
|||
|
|||
web.ResourceRequestHandlerFactory = myResourceRequestHandlerFactory; |
|||
|
|||
|
|||
grid.Children.Add(web); |
|||
Loaded += BrowerControl_Loaded; |
|||
web.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; |
|||
var cjs = new Cef2AsyncJS(); |
|||
cjs.Brower = this; |
|||
web.JavascriptObjectRepository.Register("hyCoreModel", cjs, BindingOptions.DefaultBinder); |
|||
web.StartNewWindow += Web_StartNewWindow; |
|||
web.TitleChanged += Web_TitleChanged; |
|||
web.AddressChanged += Web_AddressChanged; |
|||
web.ExecuteScriptAsyncWhenPageLoaded("hyCoreModel.onLoad()"); |
|||
this.KeyDown += BrowerControl_KeyDown; |
|||
} |
|||
|
|||
private void BrowerControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) |
|||
{ |
|||
if (e.Key == Key.F12) |
|||
{ |
|||
web.ShowDevTools(); |
|||
} |
|||
} |
|||
|
|||
private void Web_AddressChanged(object sender, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
Application.Current.Dispatcher.Invoke(()=> { |
|||
txtUrl.Text = e.NewValue.ToString(); |
|||
}); |
|||
} |
|||
|
|||
public void Exit() |
|||
{ |
|||
web.Dispose(); |
|||
} |
|||
|
|||
private void Web_TitleChanged(object sender, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
Application.Current.Dispatcher.Invoke(() => |
|||
{ |
|||
Tab.Header = e.NewValue; |
|||
}); |
|||
} |
|||
|
|||
int nowPatlom = 0; |
|||
|
|||
public void OnUrlEnd(string url) |
|||
{ |
|||
if (url.Contains("/marketOfferResultViewService")) |
|||
{ |
|||
Task.Factory.StartNew(() => |
|||
{ |
|||
var items= Get1688ShopIds(); |
|||
|
|||
while (items == Get1688ShopIds()) |
|||
{ |
|||
Thread.Sleep(100); |
|||
} |
|||
nowPatlom = 2; |
|||
lastUrl = "s.1688.com"; |
|||
StartPage(); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void Web_StartNewWindow(object sender, NewWindowEventArgs e) |
|||
{ |
|||
MainWindow.Main.brower.NewTab(e.Url); |
|||
//web.Load(e.Url);
|
|||
} |
|||
|
|||
private void BrowerControl_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
Thread t = new Thread(() => { |
|||
|
|||
IWebBrowser webBrowser = null; |
|||
|
|||
Application.Current.Dispatcher.Invoke(() => { |
|||
webBrowser = web.WebBrowser; |
|||
}); |
|||
|
|||
while (webBrowser == null) |
|||
{ |
|||
Thread.Sleep(100); |
|||
Application.Current.Dispatcher.Invoke(() => { |
|||
webBrowser = web.WebBrowser; |
|||
}); |
|||
} |
|||
|
|||
Application.Current.Dispatcher.Invoke(() => { |
|||
web.WebBrowser.LoadingStateChanged += WebBrowser_LoadingStateChanged; |
|||
}); |
|||
}); |
|||
|
|||
t.Start(); |
|||
} |
|||
|
|||
private string lastUrl = string.Empty; |
|||
|
|||
private void WebBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) |
|||
{ |
|||
if (lastUrl != e.Browser.MainFrame.Url) |
|||
{ |
|||
lastUrl = e.Browser.MainFrame.Url; |
|||
//开始单页查询
|
|||
if (lastUrl.StartsWith("https://s.taobao.com/search")|| lastUrl.StartsWith("https://search.jd.com/")||lastUrl.StartsWith("https://s.1688.com/selloffer/offer_search.htm")) |
|||
{ |
|||
StartPage(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
object doWorkObj = new object(); |
|||
|
|||
private void StartPage() |
|||
{ |
|||
Thread t = new Thread(() => |
|||
{ |
|||
lock (doWorkObj) |
|||
{ |
|||
if (string.IsNullOrEmpty(lastUrl)) |
|||
return; |
|||
|
|||
AddJquery(); |
|||
|
|||
DoWork(); |
|||
} |
|||
}); |
|||
|
|||
t.Start(); |
|||
} |
|||
|
|||
object lockWork = new object(); |
|||
|
|||
private void DoWork() |
|||
{ |
|||
lock (lockWork) |
|||
{ |
|||
while (true) |
|||
{ |
|||
if (string.IsNullOrEmpty(lastUrl)) |
|||
break; |
|||
|
|||
Task<JavascriptResponse> task = null; |
|||
|
|||
Application.Current.Dispatcher.Invoke(() => |
|||
{ |
|||
task = web.EvaluateScriptAsPromiseAsync("return $(document.body).html();"); |
|||
}); |
|||
|
|||
var result = task.Result; |
|||
|
|||
//判断是否加载完成
|
|||
if (result.Success) |
|||
{ |
|||
AddCss(); |
|||
|
|||
Add1688OptionDiv(); |
|||
Check1688PageItem(); |
|||
|
|||
break; |
|||
} |
|||
|
|||
Thread.Sleep(100); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 添加jq操作类
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private bool AddJquery() |
|||
{ |
|||
return DoJavaScript("var script=document.createElement('script'); script.type='text/javascript'; script.src='https://code.jquery.com/jquery-1.12.4.min.js'; document.getElementsByTagName('head')[0].appendChild(script); ").isOk; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 添加ajax请求拦截
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private bool AddAjaxHook() |
|||
{ |
|||
return DoJavaScript(@"$(document).ajaxSuccess(function( event, xhr, settings ) {hyCoreModel.onAjaxHook(settings.url);});").isOk; |
|||
} |
|||
|
|||
|
|||
#region 阿里巴巴代码
|
|||
|
|||
private List<string> Get1688ShopIds() |
|||
{ |
|||
var res = DoJavaScript(@"var ids=[]; $('ul#sm-offer-list div.normalcommon-offer-card').each(function(){ids.push($(this).attr(""data-aplus-report""))});return ids;"); |
|||
|
|||
List<string> reports = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(Newtonsoft.Json.JsonConvert.SerializeObject(res.result)); |
|||
|
|||
List<string> itemIds = new List<string>(); |
|||
if (reports != null) |
|||
{ |
|||
reports.ForEach(c => |
|||
{ |
|||
string objid = Regex.Match(c, "object_id\\@(.*?)\\^").Groups[1].Value; |
|||
itemIds.Add(objid); |
|||
}); |
|||
} |
|||
|
|||
return itemIds; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 检测页面商品
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private void Check1688PageItem() |
|||
{ |
|||
var res = DoJavaScript(@"var ids=[]; $('ul#sm-offer-list div.normalcommon-offer-card').each(function(){ids.push($(this).attr(""data-aplus-report""))});return ids;"); |
|||
|
|||
List<string> reports = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(Newtonsoft.Json.JsonConvert.SerializeObject(res.result)); |
|||
|
|||
List<string> itemIds = new List<string>(); |
|||
List<string> shopIds = new List<string>(); |
|||
if (reports != null) |
|||
{ |
|||
reports.ForEach(c => |
|||
{ |
|||
string objid = Regex.Match(c, "object_id\\@(.*?)\\^").Groups[1].Value; |
|||
string shopId= Regex.Match(c, "object_member_id\\@(.*?)\\^").Groups[1].Value; |
|||
DoJavaScript(@$"$(""ul#sm-offer-list"").find('div[data-aplus-report=""{c}""]').attr(""data-sku"",""{objid}"")"); |
|||
DoJavaScript(@$"$(""ul#sm-offer-list"").find('div[data-aplus-report=""{c}""]').attr(""data-shopId"",""{shopId}"")"); |
|||
itemIds.Add(objid); |
|||
if(!shopIds.Contains(shopId)) |
|||
shopIds.Add(shopId); |
|||
}); |
|||
} |
|||
|
|||
var result = ApiHelper.GetLabelByItemIds(itemIds, Models.ItemPlatform.ALBB); |
|||
|
|||
if (result.isOk) |
|||
{ |
|||
foreach (var item in result.datas) |
|||
{ |
|||
//判断是否团队过滤
|
|||
if (item.IsFilter) |
|||
{ |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.myitemState').addClass(""falseBg"")"); |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.stateGraydiv').addClass(""divshow"")"); |
|||
} |
|||
else |
|||
{ |
|||
//判断是否集团过滤
|
|||
if (item.HasFilter) |
|||
{ |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.myitemState').prepend('<div class=""smallfalseBg""></div>')"); |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.stateGraydiv').addClass(""divshow"")"); |
|||
} |
|||
} |
|||
|
|||
|
|||
//if (item.IsCompeting)
|
|||
//{
|
|||
// if ((int)BrowerControl.Main.DoJavaScript(@$"return $($('div#J_goodsList li[data-sku=""{item.GoodsId}""]')).find('.stateYellow').length").result <= 0)
|
|||
// {
|
|||
// DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.myitemState').prepend('<div style=""width:20%;height:20%"" class=""stateYellow"">合</div>')");
|
|||
// }
|
|||
// DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.stateGraydiv').addClass(""divshow"")");
|
|||
//}
|
|||
|
|||
if (item.IsScreening) |
|||
{ |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.myitemState').addClass(""trueBg"")"); |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.stateGraydiv').addClass(""divshow"")"); |
|||
} |
|||
|
|||
if (item.IsAdded) |
|||
{ |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.myitemState').addClass(""popBg"")"); |
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-sku=""{item.GoodsId}""]')).find('.stateGraydiv').addClass(""divshow"")"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
var alResult = ApiHelper.GetAlbbLabelByShopIds(shopIds); |
|||
if (alResult.isOk) |
|||
{ |
|||
alResult.datas.ForEach(item => { |
|||
|
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-shopId=""{item.ShopId}""]')).find('.myitemState').prepend('<div style=""width:20%;height:20%"" class=""stateYellow"">合</div>')"); |
|||
|
|||
DoJavaScript($@"$($('ul#sm-offer-list div[data-shopId=""{item.ShopId}""]')).find('.stateGraydiv').addClass(""divshow"")"); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 添加操作面板
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private bool Add1688OptionDiv() |
|||
{ |
|||
//添加js事件
|
|||
|
|||
DoJavaScript(@"
|
|||
window.optClick= function (ele,type){ |
|||
var e=window.event || arguments.callee.caller.arguments[0]; |
|||
e.preventDefault(); |
|||
e.stopPropagation(); |
|||
|
|||
var infoDiv=$($(ele).parent().parent().parent().parent().parent().parent()); |
|||
var itemid= infoDiv.attr(""data-sku""); |
|||
|
|||
var price=infoDiv.find("".showPricec"").text(); |
|||
var sales=infoDiv.find("".sale"").text(); |
|||
var title=infoDiv.find("".mojar-element-title"").text(); |
|||
var img=$(ele).parent().parent().find(""div.img"").css(""background-image""); |
|||
var shopId=infoDiv.attr(""data-shopId""); |
|||
hyCoreModel.set1688ItemData({itemid:itemid,price:price,sales:sales,title:title,img:img,type:type,shopId:shopId}); |
|||
}; |
|||
");
|
|||
|
|||
return DoJavaScript(@"$('ul#sm-offer-list').find('.myitemState').remove();$('ul#sm-offer-list').find('.myopdiv').remove();
|
|||
$('ul#sm-offer-list div.normalcommon-offer-card .img-container div.img').append(' |
|||
<div class=""myitemState""> |
|||
<div class=""stateGraydiv""></div></div> |
|||
<div class=""myopdiv""> |
|||
<div class=""bgYellow"" style=""display:flex;"" onclick=""optClick(this,4)"">合作</div> |
|||
<div class=""bgZs"" style=""display:flex;"" onclick=""optClick(this,2)"" >海选</div> |
|||
<div class=""bgPig"" style=""display:flex;"" onclick=""optClick(this,1)"">淘汰</div> |
|||
<div class=""bgGreen"" style=""display:flex;"" onclick=""optClick(this,0)"">同款</div> |
|||
</div> |
|||
')").isOk;
|
|||
|
|||
} |
|||
#endregion
|
|||
|
|||
public void RunSomeAction() |
|||
{ |
|||
DoJavaScript(@$"
|
|||
window.lib.mtop.request({{ |
|||
api: ""mtop.1688.imageService.putImage"", |
|||
data: JSON.stringify({{ |
|||
imageBase64: ""{Base64Img}"", |
|||
appName: ""searchImageUpload"", |
|||
appKey: ""pvvljh1grxcmaay2vgpe9nb68gg9ueg2"" |
|||
}}), |
|||
ecode: ""0"", |
|||
v: ""1.0"", |
|||
type: ""POST"" |
|||
}}).then(res=>{{ |
|||
hyCoreModel.onSomePicRes(res) |
|||
}}) |
|||
");
|
|||
} |
|||
|
|||
private bool AddCss() |
|||
{ |
|||
///添加css
|
|||
return DoJavaScript(@"$('head').append('<style>
|
|||
.myitemState |
|||
{ |
|||
width:100%; |
|||
height:100%; |
|||
position: absolute; |
|||
left: 0px; |
|||
top: 0px; |
|||
z-index: 9999; |
|||
} |
|||
.trueBg |
|||
{ |
|||
background: url(""nacollector://home/img/true.png"") no-repeat;
|
|||
background-size: 100% 100%; |
|||
} |
|||
|
|||
.popBg |
|||
{ |
|||
background: url(""nacollector://home/img/pop.png"") no-repeat;
|
|||
background-size: 100% 100%; |
|||
} |
|||
.falseBg |
|||
{ |
|||
background: url(""nacollector://home/img/close.png"") no-repeat;
|
|||
background-size: 100% 100%; |
|||
} |
|||
|
|||
.smallfalseBg |
|||
{ |
|||
width:78px; |
|||
height:78px; |
|||
bottom: 0px; |
|||
left: 0px; |
|||
top: unset; |
|||
background: url(""nacollector://home/img/close.png"") no-repeat;
|
|||
background-size: 100% 100%; |
|||
position: absolute; |
|||
} |
|||
|
|||
.stateGraydiv |
|||
{ |
|||
width:100%; |
|||
height:100%; |
|||
display:none; |
|||
background-color: rgba(85, 85, 85, 0.45); |
|||
} |
|||
.divshow |
|||
{ |
|||
display:block; |
|||
} |
|||
.myopdiv |
|||
{ |
|||
width:85%; |
|||
height:100%; |
|||
display:none; |
|||
position: absolute; |
|||
top: 0px; |
|||
right:0px; |
|||
} |
|||
|
|||
.myopdiv div { |
|||
width: 23%; |
|||
height: 20%; |
|||
display: inline-block; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.pic-box:hover .myopdiv |
|||
{ |
|||
display:unset; |
|||
} |
|||
.pic-box:hover .myitemState |
|||
{ |
|||
display:none; |
|||
} |
|||
|
|||
.p-img:hover .myitemState |
|||
{ |
|||
display:none; |
|||
} |
|||
.p-img:hover .myopdiv |
|||
{ |
|||
display:unset; |
|||
z-index:9999; |
|||
} |
|||
|
|||
.img-container:hover .myitemState |
|||
{ |
|||
display:none; |
|||
} |
|||
.img-container:hover .myopdiv |
|||
{ |
|||
display:unset; |
|||
z-index:9999; |
|||
} |
|||
|
|||
.bgGreen |
|||
{ |
|||
background: rgba(99, 161, 3, 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; |
|||
margin-right:5px; |
|||
} |
|||
.bgPig |
|||
{ |
|||
background: rgba(236, 128, 141, 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; |
|||
margin-right:5px; |
|||
} |
|||
.bgZs |
|||
{ |
|||
background: rgba(194, 128, 255, 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; |
|||
margin-right:5px; |
|||
} |
|||
.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; |
|||
} |
|||
.stateYellow |
|||
{ |
|||
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", "")).isOk;
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 执行js
|
|||
/// </summary>
|
|||
/// <param name="js"></param>
|
|||
/// <returns></returns>
|
|||
public (bool isOk, object result) DoJavaScript(string js) |
|||
{ |
|||
js = js.Replace("\n", "").Replace("\r\n", "").Replace(System.Environment.NewLine, "").Replace("\r", ""); |
|||
Task<JavascriptResponse> task = null; |
|||
|
|||
Application.Current.Dispatcher.Invoke(() => |
|||
{ |
|||
task = web.EvaluateScriptAsPromiseAsync(js); |
|||
}); |
|||
|
|||
var result = task.Result; |
|||
|
|||
//判断是否加载完成
|
|||
return (result.Success,result.Result); |
|||
} |
|||
|
|||
private void txtUrl_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) |
|||
{ |
|||
if (e.Key == System.Windows.Input.Key.Enter) |
|||
{ |
|||
web.Load(txtUrl.Text); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class Cef2AsyncJS |
|||
{ |
|||
public SomeBrowerControl Brower { get; set; } |
|||
|
|||
|
|||
public void onAjaxHook(string url) |
|||
{ |
|||
Brower.OnUrlEnd(url); |
|||
} |
|||
|
|||
public void onLoad() |
|||
{ |
|||
Brower.RunSomeAction(); |
|||
} |
|||
|
|||
public void onSomePicRes(dynamic data) |
|||
{ |
|||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(data); |
|||
//{"imageId":"0","requestId":"a837075218924fd6a6969eb1d0596c64","sessionId":"6c4a3e67343c41dcbfb3ac0b2fb82abd"}
|
|||
|
|||
string imgId = data.data.imageId; |
|||
string requestId = data.data.requestId; |
|||
string sessionId= data.data.sessionId; |
|||
Application.Current.Dispatcher.Invoke(() => |
|||
{ |
|||
Brower.web.Load($"https://s.1688.com/youyuan/index.htm?tab=imageSearch&imageAddress=&imageId={imgId}&spm=a260k.dacugeneral.search.0&imageIdList={imgId}"); |
|||
}); |
|||
//https://s.1688.com/youyuan/index.htm?tab=imageSearch&imageAddress=&imageId=1809207254297088602&spm=a260k.dacugeneral.search.0&imageIdList=1809207254297088602
|
|||
|
|||
} |
|||
} |
|||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue