diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index c76b1d4c..29c6e1a0 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -25,5 +25,9 @@ namespace BBWY.Client.Models public string ManagePwd { get; set; } public decimal? PlatformCommissionRatio { get; set; } + + public string TeamId { get; set; } + + public string TeamName { get; set; } } } diff --git a/BBWY.Client/Models/Shop/Department2.cs b/BBWY.Client/Models/Shop/Department2.cs new file mode 100644 index 00000000..6163dfac --- /dev/null +++ b/BBWY.Client/Models/Shop/Department2.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace BBWY.Client.Models +{ + public class Department2 + { + public string Id { get; set; } + + public string Name { get; set; } + + public IList ShopList { get; set; } + + public Department2() + { + ShopList = new List(); + } + } +} diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index ccb3db65..58823ec3 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -36,5 +36,9 @@ namespace BBWY.Client.Models /// 店铺扣点 /// public decimal? PlatformCommissionRatio { get; set; } + + public string TeamId { get; set; } + + public string TeamName { get; set; } } } diff --git a/BBWY.Client/Models/User/User.cs b/BBWY.Client/Models/User/User.cs index f7c45709..e782f434 100644 --- a/BBWY.Client/Models/User/User.cs +++ b/BBWY.Client/Models/User/User.cs @@ -1,4 +1,7 @@ -namespace BBWY.Client.Models +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace BBWY.Client.Models { public class User : NotifyObject { @@ -20,5 +23,7 @@ public string TeamName { get; set; } public Shop Shop { get => shop; set { Set(ref shop, value); } } + + public IList DepartmentList { get; set; } } } diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index c818b72f..e2b6e278 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -1,5 +1,6 @@ using BBWY.Client.APIServices; using BBWY.Client.Models; +using BBWY.Client.Views; using BBWY.Common.Extensions; using BBWY.Common.Http; using BBWY.Common.Models; @@ -188,16 +189,44 @@ namespace BBWY.Client.ViewModels var shopList = shopListResponse.Data.Map>(); if (shopList.Count == 1) { + ShowShopChoosePanel = false; ChooseShop(shopList[0], true); } else { + ShowShopChoosePanel = true; + IList department2s = new List(); + foreach (var shop in shopList) + { + var department = department2s.FirstOrDefault(d => d.Id == shop.TeamId); + if (department == null) + { + department = new Department2() { Id = shop.TeamId, Name = shop.TeamName }; + department2s.Add(department); + } + department.ShopList.Add(shop); + } + GlobalContext.User.DepartmentList = department2s; + App.Current.Dispatcher.Invoke(() => { - foreach (var s in shopList) - ShopList.Add(s); + var selectShop = new SelectShop(department2s); + if (selectShop.ShowDialog() == true) + { + ChooseShop(selectShop.Shop, true); + } + else + { + Environment.Exit(Environment.ExitCode); + } }); - ShowShopChoosePanel = true; + + //App.Current.Dispatcher.Invoke(() => + //{ + // foreach (var s in shopList) + // ShopList.Add(s); + //}); + //ShowShopChoosePanel = true; } } } @@ -230,7 +259,7 @@ namespace BBWY.Client.ViewModels } GlobalContext.User.Shop = shop; - ShowShopChoosePanel = false; + //ShowShopChoosePanel = false; Task.Factory.StartNew(GetLogisticsList); } diff --git a/BBWY.Client/Views/SelectShop.xaml b/BBWY.Client/Views/SelectShop.xaml new file mode 100644 index 00000000..b54bf15a --- /dev/null +++ b/BBWY.Client/Views/SelectShop.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/SelectShop.xaml.cs b/BBWY.Client/Views/SelectShop.xaml.cs new file mode 100644 index 00000000..a22b6233 --- /dev/null +++ b/BBWY.Client/Views/SelectShop.xaml.cs @@ -0,0 +1,36 @@ +using BBWY.Client.Models; +using BBWY.Controls; +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace BBWY.Client.Views +{ + /// + /// SelectShop.xaml 的交互逻辑 + /// + public partial class SelectShop : BWindow + { + public IList DepartmentList { get; set; } + public Shop Shop { get; set; } + + public SelectShop(IList departmentList) + { + InitializeComponent(); + this.DepartmentList = departmentList; + } + + private void btn_ok_Click(object sender, RoutedEventArgs e) + { + + } + } +}