diff --git a/29WxOrder.sln b/29WxOrder.sln index f7b161d..b249ba4 100644 --- a/29WxOrder.sln +++ b/29WxOrder.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 18 -VisualStudioVersion = 18.7.12002.237 oobstable +VisualStudioVersion = 18.7.12002.237 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "29WxOrderAllBase", "AllBase\29WxOrderAllBase.csproj", "{6461D807-B1C8-45F0-B388-E0CA1A418DE0}" EndProject @@ -9,10 +9,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "29供应链-微信小店拍 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "29WxOrderWork", "Work\29WxOrderWork.csproj", "{1AD45D66-6872-4522-ACF0-04E2C0514048}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "29WxOrderWpf", "29WxOrderWpf\29WxOrderWpf.csproj", "{D7884375-E42F-4B89-AA3A-D8E75508D8C7}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "29供应链-BaseProject", "29供应链-BaseProject", "{4A54DC2A-B47C-4ED1-A482-EE60161DB2C3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "29WxOrderWpf", "29WxOrderWpf\29WxOrderWpf.csproj", "{5A410EB5-06AD-97BB-2314-9D7A808E12F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -57,22 +57,22 @@ Global {1AD45D66-6872-4522-ACF0-04E2C0514048}.Release|x64.Build.0 = Release|x64 {1AD45D66-6872-4522-ACF0-04E2C0514048}.Release|x86.ActiveCfg = Release|x86 {1AD45D66-6872-4522-ACF0-04E2C0514048}.Release|x86.Build.0 = Release|x86 - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|x64.ActiveCfg = Debug|x64 - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|x64.Build.0 = Debug|x64 - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|x86.ActiveCfg = Debug|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Debug|x86.Build.0 = Debug|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|Any CPU.Build.0 = Release|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|x64.ActiveCfg = Release|x64 - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|x64.Build.0 = Release|x64 - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|x86.ActiveCfg = Release|Any CPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7}.Release|x86.Build.0 = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|x64.ActiveCfg = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|x64.Build.0 = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|x86.ActiveCfg = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Debug|x86.Build.0 = Debug|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|Any CPU.Build.0 = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|x64.ActiveCfg = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|x64.Build.0 = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|x86.ActiveCfg = Release|Any CPU + {5A410EB5-06AD-97BB-2314-9D7A808E12F7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,7 +80,7 @@ Global GlobalSection(NestedProjects) = preSolution {6461D807-B1C8-45F0-B388-E0CA1A418DE0} = {4A54DC2A-B47C-4ED1-A482-EE60161DB2C3} {1AD45D66-6872-4522-ACF0-04E2C0514048} = {4A54DC2A-B47C-4ED1-A482-EE60161DB2C3} - {D7884375-E42F-4B89-AA3A-D8E75508D8C7} = {1A7830FA-AC8F-40FB-A232-F0626812B8BE} + {5A410EB5-06AD-97BB-2314-9D7A808E12F7} = {1A7830FA-AC8F-40FB-A232-F0626812B8BE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {38687A61-0347-49AC-98C7-E7F7148C0234} diff --git a/29WxOrderWpf/29WxOrderWpf.csproj b/29WxOrderWpf/29WxOrderWpf.csproj index 0e032fa..c6eaf2c 100644 --- a/29WxOrderWpf/29WxOrderWpf.csproj +++ b/29WxOrderWpf/29WxOrderWpf.csproj @@ -1,464 +1,70 @@ - - - - - - + + - Debug - AnyCPU - {D7884375-E42F-4B89-AA3A-D8E75508D8C7} WinExe + net462 _29WxOrderWpf 29WxFindOrder - v4.6.2 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - - AnyCPU - true - full - false - ..\..\KJD Cef138\Bin\ - DEBUG;TRACE - prompt - 4 - - - x64 - pdbonly - true - ..\..\KJD Cef138\Bin\ - TRACE - prompt - 4 - - + true gear.ico - - - true + 12 + x64 ..\bin\ - DEBUG;TRACE - full + false + false + + + x64 - 7.3 - prompt - true - - - ..\..\KJD\Bin\ - TRACE - true pdbonly - x64 - 7.3 - prompt - true - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - 7.3 - prompt - true - - - bin\x86\Release\ - TRACE true - pdbonly - x86 - 7.3 - prompt - true + ..\..\KJD Cef138\Bin\ + TRACE + + + + + + + + + - - ..\packages\CefSharp.Common.138.0.340\lib\net462\CefSharp.dll - - - ..\packages\CefSharp.Common.138.0.340\lib\net462\CefSharp.Core.dll - - - ..\packages\CefSharp.Wpf.138.0.340\lib\net462\CefSharp.Wpf.dll - - - ..\DllReference\NaiBa.Util.dll - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - + + + - - - - - - 4.0 - + + + - - MSBuild:Compile - Designer - - - BaseMsgWindow.xaml - - - - - - - - - - - - - - - - - - PDDBuyerOrderReadCtrl.xaml - - - PDDBuyerSelectCtrl.xaml - - - DialogWindow.xaml - - - OrderListRowCtrl.xaml - - - OrderListRowHeaderCtrl.xaml - - - OrderListRowItemCtrl.xaml - - - ShopDataGridCtrl.xaml - - - ShopListCtrl.xaml - - - RevenueLineChart.xaml - - - RevenuePieChart.xaml - - - - - ShopRevenueStatisticsView.xaml - - - PeriodRevenueStatisticsView.xaml - - - - - UcWaterMarkTextBox.xaml - - - LoginWindow.xaml - - - OrderListCtrl.xaml - - - - Icons.xaml - - - - - UcWindowBoxes.xaml - - - - TransitAfterSaleWindow.xaml - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - + + ..\DllReference\NaiBa.Util.dll + true + + - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - False - Microsoft .NET Framework 4.6.2 %28x86 和 x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - - - {6461D807-B1C8-45F0-B388-E0CA1A418DE0} - 29WxOrderAllBase - - - {1ad45d66-6872-4522-acf0-04e2c0514048} - 29WxOrderWork - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - - - - - \ No newline at end of file + + diff --git a/29WxOrderWpf/29WxOrderWpf.csproj.user b/29WxOrderWpf/29WxOrderWpf.csproj.user index e905d8d..607b9ea 100644 --- a/29WxOrderWpf/29WxOrderWpf.csproj.user +++ b/29WxOrderWpf/29WxOrderWpf.csproj.user @@ -10,5 +10,12 @@ zh-CN false ProjectFiles + Production + + + ProjectDebugger + + + ProjectDebugger \ No newline at end of file diff --git a/29WxOrderWpf/Common/EnvironmentHelper.cs b/29WxOrderWpf/Common/EnvironmentHelper.cs new file mode 100644 index 0000000..eba41fb --- /dev/null +++ b/29WxOrderWpf/Common/EnvironmentHelper.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MAX.Core.Helpers; +public class EnvironmentHelper +{ + private static string? _currentEnvironment; + + // 获取当前环境 + public static string CurrentEnvironment + { + get + { + if (_currentEnvironment == null) + { + _currentEnvironment = DetermineEnvironment(); + } + return _currentEnvironment; + } + } + public static bool IsTest => CurrentEnvironment.Equals("Test", StringComparison.OrdinalIgnoreCase); + public static bool IsDevelopment => CurrentEnvironment.Equals("Development", StringComparison.OrdinalIgnoreCase); + + public static bool IsProduction => CurrentEnvironment.Equals("Production", StringComparison.OrdinalIgnoreCase); + + private static string DetermineEnvironment() + { + // 1. 检查环境变量 + var envVar = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? + Environment.GetEnvironmentVariable("ENVIRONMENT"); + + if (!string.IsNullOrEmpty(envVar)) + { + return envVar; + } + + + // 检查当前机器名 + string machineName = Environment.MachineName.ToLower(); + if (machineName.Contains("dev") || + machineName.Contains("test")) + { + return machineName.Contains("TEST") ? "Test" : "Development"; + } + + // 4. 默认返回 Production + return "Production"; + } + + // 获取环境描述 + public static string EnvironmentDescription + { + get + { + if (IsTest) return "测试环境"; + if (IsDevelopment) return "开发环境"; + if (IsProduction) return "生产环境"; + return $"未知环境 ({CurrentEnvironment})"; + } + } +} diff --git a/29WxOrderWpf/Properties/Settings.Designer.cs b/29WxOrderWpf/Properties/Settings.Designer.cs deleted file mode 100644 index a436abc..0000000 --- a/29WxOrderWpf/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace _29WxOrderWpf.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/29WxOrderWpf/Properties/Settings.settings b/29WxOrderWpf/Properties/Settings.settings deleted file mode 100644 index 033d7a5..0000000 --- a/29WxOrderWpf/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/29WxOrderWpf/Properties/launchSettings.json b/29WxOrderWpf/Properties/launchSettings.json index b29c050..2265c7b 100644 --- a/29WxOrderWpf/Properties/launchSettings.json +++ b/29WxOrderWpf/Properties/launchSettings.json @@ -1,11 +1,11 @@ -{ +{ "profiles": { - "Production": { + "Production": { "commandName": "Project", "environmentVariables": { "ENVIRONMENT": "Production" } - } + }, "Development": { "commandName": "Project", "environmentVariables": { diff --git a/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs b/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs index 977a5ae..051bd98 100644 --- a/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs +++ b/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs @@ -2,6 +2,7 @@ using _29WxOrderWpf.UserControls; using AllBase; using AllBase.DouYinModel.Param.LoginManage; +using MAX.Core.Helpers; using NaiBa.Util; using NaiBa.Util.Extension; using NaiBa.Util.Helper; @@ -25,201 +26,202 @@ using Work.BaseForms; namespace _29WxOrderWpf.Windows.LoginWindows { - /// - /// LoginWindow.xaml 的交互逻辑 - /// - public partial class LoginWindow : BaseWindow - { - public static ConcurrentList UserParamList { get; set; } = new ConcurrentList(); + /// + /// LoginWindow.xaml 的交互逻辑 + /// + public partial class LoginWindow : BaseWindow + { + public static ConcurrentList UserParamList { get; set; } = new ConcurrentList(); - public bool IsLogin { get; set; } = false; + public bool IsLogin { get; set; } = false; - string[] argsuser; + string[] argsuser; - public LoginWindow(string[] args) - { - InitializeComponent(); + public LoginWindow(string[] args) + { + InitializeComponent(); - if (!string.IsNullOrEmpty(BaseClass.ProgramName)) - { - lblAppName.Content = BaseClass.ProgramName; - MainWindow.Instance.lblAppName.Content = lblAppName.Content; - } + if (!string.IsNullOrEmpty(BaseClass.ProgramName)) + { + lblAppName.Content = BaseClass.ProgramName; + MainWindow.Instance.lblAppName.Content = lblAppName.Content; + } - this.Title = "用户登录"; - argsuser = args; - } + this.Title = "用户登录"; + argsuser = args; + } - private void loginWindow_Loaded(object sender, RoutedEventArgs e) - { -#if DEBUG - chkDebug.Visibility = Visibility.Visible; -#endif - - GetUserList(); - foreach (var user in UserParamList) - { - cmbUserNameMobile.Items.Insert(0, user.UserName); - } - - this.Title = "登录"; - if (BaseClass.Remember) - { - chkRemember.IsChecked = true; - cmbUserNameMobile.Text = BaseClass.UserName; - if (!string.IsNullOrEmpty(BaseClass.PassWord)) - txtPassword.Password = "******"; - } - - if (argsuser.Length > 1) - { - cmbUserNameMobile.Text = argsuser[0].Replace(" ", ""); - txtPassword.Password = "******"; - BaseClass.PassWord = argsuser[1].Replace(" ", ""); - btnLogin_Click(null, null); - } - } - - - private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) - { - //if (BaseMsgForm.ShowConfirm("是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个", "请先登录或者注册").DialogResult == System.Windows.Forms.DialogResult.OK) - // Process.GetCurrentProcess().Kill(); - //else - // e.Cancel = true; - - if (!IsLogin) - { - if (BaseMsgWindow.ShowConfirm("是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个。", "请先登录或者注册", this).DialogResult == true) - Process.GetCurrentProcess().Kill(); - else - e.Cancel = true; - } - } - - private void btnLogin_Click(object sender, RoutedEventArgs e) - { - UserLogin ul = new UserLogin(); - ul.Mobile = cmbUserNameMobile.Text; - ul.Password = txtPassword.Password; - - if (cmbUserNameMobile.Text.Length != 11) - { - BaseMsgWindow.ShowError("手机号不正确", "提示", this); - cmbUserNameMobile.Focus(); - return; - } - if (txtPassword.Password.Length < 6) - { - BaseMsgWindow.ShowError("密码长度不正确", "提示", this); - txtPassword.Password = ""; - txtPassword.Focus(); - return; - } - string message = ""; - int weakPassword = 0; - int lockUserName = 0; - string messageInfo = ""; - bool ok = ul.Get(ref message, out lockUserName, out weakPassword, out messageInfo); - if (!ok) - { - BaseMsgForm.ShowError(message, "登录失败"); - return; - } - MainWindow.Instance.Balance = BaseClass.Balance.ToString("0.00"); - if (BaseClass.Remember) - { - Initialization i = new Initialization(); - i.SaveConfig(); - - var eUser = UserParamList.FirstOrDefault(u => u.UserName == BaseClass.UserName); - if (eUser != null) - UserParamList.Remove(eUser); - UserParamList.Add(new UserParam() - { - UserName = BaseClass.UserName, - PasswordMd5 = BaseClass.PassWord - }); - SaveUserList(); - } + private void loginWindow_Loaded(object sender, RoutedEventArgs e) + { #if DEBUG - MainWindow.Instance.lblDebug.Visibility = Visibility.Visible; - MainWindow.Instance.lblDebug.Content = "[Debug]"; - MainWindow.Instance.lblDebug.Foreground = new SolidColorBrush(Color.FromRgb(100, 250, 255)); - if (BaseClass.LoginApiUrl == BaseClass.DebugUrl) - { - MainWindow.Instance.lblDebug.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 100)); - MainWindow.Instance.lblDebug.Content = "[Dev]"; - } + chkDebug.Visibility = Visibility.Visible; + chkDebug.IsChecked = EnvironmentHelper.IsDevelopment; #endif - this.IsLogin = true; - this.Close(); - } - public static void SaveUserList() - { - ConfigHelper.SaveConfig("user_login_config", UserParamList); - } - public static void GetUserList() - { - #region 用户账户记忆功能 - UserParamList = ConfigHelper.LoadConfig>("user_login_config"); - if (UserParamList == null) - UserParamList = new ConcurrentList(); - #endregion - } + GetUserList(); + foreach (var user in UserParamList) + { + cmbUserNameMobile.Items.Insert(0, user.UserName); + } - private void btnDeleteItem_Click(object sender, RoutedEventArgs e) - { - var imgButton = sender as UcImageButton; - if (imgButton != null) - { - var userName = imgButton.Tag.ParseToString(); - if (!string.IsNullOrEmpty(userName)) - { - UserParamList.RemoveAll(u => u.UserName == userName); - SaveUserList(); - foreach (var item in cmbUserNameMobile.Items.Cast().ToList()) - { - if (item.ParseToString() == userName) - { - cmbUserNameMobile.Items.Remove(item); - } + this.Title = "登录"; + if (BaseClass.Remember) + { + chkRemember.IsChecked = true; + cmbUserNameMobile.Text = BaseClass.UserName; + if (!string.IsNullOrEmpty(BaseClass.PassWord)) + txtPassword.Password = "******"; + } - } - //ShowUserDropDown(); - } - } - } + if (argsuser.Length > 1) + { + cmbUserNameMobile.Text = argsuser[0].Replace(" ", ""); + txtPassword.Password = "******"; + BaseClass.PassWord = argsuser[1].Replace(" ", ""); + btnLogin_Click(null, null); + } + } - private void cmbUserNameMobile_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - var userName = cmbUserNameMobile.SelectedItem.ParseToString(); - var user = UserParamList.FirstOrDefault(u => u.UserName == userName); - if (user != null) - { - BaseClass.UserName = user.UserName; - BaseClass.PassWord = user.PasswordMd5; - this.cmbUserNameMobile.Text = user.UserName; - this.txtPassword.Password = "******"; - } - } - private void chkRemember_Checked(object sender, RoutedEventArgs e) - { - BaseClass.Remember = chkRemember.IsChecked.ParseToBool(); - } + private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + //if (BaseMsgForm.ShowConfirm("是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个", "请先登录或者注册").DialogResult == System.Windows.Forms.DialogResult.OK) + // Process.GetCurrentProcess().Kill(); + //else + // e.Cancel = true; - private void chkDebug_Checked(object sender, RoutedEventArgs e) - { - if (chkDebug.IsChecked == true) - { - BaseClass.LoginApiUrl = BaseClass.DebugUrl; - } - else - { - BaseClass.LoginApiUrl = BaseClass.ServerUrl; - } - } - } + if (!IsLogin) + { + if (BaseMsgWindow.ShowConfirm("是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个。", "请先登录或者注册", this).DialogResult == true) + Process.GetCurrentProcess().Kill(); + else + e.Cancel = true; + } + } + + private void btnLogin_Click(object sender, RoutedEventArgs e) + { + UserLogin ul = new UserLogin(); + ul.Mobile = cmbUserNameMobile.Text; + ul.Password = txtPassword.Password; + + if (cmbUserNameMobile.Text.Length != 11) + { + BaseMsgWindow.ShowError("手机号不正确", "提示", this); + cmbUserNameMobile.Focus(); + return; + } + if (txtPassword.Password.Length < 6) + { + BaseMsgWindow.ShowError("密码长度不正确", "提示", this); + txtPassword.Password = ""; + txtPassword.Focus(); + return; + } + string message = ""; + int weakPassword = 0; + int lockUserName = 0; + string messageInfo = ""; + bool ok = ul.Get(ref message, out lockUserName, out weakPassword, out messageInfo); + if (!ok) + { + BaseMsgForm.ShowError(message, "登录失败"); + return; + } + MainWindow.Instance.Balance = BaseClass.Balance.ToString("0.00"); + if (BaseClass.Remember) + { + Initialization i = new Initialization(); + i.SaveConfig(); + + var eUser = UserParamList.FirstOrDefault(u => u.UserName == BaseClass.UserName); + if (eUser != null) + UserParamList.Remove(eUser); + UserParamList.Add(new UserParam() + { + UserName = BaseClass.UserName, + PasswordMd5 = BaseClass.PassWord + }); + SaveUserList(); + } +#if DEBUG + MainWindow.Instance.lblDebug.Visibility = Visibility.Visible; + MainWindow.Instance.lblDebug.Content = "[Debug]"; + MainWindow.Instance.lblDebug.Foreground = new SolidColorBrush(Color.FromRgb(100, 250, 255)); + if (BaseClass.LoginApiUrl == BaseClass.DebugUrl) + { + MainWindow.Instance.lblDebug.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 100)); + MainWindow.Instance.lblDebug.Content = "[Dev]"; + } +#endif + this.IsLogin = true; + this.Close(); + } + + public static void SaveUserList() + { + ConfigHelper.SaveConfig("user_login_config", UserParamList); + } + public static void GetUserList() + { + #region 用户账户记忆功能 + UserParamList = ConfigHelper.LoadConfig>("user_login_config"); + if (UserParamList == null) + UserParamList = new ConcurrentList(); + #endregion + } + + private void btnDeleteItem_Click(object sender, RoutedEventArgs e) + { + var imgButton = sender as UcImageButton; + if (imgButton != null) + { + var userName = imgButton.Tag.ParseToString(); + if (!string.IsNullOrEmpty(userName)) + { + UserParamList.RemoveAll(u => u.UserName == userName); + SaveUserList(); + foreach (var item in cmbUserNameMobile.Items.Cast().ToList()) + { + if (item.ParseToString() == userName) + { + cmbUserNameMobile.Items.Remove(item); + } + + } + //ShowUserDropDown(); + } + } + } + + private void cmbUserNameMobile_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var userName = cmbUserNameMobile.SelectedItem.ParseToString(); + var user = UserParamList.FirstOrDefault(u => u.UserName == userName); + if (user != null) + { + BaseClass.UserName = user.UserName; + BaseClass.PassWord = user.PasswordMd5; + this.cmbUserNameMobile.Text = user.UserName; + this.txtPassword.Password = "******"; + } + } + + private void chkRemember_Checked(object sender, RoutedEventArgs e) + { + BaseClass.Remember = chkRemember.IsChecked.ParseToBool(); + } + + private void chkDebug_Checked(object sender, RoutedEventArgs e) + { + if (chkDebug.IsChecked == true) + { + BaseClass.LoginApiUrl = BaseClass.DebugUrl; + } + else + { + BaseClass.LoginApiUrl = BaseClass.ServerUrl; + } + } + } } diff --git a/29WxOrderWpf/packages.config b/29WxOrderWpf/packages.config deleted file mode 100644 index 3d04e23..0000000 --- a/29WxOrderWpf/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file