界面修改 功能修改
This commit is contained in:
1 parent
3fe394c8da
commit
25cdf642bf
43 files changed
+897
-189
No files matched your search
@@ -1,4 +1,10 @@
|
||||
using _29WxOrderWpf.BaseWindows;
|
||||
using _29WxOrderWpf.UserControls;
|
||||
using AllBase;
|
||||
using AllBase.DouYinModel.Param.LoginManage;
|
||||
using NaiBa.Util;
|
||||
using NaiBa.Util.Extension;
|
||||
using NaiBa.Util.Helper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -9,10 +15,12 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Work;
|
||||
using Work.BaseForms;
|
||||
|
||||
namespace _29WxOrderWpf.LoginWindows
|
||||
@@ -22,22 +30,168 @@ namespace _29WxOrderWpf.LoginWindows
|
||||
/// </summary>
|
||||
public partial class LoginWindow : BaseWindow
|
||||
{
|
||||
public LoginWindow()
|
||||
public static ConcurrentList<UserParam> UserParamList { get; set; } = new ConcurrentList<UserParam>();
|
||||
|
||||
bool isLogin = false;
|
||||
|
||||
string[] argsuser;
|
||||
|
||||
public LoginWindow(string[] args)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (!string.IsNullOrEmpty(BaseClass.ProgramName))
|
||||
{
|
||||
lblAppName.Content = BaseClass.ProgramName;
|
||||
}
|
||||
|
||||
this.Title = "用户登录";
|
||||
argsuser = args;
|
||||
}
|
||||
|
||||
private void loginWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
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(this, "是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个。", "请先登录或者注册").DialogResult == true)
|
||||
Process.GetCurrentProcess().Kill();
|
||||
else
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (BaseMsgWindow.ShowConfirm(this, "是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个", "请先登录或者注册").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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
this.isLogin = true;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
public static void SaveUserList()
|
||||
{
|
||||
ConfigHelper.SaveConfig("user_login_config", UserParamList);
|
||||
}
|
||||
public static void GetUserList()
|
||||
{
|
||||
#region 用户账户记忆功能
|
||||
UserParamList = ConfigHelper.LoadConfig<ConcurrentList<UserParam>>("user_login_config");
|
||||
if (UserParamList == null)
|
||||
UserParamList = new ConcurrentList<UserParam>();
|
||||
#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<string>().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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user