Browse Source

PJZS

qianyi
shanji 2 years ago
parent
commit
94f88a818e
  1. 9
      BBWY.sln
  2. 9
      PJZS/App.xaml
  3. 37
      PJZS/App.xaml.cs
  4. 10
      PJZS/AssemblyInfo.cs
  5. 22
      PJZS/GlobalContext.cs
  6. 12
      PJZS/MainWindow.xaml
  7. 28
      PJZS/MainWindow.xaml.cs
  8. 18
      PJZS/Models/Enums.cs
  9. 23
      PJZS/Models/NotifyObject.cs
  10. 37
      PJZS/Models/Shop/Department.cs
  11. 28
      PJZS/Models/Shop/PurchaseAccount.cs
  12. 79
      PJZS/Models/Shop/Shop.cs
  13. 31
      PJZS/Models/User/User.cs
  14. 28
      PJZS/PJZS.csproj
  15. 69
      PJZS/WebView2Manager.cs

9
BBWY.sln

@ -34,7 +34,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.1688SDK", "BBWY.1688SD
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.Test", "BBWY.Test\BBWY.Test.csproj", "{FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JD.API", "JD.API\JD.API.csproj", "{3D37A8D3-0364-4539-B3E9-A6610F4659A8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JD.API", "JD.API\JD.API.csproj", "{3D37A8D3-0364-4539-B3E9-A6610F4659A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PJZS", "PJZS\PJZS.csproj", "{FB4BF1A9-DA81-446F-903C-89D3F905B7B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -86,6 +88,10 @@ Global
{3D37A8D3-0364-4539-B3E9-A6610F4659A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D37A8D3-0364-4539-B3E9-A6610F4659A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D37A8D3-0364-4539-B3E9-A6610F4659A8}.Release|Any CPU.Build.0 = Release|Any CPU
{FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -101,6 +107,7 @@ Global
{1A7EB438-5DEF-4940-8CB2-C58141C75524} = {B131026A-2025-4A74-ABF1-644059FADF78}
{FCD5E03E-DA48-406B-9AA8-F72F21F62BDB} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5}
{3D37A8D3-0364-4539-B3E9-A6610F4659A8} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5}
{FB4BF1A9-DA81-446F-903C-89D3F905B7B8} = {D097AEA5-A7B1-414D-B82D-F70F177D0D8D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC045257-4D86-45FD-A1F0-2715C024F1B5}

9
PJZS/App.xaml

@ -0,0 +1,9 @@
<Application x:Class="PJZS.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PJZS"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

37
PJZS/App.xaml.cs

@ -0,0 +1,37 @@
using System.Windows;
namespace PJZS
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
var gl = new GlobalContext();
string userToken = string.Empty;
#if DEBUG
//齐越山鸡
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw";
#else
var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty;
if (string.IsNullOrEmpty(uid))
{
MessageBox.Show("缺少启动参数", "提示");
Environment.Exit(0);
}
var tokenResult = ReadMMF(uid);
if (tokenResult.isOk)
userToken = tokenResult.content;
else
{
MessageBox.Show($"读取内存数据失败\r\n{tokenResult.content}", "提示");
Environment.Exit(0);
}
#endif
gl.UserToken = userToken;
base.OnStartup(e);
}
}
}

10
PJZS/AssemblyInfo.cs

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

22
PJZS/GlobalContext.cs

@ -0,0 +1,22 @@
namespace PJZS
{
public class GlobalContext : NotifyObject
{
private User user;
public User User { get => user; set { Set(ref user, value); } }
public string UserToken { get; set; }
#region APIHost
public string BBYWApiHost { get; set; }
public string MDSApiHost { get; set; }
public string JOSApiHost { get; set; }
public string _1688ApiHost { get; set; }
#endregion
}
}

12
PJZS/MainWindow.xaml

@ -0,0 +1,12 @@
<Window x:Class="PJZS.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PJZS"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>

28
PJZS/MainWindow.xaml.cs

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace PJZS
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

18
PJZS/Models/Enums.cs

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PJZS.Models
{
/// <summary>
/// 电商平台
/// </summary>
public enum Platform
{
= 0,
= 1,
= 2,
= 3,
= 4
}
}

23
PJZS/Models/NotifyObject.cs

@ -0,0 +1,23 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace PJZS
{
public class NotifyObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName]string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool Set<T>(ref T oldValue, T newValue, [CallerMemberName]string propertyName = "")
{
if (Equals(oldValue, newValue))
return false;
oldValue = newValue;
OnPropertyChanged(propertyName);
return true;
}
}
}

37
PJZS/Models/Shop/Department.cs

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
namespace PJZS
{
public class Department : NotifyObject
{
private bool isSelected;
public string Id { get; set; }
public string Name { get; set; }
public IList<Shop> ShopList { get; set; }
public bool IsSelected
{
get => isSelected;
set
{
if (Set(ref isSelected, value))
OnIsSelectedChanged?.Invoke();
}
}
public Department()
{
ShopList = new List<Shop>();
}
public Action OnIsSelectedChanged { get; set; }
public override string ToString()
{
return this.Name;
}
}
}

28
PJZS/Models/Shop/PurchaseAccount.cs

