537 lines
15 KiB
C#
537 lines
15 KiB
C#
using AllBase;
|
|
using AllBase.Helper;
|
|
using CefSharp;
|
|
using CefSharp.WinForms;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using TemuKJD.BaseForms;
|
|
using Work;
|
|
using Work.Store.Api;
|
|
|
|
namespace TemuKJD.UserForm
|
|
{
|
|
public partial class LoginForm : BaseForm
|
|
{
|
|
|
|
private Point mouseOffset;//记录鼠标指针的坐标
|
|
private bool isMouseDown;//记录鼠标左键是否按下
|
|
public MainForm mf;
|
|
public delegate void delegateView();
|
|
private DevComponents.DotNetBar.PanelEx pnlRememberBox = null;
|
|
public static List<UserParam> UserParamList { get; set; } = new List<UserParam>();
|
|
|
|
public LoginForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void SetMobile(string m)
|
|
{
|
|
txtMobile.Text = m;
|
|
}
|
|
|
|
private void LoginForm_Load(object sender, EventArgs e)
|
|
{
|
|
if (BaseClass.MainPath == "29pdd")
|
|
{
|
|
this.pnlLoginBg.Style.BackgroundImage = Properties.Resources.pdd_bg;
|
|
this.pnlLoginBg.Style.BackgroundImagePosition = DevComponents.DotNetBar.eBackgroundImagePosition.Stretch;
|
|
//this.pbLogo.Image = Properties.Resources.pdd_logo;
|
|
}
|
|
if (BaseClass.MainPath == "29wx")
|
|
{
|
|
this.pnlLoginBg.Style.BackgroundImage = Properties.Resources.weixin_bg;
|
|
this.pnlLoginBg.Style.BackgroundImagePosition = DevComponents.DotNetBar.eBackgroundImagePosition.Stretch;
|
|
//this.pbLogo.Image = Properties.Resources.weixin_logo;
|
|
}
|
|
this.pbLogo.Image = BaseClass.LogoImage;
|
|
|
|
GetUserList();
|
|
#if DEBUG
|
|
if (File.Exists(System.Environment.CurrentDirectory + "\\choice.debug.tools"))
|
|
{
|
|
grpEnvironmentChoice.Visible = true;
|
|
pnlShowRemember.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
grpEnvironmentChoice.Visible = false;
|
|
//pnlShowRemember.Visible = false;
|
|
rbtPrd.Checked = true;
|
|
}
|
|
grpEnvironmentChoice.Visible = true;
|
|
rbtDev.Checked = EnvironmentHelper.IsDevelopment;
|
|
#else
|
|
grpEnvironmentChoice.Visible = false;
|
|
//pnlShowRemember.Visible = false;
|
|
rbtPrd.Checked = true;
|
|
#endif
|
|
|
|
if (BaseClass.Ico != null)
|
|
Icon = BaseClass.Ico;
|
|
|
|
Text = "登录 " + BaseClass.ToolName;
|
|
if (BaseClass.LoginImage != null)
|
|
pnlLoginBg.Style.BackgroundImage = BaseClass.LoginImage;
|
|
|
|
lblSignUp.Visible = BaseClass.ToolName == "跨境达-管理工具";
|
|
lblSignUp.Visible = false;
|
|
if (FileBase.Exists("locales/ii.pak"))
|
|
{
|
|
string agentConfig = FileBase.ReadAllText("locales/ii.pak");
|
|
if (agentConfig.Contains("\n"))
|
|
{
|
|
List<string> lstAgentConfig = agentConfig.Split('\n').ToList();
|
|
//0--显示 1--隐藏
|
|
lblSignUp.Visible = lstAgentConfig[0].Trim().Equals("0"); // 是否显示注册功能
|
|
//BaseClass.NoAnnounce = lstAgentConfig[1].Trim().Equals("1"); // 是否显示产品公告
|
|
//if (lstAgentConfig.Count == 3)
|
|
//{
|
|
// BaseClass.ShowGuidance = lstAgentConfig[2].Trim().Equals("0"); //是否显示使用指南
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
lblSignUp.Visible = agentConfig.Equals("0");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblSignUp.Visible = BaseClass.IsShowRegister;
|
|
lblBuy.Visible = BaseClass.IsShowOpenAccount;
|
|
}
|
|
lblSignUp.Visible = false;
|
|
lblBuy.Visible = false;
|
|
txtMobile.Text = BaseClass.UserName;
|
|
if (BaseClass.Remember)
|
|
{
|
|
chkRemember.Checked = true;
|
|
if (!string.IsNullOrEmpty(BaseClass.PassWord))
|
|
password.Text = "******";
|
|
}
|
|
LogSave.ClearFile();
|
|
|
|
if (File.Exists("locales/wl.pak"))
|
|
{
|
|
lblSignUp.Visible = false;
|
|
lblBuy.Visible = false;
|
|
}
|
|
|
|
// 是否显示联系客服按钮
|
|
if (FileBase.Exists("locales/ig.pak") || FileBase.Exists("locales/wl.pak"))
|
|
lblContactSupport.Visible = false;
|
|
else
|
|
lblContactSupport.Visible = true;
|
|
lblContactSupport.Visible = false;
|
|
}
|
|
|
|
private void lblSignUp_Click(object sender, EventArgs e)
|
|
{
|
|
GetHtml.OpenUrl("http://dd.9u99.com/?obj=public/register");
|
|
//RegeditForm r = new RegeditForm();
|
|
//r.lf = this;
|
|
//r.ShowDialog();
|
|
}
|
|
|
|
private void lblResetPassword_Click(object sender, EventArgs e)
|
|
{
|
|
ResetPasswordForm r = new ResetPasswordForm();
|
|
r.ShowDialog();
|
|
}
|
|
|
|
private void remember_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
BaseClass.Remember = chkRemember.Checked;
|
|
}
|
|
|
|
private void autoLogin_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
BaseClass.AutoLogin = autoLogin.Checked;
|
|
if (autoLogin.Checked)
|
|
chkRemember.Checked = true;
|
|
}
|
|
|
|
private void loginPanel_Click(object sender, EventArgs e)
|
|
{
|
|
if (rbtDev.Checked)
|
|
{
|
|
BaseClass.LoginApiUrl = "http://localhost:9000";
|
|
}
|
|
else
|
|
BaseClass.LoginApiUrl = BaseClass.ServerUrl;
|
|
//"http://localhost:8000/user/user_login"
|
|
|
|
UserLogin ul = new UserLogin();
|
|
ul.Mobile = txtMobile.Text;
|
|
ul.Password = password.Text;
|
|
if (txtMobile.Text.Length != 11)
|
|
{
|
|
MessageBox.Show("手机号不正确", "提示");
|
|
txtMobile.Focus();
|
|
return;
|
|
}
|
|
if (password.Text.Length < 6)
|
|
{
|
|
MessageBox.Show("密码长度不正确", "提示");
|
|
password.Text = "";
|
|
password.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 && BaseClass.Remember)
|
|
{
|
|
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 (!ok)
|
|
{
|
|
if (message.Contains("账户已过期"))
|
|
{
|
|
if (lblBuy.Visible == false)
|
|
BaseMsgForm.ShowError(message + ",请先联系客服商务开户!", "登录失败");
|
|
else
|
|
{
|
|
BaseMsgForm.ShowError(message + ",请在弹出网页购买开户", "登录失败");
|
|
GetHtml.OpenUrl("http://dd.jindouduo.com/?obj=open");
|
|
}
|
|
}
|
|
else
|
|
BaseMsgForm.ShowError(message, "登录失败");
|
|
return;
|
|
}
|
|
if (lockUserName == 1)
|
|
{
|
|
BaseMsgForm.ShowError(messageInfo, "账户锁定提醒", FormLevel.MEDIUM);
|
|
return;
|
|
}
|
|
//if (lockUserName == 0 && weakPassword == 1)
|
|
//{
|
|
// BaseMsgForm.ShowError(messageInfo, "登录密码提醒", FormLevel.MEDIUM);
|
|
//}
|
|
//if (BaseClass.GroupId != 3 && BaseClass.GroupId != 4 && BaseClass.GroupId != 8 && BaseClass.GroupId != 9 && BaseClass.GroupId != 10 && BaseClass.GroupId != 11)
|
|
//{
|
|
// BaseMsgForm.ShowError("您当前无权限登录系统", "登录失败");
|
|
// return;
|
|
//}
|
|
|
|
//this.mf.pnlShop.Visible /*= this.mf.pnlCollect.Visible*/ = this.mf.pnlTools.Visible = this.mf.pnlUpload.Visible = true;
|
|
//if (BaseClass.DyProductCollect)
|
|
//{
|
|
// this.mf.pnlCollect.Visible = true;
|
|
//}
|
|
//mf.SetTitle();
|
|
|
|
//if (BaseClass.GroupId == 5 || BaseClass.GroupId == 10 || BaseClass.GroupId == 11) // 上货
|
|
//{
|
|
// mf.ShowTaobaoLoginAndInitModule();
|
|
// Close();
|
|
// return;
|
|
//}
|
|
//if (BaseClass.GroupId == 4) // 客服
|
|
//{
|
|
// Task.Run(() =>
|
|
// {
|
|
// Thread.Sleep(1000);
|
|
// Invoke(new Action(() =>
|
|
// {
|
|
// ChatForms.ChatForm cf = new ChatForms.ChatForm();
|
|
// cf.Show();
|
|
// cf.SetTitle();
|
|
// this.mf.Hide();
|
|
// Hide();
|
|
// }));
|
|
// });
|
|
// return;
|
|
//}
|
|
//if (BaseClass.GroupId == 8)
|
|
//{
|
|
// Process p = new Process();
|
|
// p.StartInfo.FileName = "TaobaoLoginer.exe";
|
|
// p.StartInfo.Arguments = BaseClass.UserName + " " + BaseClass.PassWord;
|
|
// p.StartInfo.UseShellExecute = true;
|
|
// p.StartInfo.Verb = "runas";
|
|
// p.Start();
|
|
// Process.GetCurrentProcess().Kill();
|
|
// return;
|
|
//}
|
|
//if (BaseClass.GroupId == 9)
|
|
//{
|
|
// Process p = new Process();
|
|
// p.StartInfo.FileName = "FindLittleRabbitOrder.exe";
|
|
// p.StartInfo.Arguments = BaseClass.UserName + " " + BaseClass.PassWord;
|
|
// p.StartInfo.UseShellExecute = true;
|
|
// p.StartInfo.Verb = "runas";
|
|
// p.Start();
|
|
// Process.GetCurrentProcess().Kill();
|
|
// return;
|
|
//}
|
|
|
|
|
|
|
|
//_ = Task.Run(() =>
|
|
//{
|
|
// try
|
|
// {
|
|
// StoreApiClient.Instance.Auth.Login(new LoginRequest
|
|
// {
|
|
// UserName = BaseClass.UserName,
|
|
// Password = BaseClass.PassWord
|
|
// });
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// try
|
|
// {
|
|
// LogSave.AddFile("Store API 登录失败:" + ex.Message);
|
|
// }
|
|
// catch
|
|
// {
|
|
// // 日志失败也不能影响主程序。
|
|
// }
|
|
// }
|
|
//});
|
|
|
|
Hide();
|
|
mf.Hide();
|
|
|
|
ChangeForm c = new ChangeForm();
|
|
c.mf = mf;
|
|
c.ShowDialog();
|
|
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
private void panelEx1_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (isMouseDown)
|
|
{
|
|
//获取鼠标的位置
|
|
Point mousePos = MousePosition;
|
|
mousePos.Offset(mouseOffset.X, mouseOffset.Y);
|
|
Location = mousePos;
|
|
}
|
|
}
|
|
|
|
private void panelEx1_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
mouseOffset = new Point(-e.X, -e.Y);
|
|
isMouseDown = true;
|
|
}
|
|
}
|
|
|
|
private void panelEx1_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
isMouseDown = false;
|
|
}
|
|
|
|
private void closePanel_Click(object sender, EventArgs e)
|
|
{
|
|
if (BaseMsgForm.ShowConfirm("是否关闭软件?\r\n必须登录账户才能使用,无账户请先注册一个", "请先登录或者注册", FormLevel.LARGE).DialogResult == DialogResult.OK)
|
|
Process.GetCurrentProcess().Kill();
|
|
}
|
|
|
|
private void password_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar == 13)
|
|
loginPanel_Click(null, null);
|
|
}
|
|
|
|
private void pnlShowRemember_Click(object sender, EventArgs e)
|
|
{
|
|
if (pnlShowRemember.Text == "▲")
|
|
{
|
|
if (pnlRememberBox != null)
|
|
{
|
|
pnlRememberBox.Controls.Clear();
|
|
pnlRememberBox.Visible = false;
|
|
}
|
|
pnlShowRemember.Text = "▼";
|
|
return;
|
|
}
|
|
|
|
pnlShowRemember.Text = "▲";
|
|
|
|
ShowUserDropDown();
|
|
}
|
|
|
|
private void ShowUserDropDown()
|
|
{
|
|
if (pnlRememberBox == null)
|
|
{
|
|
pnlRememberBox = new DevComponents.DotNetBar.PanelEx();
|
|
pnlRememberBox.Location = new Point(panelEx3.Location.X + txtMobile.Location.X, panelEx3.Location.Y + txtMobile.Location.Y + txtMobile.Height + 1);
|
|
pnlRememberBox.Height = 120;
|
|
pnlRememberBox.Width = pnlShowRemember.Location.X + pnlShowRemember.Width - txtMobile.Location.X;
|
|
pnlRememberBox.AutoScroll = true;
|
|
pnlRememberBox.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
|
|
pnlRememberBox.Style.BorderColor.Color = Color.FromArgb(210, 210, 210);
|
|
pnlRememberBox.Padding = new Padding(1);
|
|
pnlRememberBox.Style.BackColor1.Color = Color.White;
|
|
pnlRememberBox.Style.BackColor2.Color = Color.White;
|
|
pnlRememberBox.MouseLeave += PnlRememberBox_MouseLeave;
|
|
|
|
this.Controls.Add(pnlRememberBox);
|
|
pnlRememberBox.BringToFront();
|
|
}
|
|
|
|
pnlRememberBox.Visible = true;
|
|
pnlRememberBox.Controls.Clear();
|
|
int top = 0;
|
|
foreach (var user in UserParamList)
|
|
{
|
|
var pnlUser = new DevComponents.DotNetBar.PanelEx();
|
|
pnlUser.Dock = DockStyle.Top;
|
|
pnlUser.Location = new Point(0, top);
|
|
pnlUser.Tag = user;
|
|
pnlUser.Height = 30;
|
|
pnlUser.Text = user.UserName;
|
|
pnlUser.Style.ForeColor.Color = Color.FromArgb(80, 80, 80);
|
|
pnlUser.Style.Font = txtMobile.Font;
|
|
pnlUser.Style.BackColor1.Color = Color.Transparent;
|
|
pnlUser.Style.BackColor2.Color = Color.Transparent;
|
|
pnlUser.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.Bottom;
|
|
pnlUser.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine;
|
|
pnlUser.Style.BorderColor.Color = Color.FromArgb(225, 225, 225);
|
|
pnlUser.Click += PnlUser_Click;
|
|
|
|
pnlRememberBox.Controls.Add(pnlUser);
|
|
|
|
var pnlClose = new DevComponents.DotNetBar.PanelEx();
|
|
pnlClose.Location = new Point(146, 7);
|
|
pnlClose.Tag = user;
|
|
pnlClose.Height = 16;
|
|
pnlClose.Width = 16;
|
|
pnlClose.Text = "x";
|
|
pnlClose.Style.Font = txtMobile.Font;
|
|
pnlClose.Style.Alignment = StringAlignment.Center;
|
|
pnlClose.Style.ForeColor.Color = Color.FromArgb(80, 80, 80);
|
|
pnlClose.Style.BackColor1.Color = Color.Transparent;
|
|
pnlClose.Style.BackColor2.Color = Color.Transparent;
|
|
pnlClose.Style.Border = DevComponents.DotNetBar.eBorderType.None;
|
|
pnlClose.StyleMouseOver.Alignment = StringAlignment.Center;
|
|
pnlClose.StyleMouseOver.ForeColor.Color = Color.FromArgb(255, 255, 255);
|
|
pnlClose.StyleMouseOver.BackColor1.Color = Color.FromArgb(127, 127, 127);
|
|
pnlClose.StyleMouseOver.BackColor2.Color = Color.FromArgb(127, 127, 127);
|
|
pnlClose.Cursor = Cursors.Hand;
|
|
pnlClose.Click += PnlClose_Click;
|
|
|
|
pnlUser.Controls.Add(pnlClose);
|
|
|
|
top += 30;
|
|
}
|
|
}
|
|
|
|
private void PnlClose_Click(object sender, EventArgs e)
|
|
{
|
|
var pnl = sender as DevComponents.DotNetBar.PanelEx;
|
|
if (pnl != null)
|
|
{
|
|
var user = pnl.Tag as UserParam;
|
|
if (user != null)
|
|
{
|
|
UserParamList.Remove(user);
|
|
SaveUserList();
|
|
ShowUserDropDown();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void PnlUser_Click(object sender, EventArgs e)
|
|
{
|
|
var user = (sender as Panel)?.Tag as UserParam;
|
|
if (user != null)
|
|
{
|
|
BaseClass.UserName = user.UserName;
|
|
BaseClass.PassWord = user.PasswordMd5;
|
|
this.txtMobile.Text = user.UserName;
|
|
this.password.Text = "******";
|
|
}
|
|
pnlRememberBox.Controls.Clear();
|
|
pnlRememberBox.Visible = false;
|
|
pnlShowRemember.Text = "▼";
|
|
}
|
|
|
|
private void PnlRememberBox_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
public static void GetUserList()
|
|
{
|
|
//if (File.Exists("config\\user_login_config"))
|
|
{
|
|
try
|
|
{
|
|
//var txt = FileBase.ReadAllText("config\\user_login_config", System.Text.Encoding.UTF8);
|
|
//UserParamList = JsonHelper.DeserializeJsonToList<UserParam>(txt);
|
|
|
|
UserParamList = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<UserParam>>("user_login_config");
|
|
if (UserParamList == null)
|
|
UserParamList = new List<UserParam>();
|
|
}
|
|
catch
|
|
{
|
|
UserParamList = new List<UserParam>();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void SaveUserList()
|
|
{
|
|
//if (!Directory.Exists("config"))
|
|
//{
|
|
// Directory.CreateDirectory("config");
|
|
//}
|
|
//try
|
|
//{
|
|
// var txt = JsonHelper.SerializeObject(UserParamList);
|
|
// FileBase.WriteAllText("config\\user_login_config", txt, System.Text.Encoding.UTF8);
|
|
//}
|
|
//catch
|
|
//{
|
|
//}
|
|
|
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig("user_login_config", UserParamList);
|
|
}
|
|
|
|
private void lblBuy_Click(object sender, EventArgs e)
|
|
{
|
|
GetHtml.OpenUrl("http://dd.jindouduo.com/?obj=open");
|
|
}
|
|
|
|
private void lblContactSupport_Click(object sender, EventArgs e)
|
|
{
|
|
SupportQrCodeForm qrForm = new SupportQrCodeForm();
|
|
qrForm.ShowDialog();
|
|
}
|
|
}
|
|
|
|
public class UserParam
|
|
{
|
|
public string UserName { get; set; }
|
|
public string PasswordMd5 { get; set; }
|
|
}
|
|
}
|