|
|
@ -3,6 +3,7 @@ using Microsoft.Web.WebView2.Core; |
|
|
|
using Microsoft.Web.WebView2.Wpf; |
|
|
|
using System; |
|
|
|
using System.Reflection; |
|
|
|
using System.Threading; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Media; |
|
|
@ -43,7 +44,7 @@ namespace BBWY.Client.Views.Order |
|
|
|
} |
|
|
|
grid.Children.Add(w2m.wb2); |
|
|
|
|
|
|
|
if(w2m.IsInitializationCompleted) |
|
|
|
if (w2m.IsInitializationCompleted) |
|
|
|
txtMsg.Text = "Grabbing Mobile"; |
|
|
|
|
|
|
|
w2m.CoreWebView2InitializationCompleted = (e) => |
|
|
@ -54,17 +55,20 @@ namespace BBWY.Client.Views.Order |
|
|
|
w2m.OnNavigationCompleted = async (e) => |
|
|
|
{ |
|
|
|
if (w2m.wb2.CoreWebView2.Source.StartsWith("https://passport.shop.jd.com/login")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//首次打开需要登录
|
|
|
|
await w2m.wb2.CoreWebView2.ExecuteScriptAsync("window.scrollTo(790,150)"); |
|
|
|
await w2m.wb2.CoreWebView2.ExecuteScriptAsync("document.querySelector(\"div[data-tab-id='form']\").click()"); |
|
|
|
Console.WriteLine($"{orderId}触发登录"); |
|
|
|
await w2m.wb2.CoreWebView2.ExecuteScriptAsync(@$"var img = document.getElementById('js-login-qrcode');
|
|
|
|
if(img.src==null || img.src.length==0){{window.location.href='https://neworder.shop.jd.com/order/orderDetail?orderId={orderId}';}}
|
|
|
|
else{{window.scrollTo(790,150);document.querySelector(""div[data-tab-id='form']"").click();}}");
|
|
|
|
} |
|
|
|
else if (w2m.wb2.CoreWebView2.Source.StartsWith("https://neworder.shop.jd.com/order/orderDetail")) |
|
|
|
{ |
|
|
|
Console.WriteLine($"{orderId}触发手机号查看"); |
|
|
|
//进入订单详情页面,触发点击查看手机号
|
|
|
|
txtMsg.Text = "Grabbing Mobile"; |
|
|
|
w2m.wb2.Width = 0.1; |
|
|
|
w2m.wb2.Height = 0.1; |
|
|
|
//w2m.wb2.Width = 0.1;
|
|
|
|
//w2m.wb2.Height = 0.1;
|
|
|
|
var js = @"var mobileNode = document.getElementById('mobile');
|
|
|
|
mobileNode.addEventListener('DOMNodeInserted',function(e){ var m=mobileNode.innerText; window.chrome.webview.postMessage(m);}); |
|
|
|
document.getElementById('viewOrderMobile').click();";
|
|
|
@ -74,6 +78,7 @@ namespace BBWY.Client.Views.Order |
|
|
|
w2m.OnWebMessageReceived = (e) => |
|
|
|
{ |
|
|
|
var mobole = e.TryGetWebMessageAsString(); |
|
|
|
Console.WriteLine($"{orderId}接收手机号{mobole}"); |
|
|
|
this.Tag = mobole; |
|
|
|
this.DialogResult = true; |
|
|
|
this.Close(); |
|
|
|