@ -0,0 +1,28 @@
using PJZS.Models;
using System;
namespace PJZS
{
public class PurchaseAccount : NotifyObject,ICloneable
{
private string accountName;
private Platform purchasePlatformId;
private string appKey;
private string appSecret;
private string appToken;
public long Id { get; set; }
public long ShopId { get; set; }
public string AccountName { get => accountName; set { Set(ref accountName, value); } }
public Platform PurchasePlatformId { get => purchasePlatformId; set { Set(ref purchasePlatformId, value); } }
public string AppKey { get => appKey; set { Set(ref appKey, value); } }
public string AppSecret { get => appSecret; set { Set(ref appSecret, value); } }
public string AppToken { get => appToken; set { Set(ref appToken, value); } }
public object Clone()
{
return this.MemberwiseClone();
}
}
}

79
PJZS/Models/Shop/Shop.cs

@ -0,0 +1,79 @@
using PJZS.Models;
using System.Collections.Generic;
namespace PJZS
{
public class Shop : NotifyObject
{
private bool isSelected;
private string shopName;
public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } }
/// <summary>
/// 店铺Id
/// </summary>
public long ShopId { get; set; }
/// <summary>
/// 商家类型
/// </summary>
public string VenderType { get; set; }
/// <summary>
/// 店铺平台
/// </summary>
public Platform Platform { get; set; }
public string AppKey { get; set; }
public string AppSecret { get; set; }
public string AppToken { get; set; }
public string AppKey2 { get; set; }
public string AppSecret2 { get; set; }
public string AppToken2 { get; set; }
public string ShopName { get => shopName; set { Set(ref shopName, value); } }
public IList<PurchaseAccount> PurchaseAccountList { get; set; }
public string ManagePwd { get; set; }
/// <summary>
/// 店铺扣点
/// </summary>
public decimal? PlatformCommissionRatio { get; set; }
public string TeamId { get; set; }
public string TeamName { get; set; }
public string DingDingWebHook { get; set; }
public string DingDingKey { get; set; }
public int SkuSafeTurnoverDays { get; set; }
/// <summary>
/// 司南策略等级
/// </summary>
public int SiNanPolicyLevel { get; set; }
/// <summary>
/// 司南钉钉WebHook地址
/// </summary>
public string SiNanDingDingWebHook { get; set; }
/// <summary>
/// 司南钉钉密钥
/// </summary>
public string SiNanDingDingKey { get; set; }
public override string ToString()
{
return ShopName;
}
}
}

31
PJZS/Models/User/User.cs

@ -0,0 +1,31 @@
using System.Collections.Generic;
namespace PJZS
{
public class User : NotifyObject
{
//private string name;
private Shop shop;
public long Id { get; set; }
public string Name { get; set; }
public string TeamId { get; set; }
public string TeamName { get; set; }
public string SonDepartmentNames { get; set; }
public Shop Shop { get => shop; set { Set(ref shop, value); } }
public IList<Department> DepartmentList { get; set; }
/// <summary>
/// 店铺列表 (暂时只有刷单组才需要)
/// </summary>
public IList<Shop> ShopList { get; set; }
}
}

28
PJZS/PJZS.csproj

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1150.38" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.37" />
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BBWY.Common\BBWY.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\APIModel\" />
</ItemGroup>
</Project>

69
PJZS/WebView2Manager.cs

@ -0,0 +1,69 @@
using BBWY.Common.Models;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.Wpf;
using System;
using io = System.IO;
namespace PJZS
{
public class WebView2Manager : IDenpendency
{
public WebView2 wb2 { get; private set; }
//public WebView2Manager()
//{
// Init();
//}
public void Init()
{
if (wb2 == null)
{
wb2 = new WebView2();
var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: io.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WebView2UserData")).Result;
wb2.EnsureCoreWebView2Async(wb2Setting);
wb2.CoreWebView2InitializationCompleted += Wb2_CoreWebView2InitializationCompleted;
wb2.NavigationCompleted += Wb2_NavigationCompleted;
wb2.WebMessageReceived += Wb2_WebMessageReceived;
}
}
public Action<CoreWebView2WebMessageReceivedEventArgs> OnWebMessageReceived;
public Action<CoreWebView2NavigationCompletedEventArgs> OnNavigationCompleted;
public Action<CoreWebView2InitializationCompletedEventArgs> CoreWebView2InitializationCompleted;
public bool IsInitializationCompleted { get ; private set; }
private void Wb2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
{
OnWebMessageReceived?.Invoke(e);
}
private void Wb2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
OnNavigationCompleted?.Invoke(e);
}
private void Wb2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
CoreWebView2InitializationCompleted?.Invoke(e);
IsInitializationCompleted = true;
}
public void Close()
{
if (wb2 != null && wb2.CoreWebView2 != null)
{
IsInitializationCompleted = false;
wb2.CoreWebView2InitializationCompleted -= Wb2_CoreWebView2InitializationCompleted;
wb2.NavigationCompleted -= Wb2_NavigationCompleted;
wb2.WebMessageReceived -= Wb2_WebMessageReceived;
var udf = wb2.CoreWebView2.Environment.UserDataFolder;
wb2.Dispose();
wb2 = null;
try
{
io.Directory.Delete(udf, true);
}
catch { }
}
}
}
}
Loading…
Cancel
Save