You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Windows.Controls;
|
|
|
|
namespace BBWY.Client.Views.Web
|
|
{
|
|
/// <summary>
|
|
/// Web.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class Web : Page
|
|
{
|
|
private WebView2Manager w2m;
|
|
private GlobalContext globalContext;
|
|
private bool isNavigated = false;
|
|
|
|
#if DEBUG
|
|
private string url = "http://192.168.1.4:8881/";
|
|
#else
|
|
private string url= "http://bbwyweb.qiyue666.com";
|
|
#endif
|
|
|
|
public Web()
|
|
{
|
|
InitializeComponent();
|
|
this.Loaded += Web_Loaded;
|
|
}
|
|
|
|
private void Web_Loaded(object sender, System.Windows.RoutedEventArgs e)
|
|
{
|
|
var sp = (App.Current as App).ServiceProvider;
|
|
using (var s = sp.CreateScope())
|
|
{
|
|
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
|
|
}
|
|
using (var s = sp.CreateScope())
|
|
{
|
|
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>();
|
|
}
|
|
w2m.Init(globalContext.User.Shop.ShopId.ToString());
|
|
grid.Children.Add(w2m.wb2);
|
|
|
|
w2m.CoreWebView2InitializationCompleted = (e) =>
|
|
{
|
|
isNavigated = true;
|
|
// w2m.wb2.CoreWebView2.Navigate($"https://neworder.shop.jd.com/order/orderDetail?orderId={orderId}");
|
|
w2m.wb2.CoreWebView2.Navigate(url);
|
|
};
|
|
if(w2m.IsInitializationCompleted && !isNavigated)
|
|
{
|
|
w2m.wb2.CoreWebView2.Navigate(url);
|
|
isNavigated = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|