Browse Source

Merge branch '1688purchase' of http://code.qiyue666.com/pengcong001/bbwy into 1688purchase

qianyi
shanji 3 years ago
parent
commit
9b25c019e8
  1. 5
      BBWY.Client/ViewModels/Order/OrderListViewModel.cs
  2. 2
      BBWY.Client/Views/Order/GrabJDMibole.xaml
  3. 17
      BBWY.Client/Views/Order/GrabJDMibole.xaml.cs

5
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 =>
{

2
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">
<Grid x:Name="grid">
<TextBlock x:Name="txtMsg" Text="Initialize Webview2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"/>
</Grid>

17
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();

Loading…
Cancel
Save