Browse Source

10128

AddValidOverTime
shanji 2 years ago
parent
commit
c1eb5404b6
  1. 18
      BBWY.Client/GlobalContext.cs
  2. 2
      BBWY.Client/Models/User/User.cs
  3. 1
      BBWY.Client/ViewModels/MainViewModel.cs
  4. 8
      BBWY.Client/Views/Order/GrabJDMibole.xaml.cs
  5. 1
      BBWY.Client/Views/Web/Web.xaml.cs

18
BBWY.Client/GlobalContext.cs

@ -1,15 +1,19 @@
using BBWY.Client.Models; using BBWY.Client.Models;
using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace BBWY.Client namespace BBWY.Client
{ {
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class GlobalContext : NotifyObject public class GlobalContext : NotifyObject
{ {
public GlobalContext() public GlobalContext()
{ {
ShopServiceGroupList = new List<string>(); ShopServiceGroupList = new List<string>();
ShopServiceGroupLowerList = new List<string>(); ShopServiceGroupLowerList = new List<string>();
ClientVersion = "10127"; ClientVersion = "10128";
} }
private User user; private User user;
@ -42,5 +46,17 @@ namespace BBWY.Client
public string QKApiHost { get; set; } public string QKApiHost { get; set; }
#endregion #endregion
#region Web
public string GetUserString()
{
return JsonConvert.SerializeObject(User);
}
public string GetClientApiVersion()
{
return ClientVersion;
}
#endregion
} }
} }

2
BBWY.Client/Models/User/User.cs

@ -28,5 +28,7 @@ namespace BBWY.Client.Models
/// </summary> /// </summary>
public IList<Shop> ShopList { get; set; } public IList<Shop> ShopList { get; set; }
public string Token { get; set; }
} }
} }

1
BBWY.Client/ViewModels/MainViewModel.cs

@ -268,6 +268,7 @@ namespace BBWY.Client.ViewModels
throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}"); throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}");
GlobalContext.User = mdsUserResponse.Data.Map<User>(); GlobalContext.User = mdsUserResponse.Data.Map<User>();
GlobalContext.User.Token = GlobalContext.UserToken;
GlobalContext.User.SonDepartmentNames = string.Empty; GlobalContext.User.SonDepartmentNames = string.Empty;
if (mdsUserResponse.Data.SonDepartmentList != null && mdsUserResponse.Data.SonDepartmentList.Count > 0) if (mdsUserResponse.Data.SonDepartmentList != null && mdsUserResponse.Data.SonDepartmentList.Count > 0)
GlobalContext.User.SonDepartmentNames = string.Join(',', mdsUserResponse.Data.SonDepartmentList.Select(sd => sd.DepartmentName)); GlobalContext.User.SonDepartmentNames = string.Join(',', mdsUserResponse.Data.SonDepartmentList.Select(sd => sd.DepartmentName));

8
BBWY.Client/Views/Order/GrabJDMibole.xaml.cs

@ -40,10 +40,17 @@ namespace BBWY.Client.Views.Order
private void GrabJDMibole_Loaded(object sender, RoutedEventArgs e) private void GrabJDMibole_Loaded(object sender, RoutedEventArgs e)
{ {
var sp = (App.Current as App).ServiceProvider; var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope()) using (var s = sp.CreateScope())
{ {
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>(); w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>();
} }
GlobalContext globalContext = null;
using (var s = sp.CreateScope())
{
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
w2m.Init(shopId); w2m.Init(shopId);
grid.Children.Add(w2m.wb2); grid.Children.Add(w2m.wb2);
@ -53,6 +60,7 @@ namespace BBWY.Client.Views.Order
w2m.CoreWebView2InitializationCompleted = (e) => w2m.CoreWebView2InitializationCompleted = (e) =>
{ {
isNavigated = true; isNavigated = true;
w2m.wb2.CoreWebView2.AddHostObjectToScript("webContext", globalContext);
w2m.wb2.CoreWebView2.Navigate($"https://neworder.shop.jd.com/order/orderDetail?orderId={orderId}"); w2m.wb2.CoreWebView2.Navigate($"https://neworder.shop.jd.com/order/orderDetail?orderId={orderId}");
}; };
w2m.OnNavigationCompleted = async (e) => w2m.OnNavigationCompleted = async (e) =>

1
BBWY.Client/Views/Web/Web.xaml.cs

@ -41,6 +41,7 @@ namespace BBWY.Client.Views.Web
w2m.CoreWebView2InitializationCompleted = (e) => w2m.CoreWebView2InitializationCompleted = (e) =>
{ {
isNavigated = true; isNavigated = true;
w2m.wb2.CoreWebView2.AddHostObjectToScript("webContext", this.globalContext);
// w2m.wb2.CoreWebView2.Navigate($"https://neworder.shop.jd.com/order/orderDetail?orderId={orderId}"); // w2m.wb2.CoreWebView2.Navigate($"https://neworder.shop.jd.com/order/orderDetail?orderId={orderId}");
w2m.wb2.CoreWebView2.Navigate(url); w2m.wb2.CoreWebView2.Navigate(url);
}; };

Loading…
Cancel
Save