淘宝买手登录 70%
This commit is contained in:
1 parent
97278249ae
commit
78ef8eedf3
10 files changed
+1117
-93
No files matched your search
@@ -1,49 +1,211 @@
|
|||||||
<UserControl x:Class="_29WxOrderWpf.Ctrls.BuyerCtrls.PDDBuyerSelectCtrl"
|
<UserControl
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
x:Class="_29WxOrderWpf.Ctrls.BuyerCtrls.PDDBuyerSelectCtrl"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:c="clr-namespace:_29WxOrderWpf.Common"
|
||||||
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.BuyerCtrls" xmlns:userctrls="clr-namespace:_29WxOrderWpf.UserControls"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d" Loaded="UserControl_Loaded"
|
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.BuyerCtrls"
|
||||||
d:DesignHeight="30" d:DesignWidth="300">
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
<Grid>
|
xmlns:userctrls="clr-namespace:_29WxOrderWpf.UserControls"
|
||||||
<Grid.ColumnDefinitions>
|
xmlns:wpf="WPFCommon"
|
||||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
d:DesignHeight="30"
|
||||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
d:DesignWidth="320"
|
||||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
Loaded="UserControl_Loaded"
|
||||||
</Grid.ColumnDefinitions>
|
mc:Ignorable="d">
|
||||||
<Image Margin="4,0,0,0" Width="24" Height="24" Source="{StaticResource imgBuyerOrder}" MouseLeftButtonUp="Image_MouseLeftButtonUp" Cursor="Hand"></Image>
|
<Grid Margin="0,0,0,-26">
|
||||||
<ComboBox Grid.Column="1" x:Name="cmbPddBuyer" Margin="8,0,0,0" VerticalContentAlignment="Center" Style="{StaticResource RoundedComboBox}" Height="24"
|
<Grid.ColumnDefinitions>
|
||||||
MouseLeftButtonUp="cmbPddBuyer_MouseLeftButtonUp" SelectionChanged="cmbPddBuyer_SelectionChanged" SelectedIndex="0">
|
<ColumnDefinition Width="auto" />
|
||||||
<ComboBox.ItemTemplate>
|
<ColumnDefinition Width="auto" />
|
||||||
<DataTemplate>
|
<ColumnDefinition Width="*" />
|
||||||
<!--<Grid HorizontalAlignment="Stretch" MinWidth="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}">-->
|
</Grid.ColumnDefinitions>
|
||||||
<Grid HorizontalAlignment="Stretch" MinWidth="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}},
|
<Image
|
||||||
Path=ActualWidth, Converter={StaticResource ValueMinus24Converter}}" Height="auto">
|
Width="24"
|
||||||
<Grid.ColumnDefinitions>
|
Height="24"
|
||||||
<ColumnDefinition Width="120*"></ColumnDefinition>
|
Margin="4,0,0,0"
|
||||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
Cursor="Hand"
|
||||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
MouseLeftButtonUp="Image_MouseLeftButtonUp"
|
||||||
</Grid.ColumnDefinitions>
|
Source="{StaticResource imgBuyerOrder}" />
|
||||||
<TextBlock x:Name="tbName" Text="{Binding buyer_nick}" VerticalAlignment="Center"/>
|
|
||||||
<userctrls:UcImageButton Width="15" Height="15" ButtonImage="{StaticResource imgCloseGray}" BorderThickness="0" Cursor="Hand" Grid.Column="0" Visibility="Collapsed"
|
|
||||||
MouseOverButtonImage="{StaticResource imgCloseGray}" MousePressButtonImage="{StaticResource imgCloseGray}" Background="Transparent"
|
|
||||||
x:Name="btnDeleteItem" Tag="{Binding ElementName=tbName, Path=Text}" HorizontalAlignment="Right" VerticalAlignment="Center"
|
<wpf:SpacingStackPanel
|
||||||
Click="btnDeleteItem_Click"/>
|
Grid.Column="1"
|
||||||
<TextBlock x:Name="tbStatus" Text="{Binding status}" Foreground="{Binding status, Converter={StaticResource statusToColorBrushConverter}}" Grid.Column="2"
|
VerticalAlignment="Center"
|
||||||
VerticalAlignment="Center"/>
|
Orientation="Vertical"
|
||||||
</Grid>
|
VerticalSpacing="2">
|
||||||
<DataTemplate.Triggers>
|
<WrapPanel x:Name="wpPddBuyer">
|
||||||
<Trigger Property="IsMouseOver" Value="True">
|
<ComboBox
|
||||||
<Setter TargetName="btnDeleteItem" Property="Visibility" Value="Visible"/>
|
x:Name="cmbPddBuyer"
|
||||||
</Trigger>
|
Grid.Column="1"
|
||||||
</DataTemplate.Triggers>
|
Width="180"
|
||||||
</DataTemplate>
|
Height="24"
|
||||||
</ComboBox.ItemTemplate>
|
Margin="0,0,0,0"
|
||||||
</ComboBox>
|
VerticalContentAlignment="Center"
|
||||||
<!--<TextBlock Text="选择买手" Grid.Column="12" Margin="12,0,0,0" VerticalAlignment="Center" IsHitTestVisible="False" Foreground="LightGray"
|
MouseLeftButtonUp="cmbPddBuyer_MouseLeftButtonUp"
|
||||||
Visibility="{Binding ElementName=cmbBuyer,Path=Text,Converter={StaticResource NotHasTextVisibility}}"></TextBlock>-->
|
SelectedIndex="0"
|
||||||
<Button Grid.Column="2" x:Name="btnLoginPdd" Style="{StaticResource BasePageButtonStyle}" Margin="4,0,0,0"
|
SelectionChanged="cmbPddBuyer_SelectionChanged"
|
||||||
Content="多多登录" Width="56" Height="24" Click="btnLoginPdd_Click"/>
|
Style="{StaticResource RoundedComboBox}">
|
||||||
</Grid>
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<!--<Grid HorizontalAlignment="Stretch" MinWidth="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}">-->
|
||||||
|
<Grid
|
||||||
|
Height="auto"
|
||||||
|
MinWidth="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}}, Path=ActualWidth, Converter={StaticResource ValueMinus24Converter}}"
|
||||||
|
HorizontalAlignment="Stretch">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120*" />
|
||||||
|
<ColumnDefinition Width="auto" />
|
||||||
|
<ColumnDefinition Width="auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
x:Name="tbName"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding buyer_nick}" />
|
||||||
|
<userctrls:UcImageButton
|
||||||
|
x:Name="btnDeleteItem"
|
||||||
|
Grid.Column="0"
|
||||||
|
Width="15"
|
||||||
|
Height="15"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
ButtonImage="{StaticResource imgCloseGray}"
|
||||||
|
Click="btnDeleteItem_Click"
|
||||||
|
Cursor="Hand"
|
||||||
|
MouseOverButtonImage="{StaticResource imgCloseGray}"
|
||||||
|
MousePressButtonImage="{StaticResource imgCloseGray}"
|
||||||
|
Tag="{Binding ElementName=tbName, Path=Text}"
|
||||||
|
Visibility="Collapsed" />
|
||||||
|
<TextBlock
|
||||||
|
x:Name="tbStatus"
|
||||||
|
Grid.Column="2"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{Binding status, Converter={StaticResource statusToColorBrushConverter}}"
|
||||||
|
Text="{Binding status}" />
|
||||||
|
</Grid>
|
||||||
|
<DataTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="btnDeleteItem" Property="Visibility" Value="Visible" />
|
||||||
|
</Trigger>
|
||||||
|
</DataTemplate.Triggers>
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
<!--<TextBlock Text="选择买手" Grid.Column="12" Margin="12,0,0,0" VerticalAlignment="Center" IsHitTestVisible="False" Foreground="LightGray"
|
||||||
|
Visibility="{Binding ElementName=cmbBuyer,Path=Text,Converter={StaticResource NotHasTextVisibility}}"></TextBlock>-->
|
||||||
|
<Button
|
||||||
|
x:Name="btnLoginPdd"
|
||||||
|
Grid.Column="2"
|
||||||
|
Width="56"
|
||||||
|
Height="24"
|
||||||
|
Margin="4,0,0,0"
|
||||||
|
Click="btnLoginPdd_Click"
|
||||||
|
Content="多多登录"
|
||||||
|
Style="{StaticResource BasePageButtonStyle}" />
|
||||||
|
</WrapPanel>
|
||||||
|
|
||||||
|
<WrapPanel
|
||||||
|
x:Name="wpTaobaoBuyer"
|
||||||
|
d:Visibility="Visible"
|
||||||
|
Visibility="Collapsed">
|
||||||
|
<ComboBox
|
||||||
|
x:Name="cmbTaobaoBuyer"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="180"
|
||||||
|
Height="24"
|
||||||
|
Margin="0,0,0,0"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
MouseLeftButtonUp="cmbTaobao_MouseLeftButtonUp"
|
||||||
|
SelectedIndex="0"
|
||||||
|
SelectionChanged="cmbTaobao_SelectionChanged"
|
||||||
|
Style="{StaticResource RoundedComboBox}">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<!--<Grid HorizontalAlignment="Stretch" MinWidth="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}">-->
|
||||||
|
<Grid
|
||||||
|
Height="auto"
|
||||||
|
MinWidth="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}}, Path=ActualWidth, Converter={StaticResource ValueMinus24Converter}}"
|
||||||
|
HorizontalAlignment="Stretch">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120*" />
|
||||||
|
<ColumnDefinition Width="auto" />
|
||||||
|
<ColumnDefinition Width="auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock
|
||||||
|
x:Name="tbName"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding buyer_nick}" />
|
||||||
|
<userctrls:UcImageButton
|
||||||
|
x:Name="btnDeleteItem"
|
||||||
|
Grid.Column="0"
|
||||||
|
Width="15"
|
||||||
|
Height="15"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
ButtonImage="{StaticResource imgCloseGray}"
|
||||||
|
Click="btnDeleteTaobaoItem_Click"
|
||||||
|
Cursor="Hand"
|
||||||
|
MouseOverButtonImage="{StaticResource imgCloseGray}"
|
||||||
|
MousePressButtonImage="{StaticResource imgCloseGray}"
|
||||||
|
Tag="{Binding ElementName=tbName, Path=Text}"
|
||||||
|
Visibility="Collapsed" />
|
||||||
|
<TextBlock
|
||||||
|
x:Name="tbStatus"
|
||||||
|
Grid.Column="2"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{Binding status, Converter={StaticResource statusToColorBrushConverter}}"
|
||||||
|
Text="{Binding status}" />
|
||||||
|
</Grid>
|
||||||
|
<DataTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="btnDeleteItem" Property="Visibility" Value="Visible" />
|
||||||
|
</Trigger>
|
||||||
|
</DataTemplate.Triggers>
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
<!--<TextBlock Text="选择买手" Grid.Column="12" Margin="12,0,0,0" VerticalAlignment="Center" IsHitTestVisible="False" Foreground="LightGray"
|
||||||
|
Visibility="{Binding ElementName=cmbBuyer,Path=Text,Converter={StaticResource NotHasTextVisibility}}"></TextBlock>-->
|
||||||
|
<Button
|
||||||
|
x:Name="btnLoginTaobao"
|
||||||
|
Grid.Column="2"
|
||||||
|
Width="56"
|
||||||
|
Height="24"
|
||||||
|
Margin="4,0,0,0"
|
||||||
|
Click="btnLoginTaobao_Click"
|
||||||
|
Content="淘宝登录"
|
||||||
|
Style="{StaticResource BasePageButtonStyle}" />
|
||||||
|
</WrapPanel>
|
||||||
|
</wpf:SpacingStackPanel>
|
||||||
|
<Button
|
||||||
|
x:Name="btnSwitch"
|
||||||
|
Grid.Column="2"
|
||||||
|
Width="24"
|
||||||
|
Height="24"
|
||||||
|
Margin="4,0,0,0"
|
||||||
|
Click="btnSwitch_Click"
|
||||||
|
Style="{StaticResource BasePageButtonStyle}">
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="0,0,0,1"
|
||||||
|
FontSize="18"
|
||||||
|
Foreground="{StaticResource mainColorLightBrush}"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
Style="{StaticResource TextBlockIcon}"
|
||||||
|
Text="{StaticResource txt-arrow_sync_circle}" />
|
||||||
|
</Button>
|
||||||
|
<!-- Text="{StaticResource txt-arrow_clockwise}" -->
|
||||||
|
<!--<Image
|
||||||
|
x:Name="切换"
|
||||||
|
Grid.Column="2"
|
||||||
|
Width="24"
|
||||||
|
Height="24"
|
||||||
|
Margin="4,0,0,0"
|
||||||
|
c:DebugVisibility.Enable="True"
|
||||||
|
Cursor="Hand"
|
||||||
|
Source="{StaticResource imgBuyerOrder}" />-->
|
||||||
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -40,6 +40,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
|||||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
cmbPddBuyer.ItemsSource = GlobalConfig.PDDBuyerLoginList;
|
cmbPddBuyer.ItemsSource = GlobalConfig.PDDBuyerLoginList;
|
||||||
|
cmbTaobaoBuyer.ItemsSource = GlobalConfig.TaobaoBuyerLoginList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnLoginPdd_Click(object sender, RoutedEventArgs e)
|
private void btnLoginPdd_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -145,48 +146,143 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//var pddBuyer =
|
|
||||||
|
|
||||||
//var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
|
||||||
//var buyers = GlobalConfig.PDDBuyerLoginList.Where(b => ids.Contains(b.buyer_id)).ToList();
|
|
||||||
//this.statusBar.pgbTaskProgress.Maximum = buyers.Count;
|
|
||||||
//pbLoading.Visible = true;
|
|
||||||
|
|
||||||
//Task.Run(() =>
|
|
||||||
//{
|
|
||||||
// int i = 0;
|
|
||||||
// foreach (var buyer in buyers)
|
|
||||||
// {
|
|
||||||
// i++;
|
|
||||||
// this.Invoke(new Action(() =>
|
|
||||||
// {
|
|
||||||
// this.statusBar.lblTaskStatus.Text = "正在删除...";
|
|
||||||
// this.statusBar.pgbTaskProgress.Value = i;
|
|
||||||
// this.statusBar.pgbTaskProgress.Text = i + "/" + buyers.Count;
|
|
||||||
// }));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Thread.Sleep(100);
|
|
||||||
// }
|
|
||||||
// this.Invoke(new Action(() =>
|
|
||||||
// {
|
|
||||||
// this.statusBar.lblTaskStatus.Text = "删除完成";
|
|
||||||
// this.statusBar.pgbTaskProgress.Value = buyers.Count;
|
|
||||||
// this.statusBar.pgbTaskProgress.Text = buyers.Count + "/" + buyers.Count;
|
|
||||||
// }));
|
|
||||||
// GetPddBuyer();
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (MainWindow.Instance.gridPddBuyerOrderReadCtrl.Visibility != Visibility.Visible)
|
if (wpPddBuyer.Visibility == Visibility.Visible)
|
||||||
MainWindow.Instance.gridPddBuyerOrderReadCtrl.Visibility = Visibility.Visible;
|
{
|
||||||
if (Panel.GetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl) < 1)
|
if (MainWindow.Instance.gridPddBuyerOrderReadCtrl.Visibility != Visibility.Visible)
|
||||||
Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, 1);
|
MainWindow.Instance.gridPddBuyerOrderReadCtrl.Visibility = Visibility.Visible;
|
||||||
|
if (Panel.GetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl) < 1)
|
||||||
|
Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, 1);
|
||||||
|
else
|
||||||
|
Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
|
Panel.SetZIndex(MainWindow.Instance.gridPddBuyerOrderReadCtrl, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSwitch_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (wpPddBuyer.Visibility == Visibility.Visible)
|
||||||
|
{
|
||||||
|
wpPddBuyer.Visibility = Visibility.Collapsed;
|
||||||
|
wpTaobaoBuyer.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wpPddBuyer.Visibility = Visibility.Visible;
|
||||||
|
wpTaobaoBuyer.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnLoginTaobao_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
BuyerLoginInfo buyer = null;
|
||||||
|
if (cmbTaobaoBuyer.SelectedItem != null)
|
||||||
|
{
|
||||||
|
buyer = cmbTaobaoBuyer.SelectedItem as BuyerLoginInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
TaobaoLoginView taobaoBuyerForm = new TaobaoLoginView(buyer);
|
||||||
|
taobaoBuyerForm.ViewModel.OpenType = EnumOpenType.login;
|
||||||
|
taobaoBuyerForm.ViewModel.InitUrl = "https://login.taobao.com/havanaone/login/login.htm";
|
||||||
|
new DialogWindow()
|
||||||
|
{
|
||||||
|
Title = "淘宝买手登录",
|
||||||
|
Content = taobaoBuyerForm,
|
||||||
|
}.ShowDialog();
|
||||||
|
|
||||||
|
MainWindow.Instance.GetTaobaoBuyer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cmbTaobao_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
BuyerLoginInfo buyer = null;
|
||||||
|
if (cmbTaobaoBuyer.SelectedItem != null)
|
||||||
|
{
|
||||||
|
buyer = cmbTaobaoBuyer.SelectedItem as BuyerLoginInfo;
|
||||||
|
}
|
||||||
|
GlobalConfig.CurrentTaobaoBuyer = buyer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cmbTaobao_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.GetPosition(sender as IInputElement).X > cmbTaobaoBuyer.ActualWidth - 18)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BuyerLoginInfo buyer = null;
|
||||||
|
if (cmbTaobaoBuyer.SelectedItem != null)
|
||||||
|
{
|
||||||
|
buyer = cmbTaobaoBuyer.SelectedItem as BuyerLoginInfo;
|
||||||
|
}
|
||||||
|
if (buyer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool islogin = false;
|
||||||
|
TaobaoLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo> { buyer }, false);
|
||||||
|
TaobaoLoginView buyerLoginForm = new TaobaoLoginView(buyer);
|
||||||
|
if (buyer.status == "在线")
|
||||||
|
{
|
||||||
|
buyerLoginForm.ViewModel.OpenType = EnumOpenType.manage;
|
||||||
|
buyerLoginForm.ViewModel.InitUrl = "https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm?";
|
||||||
|
|
||||||
|
new DialogWindow()
|
||||||
|
{
|
||||||
|
Width = 1280,
|
||||||
|
Height = 800,
|
||||||
|
Title = "买手主页",
|
||||||
|
Content = buyerLoginForm,
|
||||||
|
}.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buyerLoginForm.ViewModel.OpenType = EnumOpenType.login;
|
||||||
|
buyerLoginForm.ViewModel.InitUrl = "https://login.taobao.com/havanaone/login/login.htm";
|
||||||
|
|
||||||
|
new DialogWindow()
|
||||||
|
{
|
||||||
|
Width = 1280,
|
||||||
|
Height = 800,
|
||||||
|
Title = "买手登录",
|
||||||
|
Content = buyerLoginForm,
|
||||||
|
}.ShowDialog();
|
||||||
|
}
|
||||||
|
if (islogin)
|
||||||
|
MainWindow.Instance.GetTaobaoBuyer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnDeleteTaobaoItem_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (BaseMsgWindow.ShowConfirm("确定删除吗?删除后不可恢复!").DialogResult != true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sender is Button btn)
|
||||||
|
{
|
||||||
|
if (btn.DataContext is BuyerLoginInfo buyer)
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
var url = BaseClass.Build29WxObjString("user/del_taobao_buyer");
|
||||||
|
var data = UserLogin.GetSignaturex()
|
||||||
|
+ "&buyer_id=" + buyer.buyer_id;
|
||||||
|
var result = GetHtml.PostUtf8(url, data);
|
||||||
|
if (result.Contains("\"code\":200"))
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
GlobalConfig.TaobaoBuyerLoginList.Remove(buyer);
|
||||||
|
this.cmbPddBuyer.SelectedIndex = 0;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,10 +111,12 @@
|
|||||||
<orderctrls:OrderListCtrl
|
<orderctrls:OrderListCtrl
|
||||||
x:Name="orderListCtrl"
|
x:Name="orderListCtrl"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
|
d:Visibility="Visible"
|
||||||
Visibility="Collapsed" />
|
Visibility="Collapsed" />
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridPddBuyerOrderReadCtrl"
|
x:Name="gridPddBuyerOrderReadCtrl"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
|
d:Visibility="Visible"
|
||||||
Background="#7F000000"
|
Background="#7F000000"
|
||||||
MouseLeftButtonUp="gridPddBuyerOrderReadCtrl_MouseLeftButtonUp"
|
MouseLeftButtonUp="gridPddBuyerOrderReadCtrl_MouseLeftButtonUp"
|
||||||
Visibility="Hidden">
|
Visibility="Hidden">
|
||||||
@@ -130,16 +132,17 @@
|
|||||||
Width="1200"
|
Width="1200"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Panel.ZIndex="-1"
|
Panel.ZIndex="-1"
|
||||||
|
d:Visibility="Visible"
|
||||||
Visibility="Collapsed" />
|
Visibility="Collapsed" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
<buyerctrls:PDDBuyerSelectCtrl
|
<buyerctrls:PDDBuyerSelectCtrl
|
||||||
x:Name="pddBuyerSelectCtrl"
|
x:Name="pddBuyerSelectCtrl"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="280"
|
|
||||||
Margin="8"
|
Margin="8"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
|
d:Visibility="Visible"
|
||||||
Visibility="Collapsed" />
|
Visibility="Collapsed" />
|
||||||
<Grid
|
<Grid
|
||||||
x:Name="gridUser"
|
x:Name="gridUser"
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ namespace _29WxOrderWpf
|
|||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
GetPddBuyer();
|
GetPddBuyer();
|
||||||
});
|
GetTaobaoBuyer();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected virtual void OnPropertyChanged(string propertyName)
|
protected virtual void OnPropertyChanged(string propertyName)
|
||||||
@@ -435,9 +436,74 @@ namespace _29WxOrderWpf
|
|||||||
isGetPddBuyer = false;
|
isGetPddBuyer = false;
|
||||||
hasGetPddBuyer = true;
|
hasGetPddBuyer = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void lblBalance_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
#region 读取拼多多买手号
|
||||||
|
public bool isGetTaobaoBuyer = false;
|
||||||
|
public bool hasGetTaobaoBuyer = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取拼多多买手
|
||||||
|
/// </summary>
|
||||||
|
public void GetTaobaoBuyer()
|
||||||
|
{
|
||||||
|
if (isGetTaobaoBuyer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
isGetTaobaoBuyer = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = BaseClass.Build29WxObjString("user/get_taobao_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);
|
||||||
|
|
||||||
|
if (result.Contains("\"code\":200"))
|
||||||
|
{
|
||||||
|
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||||
|
|
||||||
|
foreach (var buyer in GlobalConfig.TaobaoBuyerLoginList.Where(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id)).ToList())
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(new Action(() => { GlobalConfig.TaobaoBuyerLoginList.Remove(buyer); }));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var b in loginInfoLst)
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
var buyer = GlobalConfig.TaobaoBuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
|
||||||
|
if (buyer == null)
|
||||||
|
GlobalConfig.TaobaoBuyerLoginList.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;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
isGetTaobaoBuyer = false;
|
||||||
|
hasGetTaobaoBuyer = true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private void lblBalance_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
WXGetBalanceQrCodeForm balanceQrCodeForm = new WXGetBalanceQrCodeForm(StartUp.UpdateBalance);
|
WXGetBalanceQrCodeForm balanceQrCodeForm = new WXGetBalanceQrCodeForm(StartUp.UpdateBalance);
|
||||||
balanceQrCodeForm.ShowDialog();
|
balanceQrCodeForm.ShowDialog();
|
||||||
|
|||||||
@@ -0,0 +1,562 @@
|
|||||||
|
using _29WxOrderWpf.CefHelper;
|
||||||
|
using _29WxOrderWpf.Commands;
|
||||||
|
using AllBase;
|
||||||
|
using AllBase.Helper;
|
||||||
|
using AllBase.Model.DBModel;
|
||||||
|
using AllBase.Model.MvvmBaseClasses;
|
||||||
|
using CefSharp;
|
||||||
|
using CefSharp.Handler;
|
||||||
|
using CefSharp.Wpf;
|
||||||
|
using NaiBa.Util.Extension;
|
||||||
|
using Org.BouncyCastle.Asn1.Ocsp;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Policy;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using TemuKJD.ToolForms;
|
||||||
|
using Work;
|
||||||
|
using Work._29Tools.BLL;
|
||||||
|
using Work._29Tools.CefTools;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||||
|
|
||||||
|
namespace _29WxOrderWpf.ViewModels
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拼多多买手移动版登录窗口 视图模型(WPF 版 TaobaoLoginForm)
|
||||||
|
/// </summary>
|
||||||
|
public class TaobaoLoginViewModel : PropertyNotifyObject
|
||||||
|
{
|
||||||
|
// 拼多多买手退货退款售后地址
|
||||||
|
// https://mobile.yangkeduo.com/complaint.html?order_sn=260718-101481213440980&after_sales_reason=0&after_sales_type=2&after_sales_code=1002
|
||||||
|
|
||||||
|
public static TaobaoLoginViewModel TaobaoLoginInstance { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>浏览器创建完成后触发(视图在此把浏览器加入可视树)</summary>
|
||||||
|
public event Action<ChromiumWebBrowser> BrowserCreated;
|
||||||
|
|
||||||
|
/// <summary>请求关闭窗口</summary>
|
||||||
|
public event Action RequestClose;
|
||||||
|
|
||||||
|
public int CloseAfterSecond { get; set; }
|
||||||
|
|
||||||
|
private EnumOpenType _openType = EnumOpenType.manage;
|
||||||
|
public EnumOpenType OpenType
|
||||||
|
{
|
||||||
|
get { return _openType; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_openType = value;
|
||||||
|
OnPropertyChanged(nameof(OpenType));
|
||||||
|
OnPropertyChanged(nameof(IsLoginMode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string InitUrl { get; set; } = "";
|
||||||
|
|
||||||
|
private string shopCookieHead = "taobao.com";
|
||||||
|
private string buyerLoginUrl = "https://login.taobao.com/havanaone/login/login.htm";
|
||||||
|
private string buyerMainUrl = "https://i.taobao.com/my_itaobao"; //"https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm?";
|
||||||
|
|
||||||
|
public ChromiumWebBrowser CefWebBrowser { get; private set; }
|
||||||
|
private BuyerLoginInfo buyer = null;
|
||||||
|
private List<ShopCompany> lstShopCompany = new List<ShopCompany>();
|
||||||
|
private string currentUrl = "";
|
||||||
|
private volatile bool _isWindowLoaded = false;
|
||||||
|
|
||||||
|
#region 界面绑定属性
|
||||||
|
|
||||||
|
/// <summary>用户名</summary>
|
||||||
|
public string UserName
|
||||||
|
{
|
||||||
|
get { return this.GetValue(x => x.UserName); }
|
||||||
|
set { this.SetValue(x => x.UserName, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>密码</summary>
|
||||||
|
public string PassWord
|
||||||
|
{
|
||||||
|
get { return this.GetValue(x => x.PassWord); }
|
||||||
|
set { this.SetValue(x => x.PassWord, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>地址栏</summary>
|
||||||
|
public string Address
|
||||||
|
{
|
||||||
|
get { return this.GetValue(x => x.Address); }
|
||||||
|
set { this.SetValue(x => x.Address, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>登录成功后关闭窗口</summary>
|
||||||
|
public bool IsCloseAfterLogin
|
||||||
|
{
|
||||||
|
get { return this.GetValue(x => x.IsCloseAfterLogin); }
|
||||||
|
set { this.SetValue(x => x.IsCloseAfterLogin, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>登录模式</summary>
|
||||||
|
public bool IsLoginMode
|
||||||
|
{
|
||||||
|
get { return this.GetValue(x => x.IsLoginMode); }
|
||||||
|
set { this.SetValue(x => x.IsLoginMode, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 命令
|
||||||
|
|
||||||
|
public ICommand ReloadCommand { get; }
|
||||||
|
public ICommand LoginAgainCommand { get; }
|
||||||
|
public ICommand StopCommand { get; }
|
||||||
|
public ICommand CopyUserNameCommand { get; }
|
||||||
|
public ICommand CopyPasswordCommand { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public TaobaoLoginViewModel(BuyerLoginInfo buyerInfo)
|
||||||
|
{
|
||||||
|
TaobaoLoginInstance = this;
|
||||||
|
|
||||||
|
buyer = buyerInfo;
|
||||||
|
UserName = buyerInfo?.buyer_name;
|
||||||
|
PassWord = ""; //DataOpenSSL.DecryptString(buyerInfo.Password);
|
||||||
|
IsCloseAfterLogin = true;
|
||||||
|
IsLoginMode = OpenType == EnumOpenType.login;
|
||||||
|
|
||||||
|
ReloadCommand = new DelegateCommand(Reload);
|
||||||
|
LoginAgainCommand = new DelegateCommand(LoginAgain);
|
||||||
|
StopCommand = new DelegateCommand(StopButton);
|
||||||
|
CopyUserNameCommand = new DelegateCommand(CopyUserName);
|
||||||
|
CopyPasswordCommand = new DelegateCommand(CopyPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 窗口加载完成时调用
|
||||||
|
/// </summary>
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
IsLoginMode = OpenType == EnumOpenType.login;
|
||||||
|
_isWindowLoaded = true;
|
||||||
|
|
||||||
|
if (CloseAfterSecond > 0)
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000 * CloseAfterSecond);
|
||||||
|
if (_isWindowLoaded)
|
||||||
|
{
|
||||||
|
Application.Current?.Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (_isWindowLoaded)
|
||||||
|
RequestClose?.Invoke();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
|
||||||
|
AutoLogin();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 窗口关闭时调用,停止后台任务
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
_isWindowLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动登录店铺后台
|
||||||
|
/// </summary>
|
||||||
|
private async void AutoLogin()
|
||||||
|
{
|
||||||
|
if (OpenType != EnumOpenType.login && buyer == null)
|
||||||
|
return;
|
||||||
|
_ = Application.Current.Dispatcher.InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
if (CefWebBrowser == null)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(InitUrl))
|
||||||
|
CefWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser(InitUrl, false);
|
||||||
|
else
|
||||||
|
CefWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser(buyerMainUrl, false);
|
||||||
|
|
||||||
|
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
|
||||||
|
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||||||
|
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||||||
|
CefWebBrowser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
|
||||||
|
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
|
||||||
|
CefWebBrowser.LifeSpanHandler = lifeSapnHandler;
|
||||||
|
//CefWebBrowser.KeyboardHandler = new KeyboardHandler();
|
||||||
|
CefWebBrowser.KeyboardHandler = new CefKeyboardHandler();
|
||||||
|
CefWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||||||
|
CefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
|
||||||
|
CefWebBrowser.LoadError += CefWebBrowser_LoadError;
|
||||||
|
|
||||||
|
// 通知视图把浏览器加入可视树(必须在等待浏览器初始化之前完成)
|
||||||
|
BrowserCreated?.Invoke(CefWebBrowser);
|
||||||
|
|
||||||
|
List<Cookie> cookieLst = new List<Cookie>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (buyer != null)
|
||||||
|
{
|
||||||
|
cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
|
||||||
|
if (cookieLst == null)
|
||||||
|
cookieLst = new List<Cookie>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// cef138必须init后方可设置或删除cookie
|
||||||
|
|
||||||
|
while (!CefWebBrowser.IsBrowserInitialized || !CefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||||
|
await Task.Delay(20);
|
||||||
|
WPFCEFBrowser.DeleteCookie(CefWebBrowser.GetCookieManager(null));
|
||||||
|
|
||||||
|
//cef 138 如果没有设置RequestContext 可能为空,直接getCookieManager
|
||||||
|
var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), CefWebBrowser.GetCookieManager(null));
|
||||||
|
foreach (var cook in cookieLst)
|
||||||
|
{
|
||||||
|
//var t = CEFBrowser.SetCookieAsync(cook.Domain.Trim('.'), cook.Name + "=" + cook.Value + ";", CefWebBrowser.GetCookieManager(null));
|
||||||
|
//t.Wait(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据登录的具体店铺设置local storage
|
||||||
|
if (!string.IsNullOrEmpty(buyer?.buyer_id))
|
||||||
|
{
|
||||||
|
//var storageJsCode = "window.localStorage.setItem('" + "mall-info-id" + "', '" + shop.ShopId + "');\r\n";
|
||||||
|
//storageJsCode += "window.localStorage.setItem('" + "agentseller-mall-info-id" + "', '" + shop.ShopId + "');\r\n";
|
||||||
|
//while (!CefWebBrowser.IsBrowserInitialized || !CefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||||
|
// Thread.Sleep(20);
|
||||||
|
//CefWebBrowser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(storageJsCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(InitUrl))
|
||||||
|
CefWebBrowser.Load(InitUrl);
|
||||||
|
else
|
||||||
|
CefWebBrowser.Load(buyerMainUrl);
|
||||||
|
|
||||||
|
//不是登录的话就此返回
|
||||||
|
if (OpenType != EnumOpenType.login)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 50; i++)
|
||||||
|
{
|
||||||
|
if (CefWebBrowser.IsLoading)
|
||||||
|
await Task.Delay(100);
|
||||||
|
}
|
||||||
|
await Task.Delay(Randomx.GetId(1500, 2000));
|
||||||
|
if (!_isWindowLoaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (!CefWebBrowser.Address?.StartsWith(buyerLoginUrl) ?? false)
|
||||||
|
{
|
||||||
|
await Task.Delay(1000);
|
||||||
|
if (!_isWindowLoaded)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void CefWebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CefWebBrowser_AddressChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (Application.Current?.Dispatcher != null)
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
currentUrl = e.NewValue.ParseToString();
|
||||||
|
Address = e.NewValue.ParseToString();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CefWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
|
||||||
|
{
|
||||||
|
//js绑定C#对象 html页面内声明绑定的C#对象
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append("(function(){");
|
||||||
|
sb.Append("CefSharp.BindObjectAsync('shopObj');");
|
||||||
|
sb.Append("})();");
|
||||||
|
CefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool RequestHandler_BeforeResourceLoad(object sender, string url, string postData, IRequest request)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
|
||||||
|
{
|
||||||
|
await DoResourceLoadComplete(url, responseData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DoResourceLoadComplete(string url, string responseData)
|
||||||
|
{
|
||||||
|
//if (url.Contains(buyerLoginUrl) && OpenType == EnumOpenType.login)
|
||||||
|
//{
|
||||||
|
// Task.Run(() => { CefWebBrowser.Load(buyerLoginUrl); });
|
||||||
|
//}
|
||||||
|
var data = responseData;
|
||||||
|
if (data.Contains("karl_malone_32") || data.Contains("jtt_fan"))
|
||||||
|
{
|
||||||
|
|
||||||
|
//https://h5api.m.taobao.com/h5/mtop.user.getusersimple/1.0/?jsv=2.7.2&appKey=12574478&t=1789984970076&sign=6bb7d3b5cd8bd3ab32bd97c1a0df1c0f&jsonpIncPrefix=tbnavnew&api=mtop.user.getUserSimple&v=1.0&dataType=json&type=originaljson&data=%7B%7D
|
||||||
|
//{"api":"mtop.user.getUserSimple","v":"1.0","ret":["SUCCESS::调用成功"],"data":{"nick":"jtt_fan","userNumId":440631048,"displayNick":"jtt_fan"}}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.Contains(buyerMainUrl) || (data.Contains("\"displayNick\"") && data.Contains("\"nick\"") && data.Contains("\"userNumId\"")))
|
||||||
|
{
|
||||||
|
if (OpenType == EnumOpenType.login)
|
||||||
|
{
|
||||||
|
await Task.Run(async () =>
|
||||||
|
{
|
||||||
|
if (data.Contains("\"ret\":[\"SUCCESS::调用成功\"]"))
|
||||||
|
{
|
||||||
|
var uid = BaseRegex.GetStringJson(ref data, "userNumId");
|
||||||
|
var nickname = BaseRegex.GetStringJson(ref data, "displayNick");
|
||||||
|
var username = nickname;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(nickname) && !string.IsNullOrEmpty(uid) && !isAddOrUpdateBuyer)
|
||||||
|
{
|
||||||
|
isAddOrUpdateBuyer = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AddOrUpdateBuyer(uid, username, nickname);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
isAddOrUpdateBuyer = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAddOrUpdateBuyer = false;
|
||||||
|
|
||||||
|
void AddOrUpdateBuyer(string uid, string username, string nickname)
|
||||||
|
{
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
|
||||||
|
List<Cookie> cookieList = WPFCEFBrowser.GetCookieList(shopCookieHead, CefWebBrowser.GetCookieManager(null));
|
||||||
|
|
||||||
|
var buyerUrl = BaseClass.Build29WxObjString("user/add_taobao_buyer");
|
||||||
|
|
||||||
|
if (this.buyer == null || this.buyer.buyer_id != uid)
|
||||||
|
this.buyer = GlobalConfig.TaobaoBuyerLoginList.FirstOrDefault(b => b.buyer_id == uid);
|
||||||
|
if (this.buyer != null)
|
||||||
|
{
|
||||||
|
this.buyer.user_name = username;
|
||||||
|
this.buyer.buyer_nick = nickname;
|
||||||
|
this.buyer.cookie = JsonHelper.SerializeObject(cookieList);
|
||||||
|
buyerUrl = BaseClass.Build29WxObjString("user/mdy_taobao_buyer");
|
||||||
|
}
|
||||||
|
|
||||||
|
var buyerData = UserLogin.GetSignaturex()
|
||||||
|
+ "&buyer_id=" + uid
|
||||||
|
+ "&buyer_name=" + username
|
||||||
|
+ "&buyer_nick=" + nickname;
|
||||||
|
var result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||||
|
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||||
|
result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||||
|
|
||||||
|
buyerUrl = BaseClass.Build29WxObjString("user/mdy_taobao_buyer_cookie");
|
||||||
|
buyerData = UserLogin.GetSignaturex()
|
||||||
|
+ "&buyer_id=" + uid
|
||||||
|
+ "&status=" + "在线"
|
||||||
|
+ "&cookie=" + GetHtml.UrlEncodeUtf8(JsonHelper.SerializeObject(cookieList));
|
||||||
|
result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||||
|
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||||
|
result = GetHtml.PostUtf8(buyerUrl, buyerData);
|
||||||
|
|
||||||
|
Application.Current?.Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (IsCloseAfterLogin)
|
||||||
|
RequestClose?.Invoke();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{ }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopButton()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopyUserName()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(UserName))
|
||||||
|
Clipboard.SetDataObject(UserName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopyPassword()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(PassWord))
|
||||||
|
Clipboard.SetDataObject(PassWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Reload()
|
||||||
|
{
|
||||||
|
if (CefWebBrowser != null)
|
||||||
|
{
|
||||||
|
if (Address != "about:blank")
|
||||||
|
CefWebBrowser.Load(Address);
|
||||||
|
else
|
||||||
|
CefWebBrowser.Load(buyerMainUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoginAgain()
|
||||||
|
{
|
||||||
|
if (this.currentUrl != buyerLoginUrl)
|
||||||
|
this.CefWebBrowser?.Load(buyerLoginUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 静态方法(检测/更新买手登录状态)
|
||||||
|
|
||||||
|
public static void CheckBuyerLogin(List<BuyerLoginInfo> checkBuyers, bool isShowProgress = true)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < checkBuyers.Count; i++)
|
||||||
|
{
|
||||||
|
var buyer = GlobalConfig.TaobaoBuyerLoginList.FirstOrDefault(v => v.buyer_id == checkBuyers[i].buyer_id);
|
||||||
|
var buys = GlobalConfig.TaobaoBuyerLoginList.Where(v => v.buyer_id == checkBuyers[i].buyer_id).ToList();
|
||||||
|
if (buyer == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 先从服务端取最新cookie
|
||||||
|
var url = BaseClass.Build29WxObjString("user/get_taobao_buyer");
|
||||||
|
var data = UserLogin.GetSignaturex();
|
||||||
|
data += "&buyer_ids=" + buyer.buyer_id;
|
||||||
|
data += "&page_size=1";
|
||||||
|
var result = GetHtml.PostUtf8(url, data);
|
||||||
|
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||||
|
result = GetHtml.PostUtf8(url, data);
|
||||||
|
if (!result.Contains("\"code\":200"))
|
||||||
|
continue;
|
||||||
|
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||||
|
|
||||||
|
var serverBuyer = loginInfoLst.FirstOrDefault();
|
||||||
|
if (buyer != null && serverBuyer != null)
|
||||||
|
{
|
||||||
|
buyer.cookie = serverBuyer.cookie;
|
||||||
|
foreach (var buy in buys)
|
||||||
|
{
|
||||||
|
buy.cookie = serverBuyer.cookie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buyer != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
|
||||||
|
var loginResult = CheckBuyerLogin(buyer);
|
||||||
|
if (!loginResult.Contains("\"success\":true") && !loginResult.Contains("\"login\":true") && !loginResult.Contains("\"nickname\""))
|
||||||
|
{
|
||||||
|
buyer.cookie = "[]";
|
||||||
|
foreach (var buy in buys)
|
||||||
|
{
|
||||||
|
buy.status = "掉线";
|
||||||
|
buy.cookie = "[]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var buy in buys)
|
||||||
|
{
|
||||||
|
buy.status = "在线";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpdateServerBuyerCookies(buyer); // 店铺cookie和状态写入服务端
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CheckBuyerLogin(BuyerLoginInfo buyer, string refere = "https://mobile.yangkeduo.com/goods.html")
|
||||||
|
{
|
||||||
|
string url = "https://mobile.yangkeduo.com/proxy/api/api/apollo/v3/user/me?pdduid=" + buyer.buyer_id;
|
||||||
|
return HttpResponseYkdBLL.YangkeduoGetResponse(buyer, url, refere);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string UpdateServerBuyerCookies(BuyerLoginInfo buyer, string fromTool = null)
|
||||||
|
{
|
||||||
|
var url = BaseClass.Build29WxObjString("user/mdy_taobao_buyer_cookie");
|
||||||
|
var data = UserLogin.GetSignaturex()
|
||||||
|
+ "&status=" + buyer.status
|
||||||
|
+ "&cookie=" + GetHtml.UrlEncodeUtf8(buyer.cookie)
|
||||||
|
+ "&buyer_id=" + buyer.buyer_id;
|
||||||
|
var result = GetHtml.PostUtf8(url, data);
|
||||||
|
if (!result.Contains("\"code\":200"))
|
||||||
|
result = GetHtml.PostUtf8(url, data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal class CefKeyboardHandler : IKeyboardHandler
|
||||||
|
{
|
||||||
|
public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
|
||||||
|
{
|
||||||
|
if (type == KeyType.KeyUp && Enum.IsDefined(typeof(System.Windows.Forms.Keys), windowsKeyCode))
|
||||||
|
{
|
||||||
|
var key = (System.Windows.Forms.Keys)windowsKeyCode;
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case System.Windows.Forms.Keys.F12:
|
||||||
|
browser.ShowDevTools();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case System.Windows.Forms.Keys.F5:
|
||||||
|
|
||||||
|
if (modifiers == CefEventFlags.ControlDown)
|
||||||
|
{
|
||||||
|
//MessageBox.Show("ctrl+f5");
|
||||||
|
browser.Reload(true); //强制忽略缓存
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//MessageBox.Show("f5");
|
||||||
|
browser.Reload();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="_29WxOrderWpf.Views.TaobaoLoginView"
|
||||||
|
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:comn="clr-namespace:_29WxOrderWpf.Common"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:wpf="WPFCommon"
|
||||||
|
x:Name="taobaoLoginView"
|
||||||
|
Width="1280"
|
||||||
|
Height="800"
|
||||||
|
MinWidth="800"
|
||||||
|
MinHeight="600"
|
||||||
|
comn:DialogWindowProperty.ResizeMode="CanResizeWithGrip"
|
||||||
|
comn:DialogWindowProperty.ShowMinButton="False"
|
||||||
|
comn:DialogWindowProperty.Width="1300"
|
||||||
|
Loaded="TaobaoLoginView_Loaded"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid Background="White">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 地址栏 -->
|
||||||
|
<Border
|
||||||
|
Grid.Row="0"
|
||||||
|
Background="White"
|
||||||
|
BorderBrush="#E0E0E0"
|
||||||
|
BorderThickness="0,0,0,1">
|
||||||
|
<TextBox
|
||||||
|
x:Name="txtAddress"
|
||||||
|
Margin="3,2"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
BorderBrush="#D0D0D0"
|
||||||
|
BorderThickness="1"
|
||||||
|
KeyDown="txtAddress_KeyDown"
|
||||||
|
Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 主区域:浏览器 + 右侧面板 -->
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 浏览器容器 -->
|
||||||
|
<Grid
|
||||||
|
x:Name="BrowserHost"
|
||||||
|
Grid.Column="0"
|
||||||
|
Background="White"
|
||||||
|
ClipToBounds="True" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using _29WxOrderWpf.BaseWindows;
|
||||||
|
using _29WxOrderWpf.ViewModels;
|
||||||
|
using AllBase.Model.DBModel;
|
||||||
|
using CefSharp.Wpf;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace _29WxOrderWpf.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 淘宝买手登录窗口(WPF 版 TaobaoLoginView)
|
||||||
|
/// </summary>
|
||||||
|
public partial class TaobaoLoginView : UserControl
|
||||||
|
{
|
||||||
|
/// <summary>视图模型</summary>
|
||||||
|
public TaobaoLoginViewModel ViewModel { get; }
|
||||||
|
|
||||||
|
public TaobaoLoginView(BuyerLoginInfo buyerInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
ViewModel = new TaobaoLoginViewModel(buyerInfo);
|
||||||
|
ViewModel.BrowserCreated += ViewModel_BrowserCreated;
|
||||||
|
ViewModel.RequestClose += ViewModel_RequestClose;
|
||||||
|
DataContext = ViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TaobaoLoginView_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ViewModel.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TaobaoLoginView_Closed(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
ViewModel.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ViewModel_BrowserCreated(ChromiumWebBrowser browser)
|
||||||
|
{
|
||||||
|
Grid.SetRow(browser, 0);
|
||||||
|
Grid.SetColumn(browser, 0);
|
||||||
|
BrowserHost.Children.Add(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ViewModel_RequestClose()
|
||||||
|
{
|
||||||
|
Window parentWindow = Window.GetWindow(this);
|
||||||
|
if (this.IsLoaded && parentWindow != null)
|
||||||
|
parentWindow.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtAddress_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
ViewModel.ReloadCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,10 +33,18 @@ namespace AllBase.Helper
|
|||||||
/// 拼多多买手列表
|
/// 拼多多买手列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ObservableCollectionThreadSafe<BuyerLoginInfo> PDDBuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
|
public static ObservableCollectionThreadSafe<BuyerLoginInfo> PDDBuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前拼多多买手
|
/// 淘宝买手列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static BuyerLoginInfo CurrentPddBuyer { get; set; }
|
public static ObservableCollectionThreadSafe<BuyerLoginInfo> TaobaoBuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
|
||||||
|
/// <summary>
|
||||||
|
/// 当前拼多多买手
|
||||||
|
/// </summary>
|
||||||
|
public static BuyerLoginInfo CurrentPddBuyer { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前淘宝买手
|
||||||
|
/// </summary>
|
||||||
|
public static BuyerLoginInfo CurrentTaobaoBuyer { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 支付宝密码
|
/// 支付宝密码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ namespace AllBase.Model.DBModel
|
|||||||
支付宝在线充值 = 30,
|
支付宝在线充值 = 30,
|
||||||
云仓退货支出 = 31,
|
云仓退货支出 = 31,
|
||||||
礼物单退费 = 34,
|
礼物单退费 = 34,
|
||||||
|
额外订单创建 = 35,
|
||||||
|
额外订单作废 = 36,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Work.KJDServer.API.WXOrder
|
|||||||
NamingStrategy = new SnakeCaseNamingStrategy()
|
NamingStrategy = new SnakeCaseNamingStrategy()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (ret.Code == 200)
|
if (ret?.Code == 200)
|
||||||
{
|
{
|
||||||
return ret.Data;
|
return ret.Data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user