修改工单流程页面,订单列表增加工单按钮

This commit is contained in:
chfei committed 2026-10-18 20:35:47 +08:00
1 parent f9dcae4610
commit 10bb0803d9
44 files changed
+5920 -1291

No files matched your search

+2 -2
View File
@@ -143,8 +143,8 @@ namespace _29WxOrderWpf
}
#endregion
//new MainWindow().Show();
new OrderSupportTicketWindow().Show();
new MainWindow().Show();
//new OrderSupportTicketWindow().Show();
}
//static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
@@ -30,7 +30,7 @@ public partial class OrderListCtrl
{
if (_statisticsDialog == null)
{
_statisticsDialog =new ShopRevenueStatisticsView();
_statisticsDialog = new ShopRevenueStatisticsView();
_statisticsDialog.Closed += (s, e) => _statisticsDialog = null;
}
_statisticsDialog.Show();
@@ -310,7 +310,7 @@ public partial class OrderListCtrl
private void ShowPDDInvoiceDialog()
{
var view = new PDDInvoiceView();
DialogService.Show(view);
DialogService.ShowOrActivateWindow(view);
}
#endregion
}
@@ -1,86 +1,86 @@
<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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:_29WxOrderWpf.UserControls"
d:DesignHeight="50"
d:DesignWidth="800"
mc:Ignorable="d">
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:_29WxOrderWpf.UserControls"
d:DesignHeight="50"
d:DesignWidth="800"
mc:Ignorable="d">
<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" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<TextBox
Grid.Column="0"
Margin="8,8,-4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
FontSize="20"
FontWeight="ExtraBold"
Foreground="{Binding OrderBuyTypeColor}"
IsReadOnly="True"
Text="{Binding OrderBuyType}"
Visibility="{Binding OrderBuyType, Converter={StaticResource HasTextVisibility}}" />
<TextBox
Grid.Column="1"
Margin="8,8,-4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
FontSize="14"
IsReadOnly="True"
Text="店铺单号:" />
<uc:UcWaterMarkTextBox1
x:Name="txtOrderId"
Grid.Column="2"
Margin="0,8,4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
Cursor="Hand"
FontSize="14"
Foreground="{StaticResource PageLinkBrush}"
IsReadOnly="True"
Text="{Binding order_id}"
WaterMark="订单号" />
<Border
Grid.Column="3"
Width="12"
Height="12"
VerticalAlignment="Center"
Background="Transparent"
Cursor="Hand"
MouseLeftButtonDown="Path_MouseLeftButtonDown"
Tag="{Binding order_id}">
<Path
Margin="0,0,0,0"
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"
Fill="{StaticResource PageLinkBrush}"
MouseLeftButtonDown="Path_MouseLeftButtonDown"
Stretch="Uniform"
Tag="{Binding order_id}" />
</Border>
<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" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<TextBox
Grid.Column="0"
Margin="8,8,-4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
FontSize="20"
FontWeight="ExtraBold"
Foreground="{Binding OrderBuyTypeColor}"
IsReadOnly="True"
Text="{Binding OrderBuyType}"
Visibility="{Binding OrderBuyType, Converter={StaticResource HasTextVisibility}}" />
<TextBox
Grid.Column="1"
Margin="8,8,-4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
FontSize="14"
IsReadOnly="True"
Text="店铺单号:" />
<uc:UcWaterMarkTextBox1
x:Name="txtOrderId"
Grid.Column="2"
Margin="0,8,4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
Cursor="Hand"
FontSize="14"
Foreground="{StaticResource PageLinkBrush}"
IsReadOnly="True"
Text="{Binding order_id}"
WaterMark="订单号" />
<Border
Grid.Column="3"
Width="12"
Height="12"
VerticalAlignment="Center"
Background="Transparent"
Cursor="Hand"
MouseLeftButtonDown="Path_MouseLeftButtonDown"
Tag="{Binding order_id}">
<Path
Margin="0,0,0,0"
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"
Fill="{StaticResource PageLinkBrush}"
MouseLeftButtonDown="Path_MouseLeftButtonDown"
Stretch="Uniform"
Tag="{Binding order_id}" />
</Border>
<!--<Border x:Name="borderDeadline" Grid.Column="3" Margin="8,0,0,0" Background="#e8fbf9" BorderBrush="#d0fbea" BorderThickness="1" MinWidth="30" Height="24" CornerRadius="2">
<!--<Border x:Name="borderDeadline" Grid.Column="3" Margin="8,0,0,0" Background="#e8fbf9" BorderBrush="#d0fbea" BorderThickness="1" MinWidth="30" Height="24" CornerRadius="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
@@ -94,163 +94,169 @@
Text="{Binding DeliveryDeadlineStr}" BorderThickness="0" />
</Grid>
</Border>-->
<Border
x:Name="borderDeadline"
Grid.Column="4"
Height="24"
MinWidth="30"
Margin="8,0,0,0"
Background="{Binding StatusBoxBackColor}"
BorderBrush="{Binding StatusBoxBorderColor}"
BorderThickness="1"
CornerRadius="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
x:Name="borderDeadlineHead"
Background="{Binding StatusBoxForeColor}"
CornerRadius="2,0,10,2">
<TextBox
Grid.Column="0"
MinWidth="20"
Margin="2,0,2,1"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Background="Transparent"
BorderThickness="0"
Foreground="White"
IsReadOnly="True"
Text="{Binding DeliveryDeadlineStatusStr}" />
</Border>
<TextBox
x:Name="txtDeadline"
Grid.Column="1"
MinWidth="20"
Margin="2,0,2,1"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Background="Transparent"
BorderThickness="0"
Foreground="{Binding StatusBoxForeColor}"
IsReadOnly="True"
Text="{Binding DeliveryDeadlineStr}" />
</Grid>
</Border>
<Border
x:Name="borderDeadline"
Grid.Column="4"
Height="24"
MinWidth="30"
Margin="8,0,0,0"
Background="{Binding StatusBoxBackColor}"
BorderBrush="{Binding StatusBoxBorderColor}"
BorderThickness="1"
CornerRadius="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
x:Name="borderDeadlineHead"
Background="{Binding StatusBoxForeColor}"
CornerRadius="2,0,10,2">
<TextBox
Grid.Column="0"
MinWidth="20"
Margin="2,0,2,1"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Background="Transparent"
BorderThickness="0"
Foreground="White"
IsReadOnly="True"
Text="{Binding DeliveryDeadlineStatusStr}" />
</Border>
<TextBox
x:Name="txtDeadline"
Grid.Column="1"
MinWidth="20"
Margin="2,0,2,1"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Background="Transparent"
BorderThickness="0"
Foreground="{Binding StatusBoxForeColor}"
IsReadOnly="True"
Text="{Binding DeliveryDeadlineStr}" />
</Grid>
</Border>
<Image
Grid.Column="5"
Width="24"
Height="24"
Margin="8,8,0,8"
Source="{StaticResource imgOrderWeishopIcon}" />
<uc:UcWaterMarkTextBox1
x:Name="txtShopLoginStatus"
Grid.Column="5"
Margin="0,12,-6,0"
Padding="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="{StaticResource ListHeadBackColorBrush}"
BorderThickness="0"
FontSize="7"
FontWeight="Bold"
Foreground="{Binding Shop.LoginStatusStr, Converter={StaticResource statusToColorBrushConverter}}"
IsReadOnly="True"
Text="{Binding Shop.LoginStatusStr}"
WaterMark="店铺状态" />
<uc:UcWaterMarkTextBox1
x:Name="txtShopName"
Grid.Column="6"
Margin="4,8,4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
Cursor="Hand"
FontSize="14"
Foreground="{StaticResource PageLinkBrush}"
IsReadOnly="True"
Text="{Binding shop_name}"
WaterMark="店铺名称" />
<Image
Grid.Column="5"
Width="24"
Height="24"
Margin="8,8,0,8"
Source="{StaticResource imgOrderWeishopIcon}" />
<uc:UcWaterMarkTextBox1
x:Name="txtShopLoginStatus"
Grid.Column="5"
Margin="0,12,-6,0"
Padding="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="{StaticResource ListHeadBackColorBrush}"
BorderThickness="0"
FontSize="7"
FontWeight="Bold"
Foreground="{Binding Shop.LoginStatusStr, Converter={StaticResource statusToColorBrushConverter}}"
IsReadOnly="True"
Text="{Binding Shop.LoginStatusStr}"
WaterMark="店铺状态" />
<uc:UcWaterMarkTextBox1
x:Name="txtShopName"
Grid.Column="6"
Margin="4,8,4,8"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
Cursor="Hand"
FontSize="14"
Foreground="{StaticResource PageLinkBrush}"
IsReadOnly="True"
Text="{Binding shop_name}"
WaterMark="店铺名称" />
<Border
Grid.Column="7"
Width="12"
Height="12"
VerticalAlignment="Center"
Background="Transparent"
Cursor="Hand"
MouseLeftButtonDown="pathShop_MouseLeftButtonDown"
Tag="{Binding order_id}">
<Path
Margin="0,0,0,0"
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"
Fill="{StaticResource PageLinkBrush}"
MouseLeftButtonDown="pathShop_MouseLeftButtonDown"
Stretch="Uniform"
Tag="{Binding order_id}" />
</Border>
<Border
Grid.Column="7"
Width="12"
Height="12"
VerticalAlignment="Center"
Background="Transparent"
Cursor="Hand"
MouseLeftButtonDown="pathShop_MouseLeftButtonDown"
Tag="{Binding order_id}">
<Path
Margin="0,0,0,0"
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"
Fill="{StaticResource PageLinkBrush}"
MouseLeftButtonDown="pathShop_MouseLeftButtonDown"
Stretch="Uniform"
Tag="{Binding order_id}" />
</Border>
<uc:UcWaterMarkTextBox1
x:Name="txtCount"
Grid.Column="9"
Margin="8,8,0,8"
VerticalAlignment="Center"
d:Text="该订单共有 x 条不同商品记录"
Background="Transparent"
BorderThickness="0"
FontSize="14"
Foreground="Gray"
IsReadOnly="True"
WaterMark="该订单共有 1 条不同商品记录" />
<uc:UcWaterMarkTextBox1
x:Name="txtCount"
Grid.Column="9"
Margin="8,8,0,8"
VerticalAlignment="Center"
d:Text="该订单共有 x 条不同商品记录"
Background="Transparent"
BorderThickness="0"
FontSize="14"
Foreground="Gray"
IsReadOnly="True"
WaterMark="该订单共有 1 条不同商品记录" />
<TextBlock
Grid.Column="11"
Margin="10"
VerticalAlignment="Center"
d:Text="仅退款/退货退款"
Foreground="Gray"
Text="{Binding RefundTypeStr}" />
<TextBlock
Grid.Column="11"
Margin="10"
VerticalAlignment="Center"
d:Text="仅退款/退货退款"
Foreground="Gray"
Text="{Binding RefundTypeStr}" />
<Border
x:Name="borderFlag"
Grid.Column="12"
Width="auto"
Height="15"
Margin="2"
VerticalAlignment="Center"
Background="Transparent"
Cursor="Hand"
MouseLeftButtonDown="borderFlag_MouseLeftButtonDown">
<!--<Path Margin="0,0,0,0" Fill="{StaticResource FlagGrayBrush}" Data="M 0,0 L 1,0 L 1,1 L 10,1 L 7,4 L 10,7 L 1,7 L 1,12 L 0,12 Z" Stretch="Uniform" />-->
<WrapPanel VerticalAlignment="Center">
<TextBlock
VerticalAlignment="Center"
FontSize="12"
Foreground="Gray"
Text="隐藏标记" />
<Border
x:Name="borderFlag"
Grid.Column="12"
Width="auto"
Margin="2"
VerticalAlignment="Center"
Background="Transparent"
Cursor="Hand"
MouseLeftButtonDown="borderFlag_MouseLeftButtonDown">
<!--<Path Margin="0,0,0,0" Fill="{StaticResource FlagGrayBrush}" Data="M 0,0 L 1,0 L 1,1 L 10,1 L 7,4 L 10,7 L 1,7 L 1,12 L 0,12 Z" Stretch="Uniform" />-->
<WrapPanel VerticalAlignment="Center">
<Button
Width="60"
Height="22"
Margin="0,0,10,0"
Click="btn_createOrderSupportTicket"
Content="创建工单"
Style="{StaticResource BasePageButtonStyle}" />
<TextBlock
VerticalAlignment="Center"
FontSize="12"
Foreground="Gray"
Text="隐藏标记" />
<Path
Width="15"
Height="15"
Margin="2,0,0,0"
d:Fill="SkyBlue"
Data="M 0,0 L 1,0 L 1,1 L 10,1 L 7,4 L 10,7 L 1,7 L 1,12 L 0,12 Z"
Fill="{Binding ColourFlagBrush}"
Stretch="Uniform" />
<!--ColourFlagBrush-->
<!--Fill="{Binding colour_flag, Converter={StaticResource flagColorConverter}}"-->
Width="15"
Height="15"
Margin="2,0,0,0"
d:Fill="SkyBlue"
Data="M 0,0 L 1,0 L 1,1 L 10,1 L 7,4 L 10,7 L 1,7 L 1,12 L 0,12 Z"
Fill="{Binding ColourFlagBrush}"
Stretch="Uniform" />
<!-- ColourFlagBrush -->
<!-- Fill="{Binding colour_flag, Converter={StaticResource flagColorConverter}}" -->
</WrapPanel>
</Border>
</Border>
<!--<Border Grid.Column="11" Width="12" Background="Transparent" Height="12" VerticalAlignment="Center" Cursor="Hand">
<!--<Border Grid.Column="11" Width="12" Background="Transparent" Height="12" VerticalAlignment="Center" Cursor="Hand">
<Path Margin="0,0,0,0" Fill="{StaticResource PageLinkBrush}" MouseLeftButtonDown="pathShop_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>
</Grid>
</Border>
</UserControl>
@@ -3,6 +3,7 @@ using AllBase;
using AllBase.Helper;
using AllBase.Model.DBModel;
using NaiBa.Util.Extension;
using OrderSupportTicket.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -25,43 +26,43 @@ using Work._29Tools.Forms.ShopForms;
namespace _29WxOrderWpf.Ctrls.OrderCtrls
{
/// <summary>
/// OrderListRowHeaderCtrl.xaml 的交互逻辑
/// </summary>
public partial class OrderListRowHeaderCtrl : UserControl
{
public OrderListRowHeaderCtrl()
{
InitializeComponent();
this.DataContextChanged += OrderListRowHeaderCtrl_DataContextChanged;
txtOrderId.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtOrderId_MouseLeftButtonUp), true);
txtShopName.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtShopName_MouseLeftButtonUp), true);
}
/// <summary>
/// OrderListRowHeaderCtrl.xaml 的交互逻辑
/// </summary>
public partial class OrderListRowHeaderCtrl : UserControl
{
public OrderListRowHeaderCtrl()
{
InitializeComponent();
this.DataContextChanged += OrderListRowHeaderCtrl_DataContextChanged;
txtOrderId.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtOrderId_MouseLeftButtonUp), true);
txtShopName.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtShopName_MouseLeftButtonUp), true);
}
private void txtShopName_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
if (shop != null)
{
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
ShopBLL.CheckShopLogin(shop);
if (shop.LoginStatus == "登录成功")
{
// 在线直接进店
shopLoginForm.openType = EnumOpenType.manage;
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/home";
shopLoginForm.Show();
}
else
{
// 掉线登录
shopLoginForm.openType = EnumOpenType.login;
shopLoginForm.ShowDialog();
private void txtShopName_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
if (shop != null)
{
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
ShopBLL.CheckShopLogin(shop);
if (shop.LoginStatus == "登录成功")
{
// 在线直接进店
shopLoginForm.openType = EnumOpenType.manage;
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/home";
shopLoginForm.Show();
}
else
{
// 掉线登录
shopLoginForm.openType = EnumOpenType.login;
shopLoginForm.ShowDialog();
if (shop.LoginStatus == "登录成功")
if (shop.LoginStatus == "登录成功")
{
shop.Is29Supplier = false;
for (int i = 0; i < 100; i++)
@@ -82,87 +83,87 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (i * 20 >= totalCount)
break;
}
foreach (var ord in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == shop.ErpShopId).ToList())
{
// 更新代发管理情况
foreach (var orderItem in ord.orderItems)
Dispatcher.Invoke(new Action(() => { orderItem.UpdateOrderItemBuyButton(); }));
}
}
}
}
}
}
private void txtOrderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
if (shop != null)
{
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
shopLoginForm.openType = EnumOpenType.manage;
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
{
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/order/detail?orderid=" + order.order_id;
}
shopLoginForm.Show();
}
}
}
foreach (var ord in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == shop.ErpShopId).ToList())
{
// 更新代发管理情况
foreach (var orderItem in ord.orderItems)
Dispatcher.Invoke(new Action(() => { orderItem.UpdateOrderItemBuyButton(); }));
}
}
}
}
}
}
private void OrderListRowHeaderCtrl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
if (order.orderItems.Count > 5)
{
txtCount.Text = "该订单共计 " + order.orderItems.Count + " 件商品";
}
}
}
private void txtOrderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
if (shop != null)
{
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
shopLoginForm.openType = EnumOpenType.manage;
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//var orderId = ((sender as Border)?.Tag).ParseToString();
if (this.DataContext is oms_wei_order_info order)
{
{
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/order/detail?orderid=" + order.order_id;
}
shopLoginForm.Show();
}
}
}
try
{
//Clipboard.SetText(order.order_id); // 复制成功,但会报错,改为SetDataObject
Clipboard.SetDataObject(order.order_id);
BaseMsgWindow.ShowAnimateMessage("复制成功");
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
}
}
}
private void OrderListRowHeaderCtrl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
if (order.orderItems.Count > 5)
{
txtCount.Text = "该订单共计 " + order.orderItems.Count + " 件商品";
}
}
}
private void pathShop_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
if (shop != null)
{
try
{
Clipboard.SetDataObject(shop.ShopAccount);
BaseMsgWindow.ShowAnimateMessage("复制成功");
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
}
}
}
}
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//var orderId = ((sender as Border)?.Tag).ParseToString();
if (this.DataContext is oms_wei_order_info order)
{
try
{
//Clipboard.SetText(order.order_id); // 复制成功,但会报错,改为SetDataObject
Clipboard.SetDataObject(order.order_id);
BaseMsgWindow.ShowAnimateMessage("复制成功");
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
}
}
}
private void pathShop_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (this.DataContext is oms_wei_order_info order)
{
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
if (shop != null)
{
try
{
Clipboard.SetDataObject(shop.ShopAccount);
BaseMsgWindow.ShowAnimateMessage("复制成功");
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
}
}
}
}
private void borderFlag_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
@@ -195,9 +196,44 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
order.colour_flag = flag;
Thread.Sleep(1000);
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.orderListCtrl.FilterOneOrder(order); }));
});
}
}
/// <summary>
/// 创建工单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void btn_createOrderSupportTicket(object sender, RoutedEventArgs e)
{
if (!(this.DataContext is oms_wei_order_info order))
return;
var shop = order.Shop
?? GlobalConfig.ShopLoginList.FirstOrDefault(
s => s.ErpShopId == order.shop_id.ParseToString());
var appId = shop?.ShopId?.Trim();
if (string.IsNullOrWhiteSpace(appId)
|| string.IsNullOrWhiteSpace(order.order_id))
{
BaseMsgWindow.ShowAnimateMessage(
"订单缺少店铺 APPID 或订单号,无法创建工单",
"Error",
5);
return;
}
var ticketOrder = TicketOrderOption.FromWechatOrder(order, appId);
try
{
await MainWindow.Instance.CreateOrderSupportTicketAsync(ticketOrder);
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("打开工单窗口失败:" + ex.Message);
}
}
}
}
+261 -221
View File
@@ -1,233 +1,273 @@
<basewindows:BaseWindow
x:Class="_29WxOrderWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:basewindows="clr-namespace:_29WxOrderWpf.BaseWindows"
xmlns:buyerctrls="clr-namespace:_29WxOrderWpf.Ctrls.BuyerCtrls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:_29WxOrderWpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:orderctrls="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
xmlns:shopctrls="clr-namespace:_29WxOrderWpf.Ctrls.ShopCtrls"
xmlns:userctrls="clr-namespace:_29WxOrderWpf.UserControls"
x:Name="mainWindow"
Title="MainWindow"
Width="1600"
Height="900"
Closing="BaseWindow_Closing"
Loaded="Window_Loaded"
Style="{StaticResource BaseNoneBorderWindowStyle}"
mc:Ignorable="d">
x:Class="_29WxOrderWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:basewindows="clr-namespace:_29WxOrderWpf.BaseWindows"
xmlns:buyerctrls="clr-namespace:_29WxOrderWpf.Ctrls.BuyerCtrls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:_29WxOrderWpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:orderctrls="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
xmlns:shopctrls="clr-namespace:_29WxOrderWpf.Ctrls.ShopCtrls"
xmlns:userctrls="clr-namespace:_29WxOrderWpf.UserControls"
x:Name="mainWindow"
Title="MainWindow"
Width="1600"
Height="900"
Closing="BaseWindow_Closing"
Loaded="Window_Loaded"
Style="{StaticResource BaseNoneBorderWindowStyle}"
mc:Ignorable="d">
<Grid
x:Name="mainGrid"
Margin="{Binding ElementName=mainWindow, Path=Padding}"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
x:Name="gridTitle"
Background="Transparent"
MouseLeftButtonDown="gridTitle_MouseLeftButtonDown">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Image
Width="50"
Height="50"
Margin="4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="{StaticResource main29WeixinIcon}" />
<Label
x:Name="lblAppName"
Grid.Column="1"
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Content="拍单软件"
FontSize="20"
Foreground="{StaticResource mainColorLightBrush}" />
<Grid
x:Name="mainGrid"
Margin="{Binding ElementName=mainWindow, Path=Padding}"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
x:Name="gridTitle"
Background="Transparent"
MouseLeftButtonDown="gridTitle_MouseLeftButtonDown">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Image
Width="50"
Height="50"
Margin="4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="{StaticResource main29WeixinIcon}" />
<Label
x:Name="lblAppName"
Grid.Column="1"
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Content="拍单软件"
FontSize="20"
Foreground="{StaticResource mainColorLightBrush}" />
<WrapPanel
Grid.Column="2"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<Button Click="bt_setting" Style="{StaticResource IconButtonStyle}">
<TextBlock
FontSize="22"
Foreground="{StaticResource mainColorLightBrush}"
Style="{StaticResource TextBlockIcon}"
Text="{StaticResource txt-settings}" />
</Button>
<Border
Width="1"
Height="20"
Margin="10,0"
Background="#b893b2" />
</WrapPanel>
<WrapPanel
Grid.Column="3"
HorizontalAlignment="Right"
VerticalAlignment="Top">
<UniformGrid Rows="2">
<WrapPanel>
<Label
x:Name="lblDebug"
Margin="2,4,0,0"
Content="[release]"
FontSize="12"
Foreground="{StaticResource mainColorLightBrush}"
Opacity="0.7" />
<Label
x:Name="lblVersion"
Margin="2,4,0,0"
Content="版本信息"
FontSize="12"
Foreground="{StaticResource mainColorLightBrush}"
Opacity="0.7" />
</WrapPanel>
<Label
x:Name="lblBalance"
Grid.Column="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
d:Content="快递余额:999.99"
Content="{Binding Balance}"
Cursor="Hand"
FontSize="12"
Foreground="#60ff66"
MouseLeftButtonUp="lblBalance_MouseLeftButtonUp"
Opacity="0.7" />
</UniformGrid>
</WrapPanel>
<userctrls:UcWindowBoxes
x:Name="ucWindowBox"
Grid.Column="4"
Margin="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
MaxBoxVisibility="Visible" />
</Grid>
<Grid
x:Name="gridContainer"
Grid.Row="1"
Margin="2,0,2,2"
Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<orderctrls:OrderListCtrl
x:Name="orderListCtrl"
Grid.Column="1"
d:Visibility="Visible"
Visibility="Collapsed" />
<Grid
x:Name="gridTbBuyerOrderReadCtrl"
Grid.ColumnSpan="2"
d:Visibility="Visible"
Background="#7F000000"
MouseLeftButtonUp="gridPddBuyerOrderReadCtrl_MouseLeftButtonUp"
Visibility="Hidden">
<WrapPanel
Grid.Column="2"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<Button
x:Name="btOrderSupport"
Click="bt_showOrderSupport"
Style="{StaticResource IconButtonStyle}"
ToolTip="客户工单">
<Grid Width="30" Height="30">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="22"
Foreground="{StaticResource mainColorLightBrush}"
Style="{StaticResource TextBlockIcon}"
Text="{StaticResource txt-alert}" />
<Border
x:Name="borderOrderSupportUnread"
Height="16"
MinWidth="16"
Padding="4,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
d:Visibility="Visible"
Background="#E53935"
CornerRadius="8"
Visibility="Collapsed">
<TextBlock
x:Name="tbOrderSupportUnread"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
FontWeight="Bold"
Foreground="White"
Text="0" />
</Border>
</Grid>
</Button>
<Border
Height="auto"
Margin="0,50,0,0"
HorizontalAlignment="Right"
Background="White"
CornerRadius="10">
Width="1"
Height="20"
Margin="10,0"
Background="#b893b2" />
<Button Click="bt_setting" Style="{StaticResource IconButtonStyle}">
<TextBlock
FontSize="22"
Foreground="{StaticResource mainColorLightBrush}"
Style="{StaticResource TextBlockIcon}"
Text="{StaticResource txt-settings}" />
</Button>
<Border
Width="1"
Height="20"
Margin="10,0"
Background="#b893b2" />
</WrapPanel>
<WrapPanel
Grid.Column="3"
HorizontalAlignment="Right"
VerticalAlignment="Top">
<UniformGrid Rows="2">
<WrapPanel>
<Label
x:Name="lblDebug"
Margin="2,4,0,0"
Content="[release]"
FontSize="12"
Foreground="{StaticResource mainColorLightBrush}"
Opacity="0.7" />
<Label
x:Name="lblVersion"
Margin="2,4,0,0"
Content="版本信息"
FontSize="12"
Foreground="{StaticResource mainColorLightBrush}"
Opacity="0.7" />
</WrapPanel>
<Label
x:Name="lblBalance"
Grid.Column="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
d:Content="快递余额:999.99"
Content="{Binding Balance}"
Cursor="Hand"
FontSize="12"
Foreground="#60ff66"
MouseLeftButtonUp="lblBalance_MouseLeftButtonUp"
Opacity="0.7" />
</UniformGrid>
</WrapPanel>
<userctrls:UcWindowBoxes
x:Name="ucWindowBox"
Grid.Column="4"
Margin="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
MaxBoxVisibility="Visible" />
</Grid>
<Grid
x:Name="gridContainer"
Grid.Row="1"
Margin="2,0,2,2"
Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<orderctrls:OrderListCtrl
x:Name="orderListCtrl"
Grid.Column="1"
d:Visibility="Visible"
Visibility="Collapsed" />
<Grid
x:Name="gridTbBuyerOrderReadCtrl"
Grid.ColumnSpan="2"
d:Visibility="Visible"
Background="#7F000000"
MouseLeftButtonUp="gridPddBuyerOrderReadCtrl_MouseLeftButtonUp"
Visibility="Hidden">
<Border
Height="auto"
Margin="0,50,0,0"
HorizontalAlignment="Right"
Background="White"
CornerRadius="10">
<Grid>
<buyerctrls:PDDBuyerOrderReadCtrl
x:Name="pddBuyerOrderReadCtrl"
Grid.Column="1"
Width="1200"
HorizontalAlignment="Right"
Panel.ZIndex="-1"
d:Visibility="Visible"
Visibility="Collapsed" />
x:Name="pddBuyerOrderReadCtrl"
Grid.Column="1"
Width="1200"
HorizontalAlignment="Right"
Panel.ZIndex="-1"
d:Visibility="Visible"
Visibility="Collapsed" />
<buyerctrls:TbBuyerOrderReadCtrl
x:Name="tbBuyerOrderReadCtrl"
Grid.Column="1"
Width="1200"
HorizontalAlignment="Right"
Panel.ZIndex="-1"
d:Visibility="Collapsed"
Visibility="Collapsed" />
x:Name="tbBuyerOrderReadCtrl"
Grid.Column="1"
Width="1200"
HorizontalAlignment="Right"
Panel.ZIndex="-1"
d:Visibility="Collapsed"
Visibility="Collapsed" />
</Grid>
</Border>
</Grid>
<buyerctrls:PDDBuyerSelectCtrl
x:Name="pddBuyerSelectCtrl"
Grid.Column="1"
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
d:Visibility="Visible"
Visibility="Collapsed" />
<Grid
x:Name="gridUser"
Grid.ColumnSpan="2"
Background="#7F000000"
Visibility="Hidden">
<Border
Width="500"
Height="600"
Background="White"
CornerRadius="4">
<shopctrls:ShopListCtrl
x:Name="shopListCtrl"
Grid.ColumnSpan="2"
Margin="2"
Visibility="{Binding ElementName=gridUser, Mode=TwoWay, Path=Visibility}" />
</Border>
</Grid>
</Grid>
</Grid>
<buyerctrls:PDDBuyerSelectCtrl
x:Name="pddBuyerSelectCtrl"
Grid.Column="1"
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
d:Visibility="Visible"
Visibility="Collapsed" />
<Grid
x:Name="gridUser"
Grid.ColumnSpan="2"
Background="#7F000000"
Visibility="Hidden">
<Border
Width="500"
Height="600"
Background="White"
CornerRadius="4">
<shopctrls:ShopListCtrl
x:Name="shopListCtrl"
Grid.ColumnSpan="2"
Margin="2"
Visibility="{Binding ElementName=gridUser, Mode=TwoWay, Path=Visibility}" />
</Border>
</Grid>
</Grid>
<Border
x:Name="borderMessage"
Grid.Row="1"
Width="auto"
Height="auto"
MinWidth="120"
MinHeight="2"
MaxWidth="1200"
Margin="10,50"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Panel.ZIndex="1000000"
Background="White"
BorderBrush="{StaticResource pageColorBrush}"
BorderThickness="1"
CornerRadius="6"
IsHitTestVisible="False"
Opacity="0">
<Border.Effect>
<DropShadowEffect
BlurRadius="40"
Opacity="0.2"
ShadowDepth="5"
Color="#FF98638f" />
</Border.Effect>
<TextBlock
x:Name="tbMessage"
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="这里是默认提示信息"
TextWrapping="Wrap" />
</Border>
<!--<Image x:Name="imageBig" HorizontalAlignment="Left" Height="800" Width="800" VerticalAlignment="Center" Grid.Row="1" Margin="200,0,0,0"/>-->
</Grid>
<Border
x:Name="borderMessage"
Grid.Row="1"
Width="auto"
Height="auto"
MinWidth="120"
MinHeight="2"
MaxWidth="1200"
Margin="10,50"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Panel.ZIndex="1000000"
Background="White"
BorderBrush="{StaticResource pageColorBrush}"
BorderThickness="1"
CornerRadius="6"
IsHitTestVisible="False"
Opacity="0">
<Border.Effect>
<DropShadowEffect
BlurRadius="40"
Opacity="0.2"
ShadowDepth="5"
Color="#FF98638f" />
</Border.Effect>
<TextBlock
x:Name="tbMessage"
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="这里是默认提示信息"
TextWrapping="Wrap" />
</Border>
<!--<Image x:Name="imageBig" HorizontalAlignment="Left" Height="800" Width="800" VerticalAlignment="Center" Grid.Row="1" Margin="200,0,0,0"/>-->
</Grid>
</basewindows:BaseWindow>
+468 -300
View File
@@ -14,6 +14,9 @@ using CefSharp;
using NaiBa.Util;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using OrderSupportTicket.Models;
using OrderSupportTicket.Services;
using OrderSupportTicket.Views;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -41,249 +44,261 @@ using System.Xml.Linq;
using Work;
using Work._29Tools.BLL;
using Work._29Tools.Forms.UserForms;
using WxOrder.Framework.Commons;
using WxOrder.Framework.Commons.Dialogs;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace _29WxOrderWpf
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : BaseWindow, INotifyPropertyChanged
{
public static MainWindow Instance { get; private set; }
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : BaseWindow, INotifyPropertyChanged
{
public static MainWindow Instance { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
public string Balance { get { return "快递余额:" + BaseClass.Balance.ToString("0.00"); } set { OnPropertyChanged("Balance"); } }
private readonly TicketRealtimeMonitor _ticketMonitor = TicketRealtimeMonitor.Current;
private TicketClientOptions _ticketOptions;
private OrderSupportTicketView _orderSupportView;
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
Instance = this;
public event PropertyChangedEventHandler PropertyChanged;
public string Balance { get { return "快递余额:" + BaseClass.Balance.ToString("0.00"); } set { OnPropertyChanged("Balance"); } }
gridUser.Visibility = Visibility.Collapsed;
}
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
Instance = this;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
GlobalConfig.Dispatcher = this.Dispatcher;
lblDebug.Visibility = Visibility.Collapsed;
gridUser.Visibility = Visibility.Collapsed;
ucWindowBox.SetWindowMax();
this.Title = BaseClass.ToolName;
_ticketMonitor.NewMessageReceived += OnTicketNewMessageReceived;
_ticketMonitor.UnreadCountChanged += OnTicketUnreadCountChanged;
Closed += MainWindow_Closed;
}
new Thread(AutoAntiGrabbingMechanism).Start(); // 反抓包
private void Window_Loaded(object sender, RoutedEventArgs e)
{
GlobalConfig.Dispatcher = this.Dispatcher;
lblDebug.Visibility = Visibility.Collapsed;
#region 弹出登录窗口
LoginWindow loginWindow = new LoginWindow(App.args);
loginWindow.Owner = this;
loginWindow.ShowDialog();
#endregion
ucWindowBox.SetWindowMax();
this.Title = BaseClass.ToolName;
if (loginWindow.IsLogin)
{
lblVersion.Content = BaseClass.ToolName + " V" + BaseClass.Varsion + " - " + BaseClass.NickName;
new Thread(AutoAntiGrabbingMechanism).Start(); // 反抓包
//shopListCtrl.Visibility = Visibility.Visible;
orderListCtrl.Visibility = Visibility.Visible;
#region 弹出登录窗口
LoginWindow loginWindow = new LoginWindow(App.args);
loginWindow.Owner = this;
loginWindow.ShowDialog();
#endregion
if (loginWindow.IsLogin)
{
lblVersion.Content = BaseClass.ToolName + " V" + BaseClass.Varsion + " - " + BaseClass.NickName;
//shopListCtrl.Visibility = Visibility.Visible;
orderListCtrl.Visibility = Visibility.Visible;
pddBuyerOrderReadCtrl.Visibility = Visibility.Visible;
tbBuyerOrderReadCtrl.Visibility = Visibility.Visible;
pddBuyerSelectCtrl.Visibility = Visibility.Visible;
Task.Run(() =>
{
GetServerShop();
Task.Run(() =>
{
GetServerShop();
StartTicketRealtimeMonitor();//启动工单监控
GetShopSupplier(GlobalConfig.ShopLoginList.ToList());
});
Task.Run(() =>
{
GetPddBuyer();
Task.Run(() =>
{
GetPddBuyer();
GetTaobaoBuyer();
});
}
}
protected virtual void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)//有改变
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
protected virtual void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)//有改变
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#region 反抓包功能
private void AutoAntiGrabbingMechanism()
{
while (true)
{
#region 反抓包功能
private void AutoAntiGrabbingMechanism()
{
while (true)
{
#if DEBUG
#else
AntiGrabbingMechanism();
#endif
try { Thread.Sleep(3000); } catch { }
}
}
try { Thread.Sleep(3000); } catch { }
}
}
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
private List<string> _AntiProcesses = "WINRAR,WIRESHARK,FIDDLER,HTTPDEBUGGERPRO,IEHTTPANALYZER,CHARLES,HTTPWATCH,SMARTSNIFF,MINISNIFFER,PROXIFIER,HTTP ANALYZER,SNIFFER,WSOCKEXPERT,IPANALYSE,ANALYZER,HTTP ANALYZER STAND-ALONE EDITION".Split(',').ToList();
private void AntiGrabbingMechanism()
{
//Gate 1 - Anti Proxy
if (IsUseSystemProxy())
{
LockUserAndKillProcess();
}
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
private List<string> _AntiProcesses = "WINRAR,WIRESHARK,FIDDLER,HTTPDEBUGGERPRO,IEHTTPANALYZER,CHARLES,HTTPWATCH,SMARTSNIFF,MINISNIFFER,PROXIFIER,HTTP ANALYZER,SNIFFER,WSOCKEXPERT,IPANALYSE,ANALYZER,HTTP ANALYZER STAND-ALONE EDITION".Split(',').ToList();
private void AntiGrabbingMechanism()
{
//Gate 1 - Anti Proxy
if (IsUseSystemProxy())
{
LockUserAndKillProcess();
}
//Gate 2 - Anti Special Processes
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process process in processList)
{
try
{
if (_AntiProcesses.Contains(process.ProcessName.ToUpper()))
{
process.Kill();
LockUserAndKillProcess();
}
//Gate 2 - Anti Special Processes
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process process in processList)
{
try
{
if (_AntiProcesses.Contains(process.ProcessName.ToUpper()))
{
process.Kill();
LockUserAndKillProcess();
}
if (process.MainWindowTitle.Contains("正在捕获"))
{
process.Kill();
LockUserAndKillProcess();
}
if (process.MainWindowTitle.Contains("正在捕获"))
{
process.Kill();
LockUserAndKillProcess();
}
if (!IsWin23App(process))
{
continue;
}
if (process.MainModule?.FileVersionInfo.FileDescription != null)
{
foreach (string antiProcess in _AntiProcesses)
{
if (process.MainModule.FileVersionInfo.FileDescription.ToUpper().Contains(antiProcess))
{
process.Kill();
LockUserAndKillProcess();
}
}
}
}
catch (Exception e)
{
}
}
}
if (!IsWin23App(process))
{
continue;
}
if (process.MainModule?.FileVersionInfo.FileDescription != null)
{
foreach (string antiProcess in _AntiProcesses)
{
if (process.MainModule.FileVersionInfo.FileDescription.ToUpper().Contains(antiProcess))
{
process.Kill();
LockUserAndKillProcess();
}
}
}
}
catch (Exception e)
{
}
}
}
private void LockUserAndKillProcess()
{
string url = BaseClass.BuildObjString("user&act=add_user_lock");
string data = UserLogin.GetSignaturex("", "");
string html = GetHtml.PostUtf8(url, data);
Process.GetCurrentProcess().Kill();
}
public static bool IsUseSystemProxy()
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
IWebProxy systemWebProxy = WebRequest.GetSystemWebProxy();
FieldInfo field1 = systemWebProxy.GetType().GetField("webProxy", bindingAttr);
if (field1 != (FieldInfo)null)
{
WebProxy webProxy = field1.GetValue((object)systemWebProxy) as WebProxy;
FieldInfo field2 = webProxy.GetType().GetField("_ProxyHostAddresses", bindingAttr);
if (field2 != (FieldInfo)null)
{
Hashtable hashtable = field2.GetValue((object)webProxy) as Hashtable;
if (hashtable != null && hashtable.Count > 0)
return true;
}
}
return false;
}
private void LockUserAndKillProcess()
{
string url = BaseClass.BuildObjString("user&act=add_user_lock");
string data = UserLogin.GetSignaturex("", "");
string html = GetHtml.PostUtf8(url, data);
Process.GetCurrentProcess().Kill();
}
public static bool IsUseSystemProxy()
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
IWebProxy systemWebProxy = WebRequest.GetSystemWebProxy();
FieldInfo field1 = systemWebProxy.GetType().GetField("webProxy", bindingAttr);
if (field1 != (FieldInfo)null)
{
WebProxy webProxy = field1.GetValue((object)systemWebProxy) as WebProxy;
FieldInfo field2 = webProxy.GetType().GetField("_ProxyHostAddresses", bindingAttr);
if (field2 != (FieldInfo)null)
{
Hashtable hashtable = field2.GetValue((object)webProxy) as Hashtable;
if (hashtable != null && hashtable.Count > 0)
return true;
}
}
return false;
}
public bool IsWin23App(Process process)
{
if (Environment.Is64BitOperatingSystem)
{
IntPtr processHandle;
bool retVal;
public bool IsWin23App(Process process)
{
if (Environment.Is64BitOperatingSystem)
{
IntPtr processHandle;
bool retVal;
try
{
processHandle = Process.GetProcessById(process.Id).Handle;
}
catch
{
return false;
}
return IsWow64Process(processHandle, out retVal) && retVal;
}
return true;
}
#endregion
try
{
processHandle = Process.GetProcessById(process.Id).Handle;
}
catch
{
return false;
}
return IsWow64Process(processHandle, out retVal) && retVal;
}
return true;
}
#endregion
private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (BaseMsgWindow.ShowConfirm("是否关闭软件?", "退出微信小店订单管理").DialogResult == true)
Process.GetCurrentProcess().Kill();
else
e.Cancel = true;
}
private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (BaseMsgWindow.ShowConfirm("是否关闭软件?", "退出微信小店订单管理").DialogResult == true)
Process.GetCurrentProcess().Kill();
else
e.Cancel = true;
}
#region 读取微信店铺
public bool isReadShop { get; set; } = false;
public bool hasReadShop { get; set; } = false;
public void GetServerShop()
{
if (isReadShop)
return;
#region 读取微信店铺
public bool isReadShop { get; set; } = false;
public bool hasReadShop { get; set; } = false;
public void GetServerShop()
{
if (isReadShop)
return;
var tList = new ConcurrentList<Task>();
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
Dispatcher.Invoke(new Action(() =>
{
}));
isReadShop = true;
int page = 0;
while (true)
{
page++;
var url = BaseClass.Build29WxObjString("shop/get_shop_list");
var data = UserLogin.GetSignaturex() + "&page=" + page;
data += "&is_get_erp_shop_id=true";
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("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
{
break;
}
var tList = new ConcurrentList<Task>();
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
Dispatcher.Invoke(new Action(() =>
{
}));
isReadShop = true;
int page = 0;
while (true)
{
page++;
var url = BaseClass.Build29WxObjString("shop/get_shop_list");
var data = UserLogin.GetSignaturex() + "&page=" + page;
data += "&is_get_erp_shop_id=true";
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("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
{
break;
}
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() == 0)
break;
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() == 0)
break;
foreach (JObject jObj in jArr)
{
var shop = ShopBLL.DeserializationShop(jObj);
foreach (JObject jObj in jArr)
{
var shop = ShopBLL.DeserializationShop(jObj);
var shopExist = list.LastOrDefault(l => l.ShopId == shop.ShopId);
while (shopExist != null)
{
shop.Is29Supplier = shopExist.Is29Supplier;
shop.IsSelect = shopExist.IsSelect;
shop.IsFilter = shopExist.IsFilter;
list.Remove(shopExist);
var shopExist = list.LastOrDefault(l => l.ShopId == shop.ShopId);
while (shopExist != null)
{
shop.Is29Supplier = shopExist.Is29Supplier;
shop.IsSelect = shopExist.IsSelect;
shop.IsFilter = shopExist.IsFilter;
list.Remove(shopExist);
shopExist = list.LastOrDefault(l => l.ShopId == shop.ShopId);
}
list.Add(shop);
list.Add(shop);
if (!GlobalConfig.ShopLoginList.Any(s => s.ShopId == shop.ShopId && !shop.is_point_shop_expire))
{
Dispatcher.Invoke(new Action(() =>
{
GlobalConfig.ShopLoginList.Add(shop);
}));
if (!GlobalConfig.ShopLoginList.Any(s => s.ShopId == shop.ShopId && !shop.is_point_shop_expire))
{
Dispatcher.Invoke(new Action(() =>
{
GlobalConfig.ShopLoginList.Add(shop);
}));
Task.Run(() =>
{
@@ -332,27 +347,27 @@ namespace _29WxOrderWpf
}));
});
}
}
}
Dispatcher.Invoke(new Action(() =>
{
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => !list.Any(ss => ss.ShopId == s.ShopId)).ToList())
{
GlobalConfig.ShopLoginList.Remove(shop);
}
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => s.is_point_shop_expire).ToList())
{
GlobalConfig.ShopLoginList.Remove(shop);
}
}));
isReadShop = false;
hasReadShop = true;
}
}
Dispatcher.Invoke(new Action(() =>
{
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => !list.Any(ss => ss.ShopId == s.ShopId)).ToList())
{
GlobalConfig.ShopLoginList.Remove(shop);
}
foreach (var shop in GlobalConfig.ShopLoginList.Where(s => s.is_point_shop_expire).ToList())
{
GlobalConfig.ShopLoginList.Remove(shop);
}
}));
isReadShop = false;
hasReadShop = true;
while (tList.Where(ta => !ta.IsFaulted && !ta.IsCompleted).Count() >= 1)
{
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCompleted || ta.IsCanceled); Thread.Sleep(100);
}
}
}
public void GetShopSupplier(List<ShopLoginInfo> shops)
{
@@ -369,7 +384,7 @@ namespace _29WxOrderWpf
var jArr = JsonHelper.JObjectParse(rst)["list"] as JArray;
// appid "wx7809625286c28f2f" name "百川日用";
if (jArr.Any(aa => aa["appid"].ParseToString() == "wx7809625286c28f2f" && aa["status"].ParseToInt() == 1))
//if (rst.Contains("wx7809625286c28f2f") || rst.Contains("百川日用"))
//if (rst.Contains("wx7809625286c28f2f") || rst.Contains("百川日用"))
continue;
rst = new WxApiBLL().SetShopSupplier(shop, "wx7809625286c28f2f", "4431685489938137094");
@@ -380,7 +395,7 @@ namespace _29WxOrderWpf
}
catch
{ }
}
}
}
#endregion
@@ -392,83 +407,83 @@ namespace _29WxOrderWpf
/// 读取拼多多买手
/// </summary>
public void GetPddBuyer()
{
if (isGetPddBuyer)
return;
{
if (isGetPddBuyer)
return;
isGetPddBuyer = true;
//var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
//Invoke(new Action(() => { pbLoading.Visible = true; }));
isGetPddBuyer = true;
//var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
//Invoke(new Action(() => { pbLoading.Visible = true; }));
try
{
var url = BaseClass.Build29PDDObjString("user/get_buyer");
var data = UserLogin.GetSignaturex();
data += "&page_size=200";
try
{
var url = BaseClass.Build29PDDObjString("user/get_buyer");
var data = UserLogin.GetSignaturex();
data += "&page_size=200";
var result = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
result = GetHtml.PostUtf8(url, data);
var result = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
result = GetHtml.PostUtf8(url, data);
if (result.Contains("\"code\":200"))
{
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
foreach (var buyer in GlobalConfig.PDDBuyerLoginList.Where(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id)).ToList())
{
Dispatcher.Invoke(new Action(() => { GlobalConfig.PDDBuyerLoginList.Remove(buyer); }));
}
if (result.Contains("\"code\":200"))
{
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
foreach (var b in loginInfoLst)
{
Dispatcher.Invoke(new Action(() =>
{
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
if (buyer == null)
GlobalConfig.PDDBuyerLoginList.Add(b);
else
{
buyer.add_time = b.add_time;
buyer.buyer_id = b.buyer_id;
buyer.buyer_name = b.buyer_name;
buyer.buyer_nick = b.buyer_nick;
buyer.cookie = b.cookie;
buyer.mdy_time = b.mdy_time;
buyer.notes = b.notes;
buyer.status = b.status;
buyer.user_name = b.user_name;
}
}));
}
foreach (var buyer in GlobalConfig.PDDBuyerLoginList.Where(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id)).ToList())
{
Dispatcher.Invoke(new Action(() => { GlobalConfig.PDDBuyerLoginList.Remove(buyer); }));
}
//Invoke(new Action(() =>
//{
//dgvBuyer.Rows.Clear();
//cmbBuyer.Items.Clear();
//}));
foreach (var b in loginInfoLst)
{
Dispatcher.Invoke(new Action(() =>
{
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
if (buyer == null)
GlobalConfig.PDDBuyerLoginList.Add(b);
else
{
buyer.add_time = b.add_time;
buyer.buyer_id = b.buyer_id;
buyer.buyer_name = b.buyer_name;
buyer.buyer_nick = b.buyer_nick;
buyer.cookie = b.cookie;
buyer.mdy_time = b.mdy_time;
buyer.notes = b.notes;
buyer.status = b.status;
buyer.user_name = b.user_name;
}
}));
}
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
//Invoke(new Action(() =>
//{
//BindBuyer(buyer, "", ids);
//cmbBuyer.Items.Add(buyer.buyer_nick);
//}));
}
}
}
catch
{
}
//Invoke(new Action(() =>
//{
//dgvBuyer.Rows.Clear();
//cmbBuyer.Items.Clear();
//}));
//Invoke(new Action(() =>
//{
// pbLoading.Visible = false;
//}));
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
{
//Invoke(new Action(() =>
//{
//BindBuyer(buyer, "", ids);
//cmbBuyer.Items.Add(buyer.buyer_nick);
//}));
}
}
}
catch
{
}
isGetPddBuyer = false;
hasGetPddBuyer = true;
}
//Invoke(new Action(() =>
//{
// pbLoading.Visible = false;
//}));
isGetPddBuyer = false;
hasGetPddBuyer = true;
}
#endregion
#region 读取拼多多买手号
@@ -537,18 +552,18 @@ namespace _29WxOrderWpf
#endregion
private void lblBalance_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
WXGetBalanceQrCodeForm balanceQrCodeForm = new WXGetBalanceQrCodeForm(StartUp.UpdateBalance);
balanceQrCodeForm.ShowDialog();
}
{
WXGetBalanceQrCodeForm balanceQrCodeForm = new WXGetBalanceQrCodeForm(StartUp.UpdateBalance);
balanceQrCodeForm.ShowDialog();
}
private void gridPddBuyerOrderReadCtrl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//if (Panel.GetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl) < 1)
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, 1);
//else
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
}
private void gridPddBuyerOrderReadCtrl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//if (Panel.GetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl) < 1)
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, 1);
//else
// Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
}
private void gridTitle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
@@ -571,5 +586,158 @@ namespace _29WxOrderWpf
view.ShowDialog();
}
}
private void bt_showOrderSupport(object sender, RoutedEventArgs e)
{
OpenOrderSupportTicket(_ticketMonitor.LatestNotification);
_ticketMonitor.MarkAllRead();
}
private void StartTicketRealtimeMonitor()
{
try
{
_ticketMonitor.Start(GetTicketOptions().Clone());
UpdateOrderSupportBadge();
}
catch (Exception ex)
{
LogSave.Add("TicketRealtimeStartError:" + ex);
}
}
private TicketClientOptions GetTicketOptions()
{
if (_ticketOptions != null)
return _ticketOptions;
_ticketOptions = new TicketClientOptions
{
UserName = BaseClass.UserName,
AppIds = GlobalConfig.ShopLoginList.Select(a=>a.ShopId).ToList(),
Orders = []
};
//OrderSupportTicketView
// .CreateDefaultOptions(BaseClass.UserName)
// .Clone();
return _ticketOptions;
}
private void OpenOrderSupportTicket(TicketRealtimeNotification notification)
{
var view = EnsureOrderSupportView();
view.ViewModel.ShowHistory();
if (notification != null)
{
view.OpenTicket(
notification.AppId,
notification.WechatOrderId);
}
// DialogService 会复用同类型的已打开窗口,避免重复创建。
DialogService.ShowOrActivateWindow(view);
}
/// <summary>
/// 从订单行打开工单页面。若左侧列表已有相同订单号的工单,直接定位到该工单;
/// 否则在同一个工单页面中进入新建工单状态。
/// </summary>
public async Task CreateOrderSupportTicketAsync(TicketOrderOption order)
{
if (order == null)
return;
var view = EnsureOrderSupportView();
await view.ViewModel.InitializeAsync();
var existing = view.ViewModel.FindTicketByOrderId(order.OrderId);
if (existing != null)
{
view.ViewModel.ApplyOrderInfo(order);
view.OpenTicket(existing.AppId, existing.WechatOrderId);
}
else
{
view.OpenNewTicket(order);
}
DialogService.ShowOrActivateWindow(view);
}
private OrderSupportTicketView EnsureOrderSupportView()
{
if (_orderSupportView == null)
{
_orderSupportView = new OrderSupportTicketView(
new TicketApiService(),
_ticketMonitor.RealtimeService,
GetTicketOptions().Clone(),
ownsRealtime: false);
}
return _orderSupportView;
}
private void OnTicketNewMessageReceived(
object sender,
TicketInboxMessageEventArgs e)
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.BeginInvoke(new Action(
() => OnTicketNewMessageReceived(sender, e)));
return;
}
var notification = e?.Notification;
if (notification == null)
return;
UpdateOrderSupportBadge();
}
private void OnTicketUnreadCountChanged(
object sender,
TicketUnreadCountChangedEventArgs e)
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.BeginInvoke(new Action(
() => OnTicketUnreadCountChanged(sender, e)));
return;
}
UpdateOrderSupportBadge(e?.UnreadCount ?? 0);
}
private void UpdateOrderSupportBadge()
{
UpdateOrderSupportBadge(_ticketMonitor.UnreadCount);
}
private void UpdateOrderSupportBadge(int unreadCount)
{
if (borderOrderSupportUnread == null)
return;
borderOrderSupportUnread.Visibility = unreadCount > 0
? Visibility.Visible
: Visibility.Collapsed;
tbOrderSupportUnread.Text = unreadCount > 99
? "99+"
: unreadCount.ToString();
btOrderSupport.ToolTip = unreadCount > 0
? $"客户工单({unreadCount} 条未读消息)"
: "客户工单";
}
private void MainWindow_Closed(object sender, EventArgs e)
{
_ticketMonitor.NewMessageReceived -= OnTicketNewMessageReceived;
_ticketMonitor.UnreadCountChanged -= OnTicketUnreadCountChanged;
}
}
}
@@ -1,14 +0,0 @@
<Window
x:Class="_29WxOrderWpf.OrderSupportTicketWindow"
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:local="clr-namespace:_29WxOrderWpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ost="clr-namespace:OrderSupportTicket.Views;assembly=OrderSupportTicket"
Title="OrderSupportTicketWindow"
Width="800"
Height="650"
mc:Ignorable="d">
<ost:OrderSupportTicketView />
</Window>
@@ -1,26 +0,0 @@
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.Shapes;
namespace _29WxOrderWpf;
/// <summary>
/// OrderSupportTicketWindow.xaml 的交互逻辑
/// </summary>
public partial class OrderSupportTicketWindow : Window
{
public OrderSupportTicketWindow()
{
InitializeComponent();
}
}
-168
View File
@@ -1,168 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
namespace _29WxOrderWpf.ToolCtrls;
public enum ToastType { Info, Success, Warning, Error }
/// <summary>
/// 在指定 Window 内显示自动消失的提示框(Toast)
/// 用法:ToastHelper.Show(window, "保存成功", ToastType.Success);
/// </summary>
public static class ToastHelper
{
// 每个 Window 对应一个提示容器,用于多个提示堆叠
private static readonly ConditionalWeakTable<Window, ToastAdorner> Hosts = new();
private static SolidColorBrush msgBrush;
static ToastHelper()
{
msgBrush = Application.Current.Resources["pageColorBrush"] as SolidColorBrush;
msgBrush = Application.Current.Resources["pageColorBrush"] as SolidColorBrush;
}
/// <param name="owner">要展示提示的窗口</param>
/// <param name="message">提示内容</param>
/// <param name="type">类型(决定背景色)</param>
/// <param name="durationMs">停留时长(毫秒,不含淡入淡出)</param>
public static void Show(Window owner, string message,
ToastType type = ToastType.Info, int durationMs = 2000)
{
if (owner == null || string.IsNullOrEmpty(message)) return;
// 允许在非 UI 线程调用
if (!owner.Dispatcher.CheckAccess())
{
owner.Dispatcher.BeginInvoke(new Action(() => Show(owner, message, type, durationMs)));
return;
}
// 窗口还没加载完,等加载后再显示
if (!owner.IsLoaded)
{
RoutedEventHandler handler = null;
handler = (s, e) =>
{
owner.Loaded -= handler;
Show(owner, message, type, durationMs);
};
owner.Loaded += handler;
return;
}
if (owner.Content is not UIElement content) return;
var layer = AdornerLayer.GetAdornerLayer(content);
if (layer == null) return;
if (!Hosts.TryGetValue(owner, out var host))
{
host = new ToastAdorner(content);
layer.Add(host);
Hosts.Add(owner, host);
}
var toast = CreateToast(message, type);
host.Panel.Children.Add(toast);
// 淡入 -> 停留 -> 淡出
var fadeIn = TimeSpan.FromMilliseconds(250);
var fadeOut = TimeSpan.FromMilliseconds(400);
var hold = TimeSpan.FromMilliseconds(Math.Max(durationMs, 0));
var anim = new DoubleAnimationUsingKeyFrames();
anim.KeyFrames.Add(new LinearDoubleKeyFrame(0, TimeSpan.Zero));
anim.KeyFrames.Add(new LinearDoubleKeyFrame(1, fadeIn));
anim.KeyFrames.Add(new LinearDoubleKeyFrame(1, fadeIn + hold));
anim.KeyFrames.Add(new LinearDoubleKeyFrame(0, fadeIn + hold + fadeOut));
anim.Completed += (s, e) =>
{
host.Panel.Children.Remove(toast);
if (host.Panel.Children.Count == 0)
{
layer.Remove(host);
Hosts.Remove(owner);
}
};
toast.BeginAnimation(UIElement.OpacityProperty, anim);
}
public static void Show(string message,
ToastType type = ToastType.Info, int durationMs = 2000)
{
Window window = Application.Current.Windows
.OfType<Window>()
.FirstOrDefault(w => w.IsActive) ?? Application.Current.MainWindow;
Show(window, message, type, durationMs);
}
private static Border CreateToast(string message, ToastType type)
{
var color = type switch
{
ToastType.Success => Color.FromRgb(0x2E, 0x9E, 0x5B),
ToastType.Warning => Color.FromRgb(0xE6, 0x9A, 0x1A),
ToastType.Error => Color.FromRgb(0xD9, 0x4A, 0x4A),
_ => msgBrush.Color,//Color.FromRgb(0x40, 0x40, 0x40),
};
return new Border
{
Background = new SolidColorBrush(color),
CornerRadius = new CornerRadius(6),
Padding = new Thickness(18, 10, 18, 10),
Margin = new Thickness(0, 0, 0, 8),
Opacity = 0,
MaxWidth = 480,
Effect = new DropShadowEffect
{
BlurRadius = 12,
ShadowDepth = 2,
Opacity = 0.3,
Color = Colors.Black
},
Child = new TextBlock
{
Text = message,
Foreground = Brushes.White,
FontSize = 14,
TextWrapping = TextWrapping.Wrap
}
};
}
/// <summary>覆盖在窗口内容上方的提示容器,顶部居中</summary>
private sealed class ToastAdorner : Adorner
{
public StackPanel Panel { get; }
public ToastAdorner(UIElement adornedElement) : base(adornedElement)
{
IsHitTestVisible = false; // 不拦截鼠标事件
Panel = new StackPanel { Orientation = Orientation.Vertical };
AddVisualChild(Panel);
}
protected override int VisualChildrenCount => 1;
protected override Visual GetVisualChild(int index) => Panel;
protected override Size MeasureOverride(Size constraint)
{
Panel.Measure(constraint);
return AdornedElement.RenderSize;
}
protected override Size ArrangeOverride(Size finalSize)
{
var size = Panel.DesiredSize;
double x = (finalSize.Width - size.Width) / 2;
Panel.Arrange(new Rect(new Point(Math.Max(x, 0), 30), size)); // 距顶部 30
return finalSize;
}
}
}