用户列表页面完成 订单列表页面开始 10%
This commit is contained in:
1 parent
25cdf642bf
commit
edc7913637
52 files changed
+2032
-365
No files matched your search
@@ -0,0 +1,82 @@
|
||||
<UserControl x:Class="_29WxOrderWpf.Ctrls.OrderCtrls.OrderListCtrl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
|
||||
xmlns:utils="clr-namespace:_29WxOrderWpf.Utils"
|
||||
xmlns:converters="clr-namespace:_29WxOrderWpf.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800" Loaded="Window_Loaded">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converters:NotHasTextToVisibilityConverter x:Key="NotHasTextVisibility"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Background="{StaticResource ListCtrlBackColorBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"></RowDefinition>
|
||||
<RowDefinition Height="40"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="gridSearch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="txtShopName" Grid.Column="0" Margin="4,0,-4,0" BorderBrush="{StaticResource mainColorBrush}" BorderThickness="1" Height="28" VerticalContentAlignment="Center"
|
||||
Style="{StaticResource BaseRoundCornerTextBoxStyle}" />
|
||||
<TextBlock Text="全部店铺" Grid.Column="0" Margin="8,0,8,0" VerticalAlignment="Center" IsHitTestVisible="False" Foreground="LightGray" Visibility="{Binding ElementName=txtShopName,Path=Text,Converter={StaticResource NotHasTextVisibility}}"></TextBlock>
|
||||
<Button Grid.Column="1" x:Name="btnMultiShopChoice" Style="{StaticResource BasePageButtonStyle}" Margin="-4,0,0,0" Grid.Row="4" Content=" ... " Width="28" Height="28" Click="btnMultiShopChoice_Click"></Button>
|
||||
<TextBox x:Name="txtGoodsName" Grid.Column="2" Margin="4,0" BorderBrush="{StaticResource mainColorBrush}" BorderThickness="1" Height="28" VerticalContentAlignment="Center"
|
||||
Style="{StaticResource BaseRoundCornerTextBoxStyle}"/>
|
||||
<TextBlock Text="商品标题" Grid.Column="2" Margin="8,0,8,0" VerticalAlignment="Center" IsHitTestVisible="False" Foreground="LightGray" Visibility="{Binding ElementName=txtGoodsName,Path=Text,Converter={StaticResource NotHasTextVisibility}}"></TextBlock>
|
||||
|
||||
</Grid>
|
||||
<Grid x:Name="gridListHeader" Margin="4,0" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40"></ColumnDefinition>
|
||||
<ColumnDefinition Width="100*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="100*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
</Grid>
|
||||
<ListBox IsHitTestVisible="True" BorderThickness="0" ItemsSource="{Binding lstOrder}" Grid.Row="2" HorizontalContentAlignment="Stretch" x:Name="lbxOrder" Margin="4,0,4,4">
|
||||
<!--使用自定义属性模板去除ListBox高亮显示框-->
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<ContentPresenter Content="{TemplateBinding Content}"
|
||||
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<!--此处绑定将数据源传递给子自定义控件OrderListRowCtrl-->
|
||||
<local:OrderListRowCtrl DataContext="{Binding}"></local:OrderListRowCtrl>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,174 @@
|
||||
using AllBase;
|
||||
using AllBase.Extension;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model;
|
||||
using AllBase.Model.Result;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
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;
|
||||
using Work;
|
||||
using Work.BLL;
|
||||
|
||||
namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
{
|
||||
/// <summary>
|
||||
/// OrderListCtrl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class OrderListCtrl : UserControl
|
||||
{
|
||||
public ObservableCollection<oms_wei_order_info> lstOrder { get; set; } = new ObservableCollection<oms_wei_order_info>();
|
||||
public List<oms_wei_order_info> lstOrder1 { get; set; } = new List<oms_wei_order_info>();
|
||||
|
||||
|
||||
public OrderListCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//MyData newItem = new MyData { Name = "New Person", Age = 28 }; // 创建新数据项
|
||||
//_myDataCollection.Add(newItem); // 添加到集合中
|
||||
//dataGrid.Items.Refresh();.
|
||||
//dgOrder.Items.Add(1111111);
|
||||
|
||||
//dgOrder.ItemsSource = lstOrder;
|
||||
|
||||
//lbxOrder.ItemsSource = lstOrder;
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (!MainWindow.Instance.hasReadShop)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
GetOrder();
|
||||
//GetOrderTest();
|
||||
});
|
||||
}
|
||||
|
||||
void GetOrderTest()
|
||||
{
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
//lstOrder.Add(new oms_wei_order_info() { id = 1, is_select = false, order_id = ("3737033423685556736".ParseToLong() + Randomx.GetId(0,100)).ParseToString(), shop_name = "媛卡曦工厂优选" });
|
||||
lstOrder.Add(new oms_wei_order_info() { id = 1, is_select = false, order_id = Randomx.GetId(1000, 10000).ParseToString(), shop_name = "媛卡曦工厂优选" });
|
||||
}
|
||||
lstOrder.SortDesc(o => o.order_id.ParseToLong());
|
||||
}
|
||||
|
||||
void GetOrder()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
int page = 0;
|
||||
int totalPage = 1;
|
||||
while (true)
|
||||
{
|
||||
if (page >= totalPage)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
page++;
|
||||
var url = BaseClass.Build29WxObjString("order/get_order_list");
|
||||
var data = UserLogin.GetSignaturex() + "&page=" + page;
|
||||
var shop_id = string.Join(",", GlobalConfig.ShopLoginList.Select(s => s.ErpShopId).Where(s => !s.IsNullOrEmpty()));
|
||||
data += "&erp_shop_id_in=" + shop_id;
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(txtShopName.Text.Trim()))
|
||||
{
|
||||
var shopNames = txtShopName.Text.Trim().Split(';').Where(s => !s.IsNullOrEmpty()).ToList();
|
||||
shop_id = string.Join(",", GlobalConfig.ShopLoginList.Where(s => shopNames.Contains(s.ShopAccount)).Select(s => s.ErpShopId).Where(s => !s.IsNullOrEmpty()));
|
||||
}
|
||||
}));
|
||||
Thread.Sleep(200);
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var jArr = JObject.Parse(html)["data"];
|
||||
if (jArr.Count() == 0)
|
||||
break;
|
||||
|
||||
foreach (JObject jObj in jArr)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
var order = JsonHelper.DeserializeJsonToObject<oms_wei_order_info>(JsonHelper.SerializeObject(jObj));
|
||||
var orderExist = this.lstOrder.FirstOrDefault(o => o.order_id == order.order_id);
|
||||
if (orderExist != null)
|
||||
this.lstOrder.Remove(orderExist);
|
||||
|
||||
var nextOrder = this.lstOrder.FirstOrDefault(o => o.create_time < order.create_time);
|
||||
if (nextOrder != null)
|
||||
{
|
||||
lstOrder.Insert(lstOrder.IndexOf(nextOrder), order);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstOrder.Add(order);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var orderId = ((sender as Border)?.Tag).ParseToString();
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(orderId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void btnMultiShopChoice_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainWindow.Instance.shopListCtrl.IsVisibleChanged -= ShopListCtrl_IsVisibleChanged;
|
||||
MainWindow.Instance.shopListCtrl.Visibility = Visibility.Visible;
|
||||
MainWindow.Instance.shopListCtrl.IsVisibleChanged += ShopListCtrl_IsVisibleChanged;
|
||||
}
|
||||
|
||||
private void ShopListCtrl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!MainWindow.Instance.shopListCtrl.IsVisible && MainWindow.Instance.shopListCtrl.IsAcceptChoiceShop == true)
|
||||
{
|
||||
var list = MainWindow.Instance.shopListCtrl.lbxShop.ItemsSource as ObservableCollection<ShopLoginInfo>;
|
||||
if (list != null)
|
||||
this.txtShopName.Text = string.Join(";", list.Where(s => s.IsSelect == true).Select(s => s.ShopAccount));
|
||||
|
||||
|
||||
}
|
||||
MainWindow.Instance.shopListCtrl.IsVisibleChanged -= ShopListCtrl_IsVisibleChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<UserControl x:Class="_29WxOrderWpf.Ctrls.OrderCtrls.OrderListRowCtrl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="200" d:DesignWidth="800">
|
||||
<Border Margin="12,12,12,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="1"
|
||||
BorderBrush="{StaticResource ListRowBorderColorBrush}" CornerRadius="10">
|
||||
<Border.Style>
|
||||
<!-- 鼠标进入或悬停Border时切换颜色(悬停时Border的填充控件必须有填充Border,所在层级不限,仅填充透明Grid则触发器无效) -->
|
||||
<Style TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{StaticResource ListRowHoverBackColorBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="120">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<!--子控件是普通控件而非模板页控件,无需指定DataContext="{Binding}"-->
|
||||
<local:OrderListRowHeaderCtrl></local:OrderListRowHeaderCtrl>
|
||||
<!--<local:OrderListRowHeaderCtrl DataContext="{Binding}"></local:OrderListRowHeaderCtrl>-->
|
||||
<Border Grid.Row="1" Background="Transparent" CornerRadius="0,0,12,12" >
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,41 @@
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
{
|
||||
/// <summary>
|
||||
/// OrderListRowCtrl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class OrderListRowCtrl : UserControl
|
||||
{
|
||||
public OrderListRowCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var orderId = ((sender as Border)?.Tag).ParseToString();
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(orderId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<UserControl x:Class="_29WxOrderWpf.Ctrls.OrderCtrls.OrderListRowHeaderCtrl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="150" d:DesignWidth="800">
|
||||
|
||||
<Border Background="{StaticResource ListRowBorderColorBrush}" CornerRadius="12,12,0,0" >
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0" Margin="8,8,0,8" VerticalAlignment="Center" FontSize="14" Background="Transparent" IsReadOnly="True" Text="店铺单号:" BorderThickness="0" />
|
||||
<TextBox Grid.Column="1" Margin="0,8,8,8" VerticalAlignment="Center" FontSize="14" Background="Transparent" IsReadOnly="True"
|
||||
Text="{Binding order_id}" BorderThickness="0" />
|
||||
<Border Grid.Column="2" Width="12" Background="Transparent" Height="12" VerticalAlignment="Center" Cursor="Hand"
|
||||
Tag="{Binding order_id}" MouseLeftButtonDown="Path_MouseLeftButtonDown">
|
||||
<Path Margin="0,0,0,0" Fill="#409eff" Tag="{Binding order_id}" MouseLeftButtonDown="Path_MouseLeftButtonDown" Data="M80 432a128 128 0 0 1 128-128h384a128 128 0 0 1 128 128v384a128 128 0 0 1-128 128h-384a128 128 0 0 1-128-128v-384z m128-64a64 64 0 0 0-64 64v384a64 64 0 0 0 64 64h384a64 64 0 0 0 64-64v-384a64 64 0 0 0-64-64h-384z M816 144h-384a64 64 0 0 0-64 64 32 32 0 0 1-64 0 128 128 0 0 1 128-128h384a128 128 0 0 1 128 128v384a128 128 0 0 1-128 128 32 32 0 0 1 0-64 64 64 0 0 0 64-64v-384a64 64 0 0 0-64-64z" Stretch="Uniform" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,41 @@
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
{
|
||||
/// <summary>
|
||||
/// OrderListRowHeaderCtrl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class OrderListRowHeaderCtrl : UserControl
|
||||
{
|
||||
public OrderListRowHeaderCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var orderId = ((sender as Border)?.Tag).ParseToString();
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(orderId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user