From 25ed48e5ebea0976fc4a79ab5ca6ebcf082cd1b6 Mon Sep 17 00:00:00 2001
From: shanj <18996038927@163.com>
Date: Wed, 30 Aug 2023 12:03:09 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B4=A7=E6=BA=90=E7=AE=A1?=
=?UTF-8?q?=E7=90=86web=E8=8F=9C=E5=8D=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BBWYB.Client/BBWYB.Client.csproj | 13 +++
BBWYB.Client/GlobalContext.cs | 2 +-
BBWYB.Client/ViewModels/MainViewModel.cs | 3 +-
BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml | 14 +++
.../Views/WebB/WebB_GoodsSource.xaml.cs | 104 ++++++++++++++++++
5 files changed, 134 insertions(+), 2 deletions(-)
create mode 100644 BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml
create mode 100644 BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs
diff --git a/BBWYB.Client/BBWYB.Client.csproj b/BBWYB.Client/BBWYB.Client.csproj
index 5fca9cb..91a07a9 100644
--- a/BBWYB.Client/BBWYB.Client.csproj
+++ b/BBWYB.Client/BBWYB.Client.csproj
@@ -53,4 +53,17 @@
+
+
+ Code
+
+
+
+
+
+ $(DefaultXamlRuntime)
+ Designer
+
+
+
diff --git a/BBWYB.Client/GlobalContext.cs b/BBWYB.Client/GlobalContext.cs
index e3b24d0..4f7f7a9 100644
--- a/BBWYB.Client/GlobalContext.cs
+++ b/BBWYB.Client/GlobalContext.cs
@@ -22,7 +22,7 @@ namespace BBWYB.Client
{
public GlobalContext()
{
- BBWYBApiVersion = "10035";
+ BBWYBApiVersion = "10036";
}
private User user;
diff --git a/BBWYB.Client/ViewModels/MainViewModel.cs b/BBWYB.Client/ViewModels/MainViewModel.cs
index 766958f..4903cbf 100644
--- a/BBWYB.Client/ViewModels/MainViewModel.cs
+++ b/BBWYB.Client/ViewModels/MainViewModel.cs
@@ -109,7 +109,8 @@ namespace BBWYB.Client.ViewModels
ChildList = new List()
{
new MenuModel(){ Name="订单列表Bata",Url="/Views/WebB/WebB.xaml" },
- new MenuModel(){ Name="绩效考核",Url="/Views/WebB/WebB_KPI.xaml" }
+ new MenuModel(){ Name="绩效考核",Url="/Views/WebB/WebB_KPI.xaml" },
+ new MenuModel(){ Name="货源管理",Url="/Views/WebB/WebB_GoodsSource.xaml" }
}
});
MenuList.Add(new MenuModel()
diff --git a/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml b/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml
new file mode 100644
index 0000000..8df7144
--- /dev/null
+++ b/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs b/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs
new file mode 100644
index 0000000..bd3e95e
--- /dev/null
+++ b/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs
@@ -0,0 +1,104 @@
+using CommunityToolkit.Mvvm.Messaging;
+using CommunityToolkit.Mvvm.Messaging.Messages;
+using Microsoft.Extensions.DependencyInjection;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace BBWYB.Client.Views.WebB
+{
+ ///
+ /// WebB.xaml 的交互逻辑
+ ///
+ public partial class WebB_GoodsSource : Page
+ {
+ private WebView2Manager w2m;
+ private bool isNavigated;
+
+ private GlobalContext globalContext;
+
+ public WebB_GoodsSource()
+ {
+ InitializeComponent();
+ this.Loaded += WebB_Loaded;
+ this.Unloaded += WebB_Unloaded;
+
+ //WeakReferenceMessenger.Default.Register(this, (o, x) =>
+ //{
+ // this.Dispatcher.Invoke(() =>
+ // {
+ // _ = w2m.wb2.ExecuteScriptAsync("window.location.reload();");
+ // });
+ //});
+
+ //WeakReferenceMessenger.Default.Register(this, (o, x) =>
+ //{
+ // this.Dispatcher.Invoke(() =>
+ // {
+ // _ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');");
+ // });
+ //});
+ }
+
+ private void WebB_Unloaded(object sender, RoutedEventArgs e)
+ {
+ grid.Children.Remove(w2m.wb2);
+ //w2m.wb2.Dispose();
+ w2m.Close();
+ WeakReferenceMessenger.Default.UnregisterAll(this);
+ }
+
+ private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e)
+ {
+ var sp = (App.Current as App).ServiceProvider;
+ using (var s = sp.CreateScope())
+ {
+ w2m = s.ServiceProvider.GetRequiredService();
+ globalContext = s.ServiceProvider.GetRequiredService();
+ }
+
+#if DEBUG
+ var url = "http://192.168.1.2/#/goods-source";
+ var registerName = "webTestContext";
+ //var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");
+#else
+ var url = "http://qtbbwy.qiyue666.com/#/goods-source";
+ var registerName = "webContext";
+#endif
+ w2m.CoreWebView2InitializationCompleted = (e) =>
+ {
+ w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext);
+ isNavigated = true;
+ w2m.wb2.CoreWebView2.Navigate(url);
+ };
+
+
+ w2m.Init("bbwyb_web");
+ w2m.wb2.SetValue(Grid.RowProperty, 1);
+ w2m.wb2.Margin = new Thickness(1, 0, 1, 0);
+ //grid.Children.Clear();
+ grid.Children.Add(w2m.wb2);
+
+ if (w2m.IsInitializationCompleted && !isNavigated)
+ {
+ w2m.wb2.CoreWebView2.Navigate(url);
+ //w2m.wb2.CoreWebView2.NavigateToString(content);
+ isNavigated = true;
+ }
+ }
+ }
+
+
+ //public class Message_WebB_GoodsSource_Refresh : ValueChangedMessage