diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index 09e6c6fc..86b6e134 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -251,6 +251,11 @@ namespace BBWY.Client.ViewModels var grab = new GrabJDMibole(order.Id); if (grab.ShowDialog() == true) plaintextMobile = grab.Tag.ToString(); + if (string.IsNullOrEmpty(plaintextMobile)) + { + MessageBox.Show("未获取到手机号", "提示"); + return; + } IsLoading = true; Task.Factory.StartNew(() => orderService.DecodeConsignee(order.Id, plaintextMobile)).ContinueWith(t => { diff --git a/BBWY.Client/Views/Order/GrabJDMibole.xaml b/BBWY.Client/Views/Order/GrabJDMibole.xaml index 9be90acf..95b4173a 100644 --- a/BBWY.Client/Views/Order/GrabJDMibole.xaml +++ b/BBWY.Client/Views/Order/GrabJDMibole.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:BBWY.Client.Views.Order" mc:Ignorable="d" WindowStartupLocation="CenterScreen" - Title="GrabJDMibole" Height="350" Width="400"> + Title="GrabJDMibole" Height="600" Width="800"> diff --git a/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs b/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs index 51c819d2..e8d80ad9 100644 --- a/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs +++ b/BBWY.Client/Views/Order/GrabJDMibole.xaml.cs @@ -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();