|
|
@@ -1,4 +1,4 @@
|
|
|
-#include "../pch/pch.h"
|
|
|
+#include "../pch/pch.h"
|
|
|
#include "CLoginWnd.h"
|
|
|
#include "CUpdateWnd.h"
|
|
|
|
|
|
@@ -6,72 +6,73 @@
|
|
|
|
|
|
void CLoginWnd::Init()
|
|
|
{
|
|
|
- CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("login_version")));
|
|
|
- version->SetText((L"智铺子收银软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
|
|
|
+ //刷新版本号
|
|
|
+ CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("login_version")));
|
|
|
+ version->SetText((L"乐外卖接单软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
|
|
|
|
|
|
- std::map<string, string> users = CSetting::getUsers();
|
|
|
+ //初始化下拉框的用户名
|
|
|
+ CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
|
|
|
|
|
|
- CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
|
|
|
-
|
|
|
- for(std::map<string, string>::iterator it = users.begin(); it != users.end(); it++)
|
|
|
- {
|
|
|
- std::string username = it->first;
|
|
|
-
|
|
|
- CListLabelElementUI* elem = new CListLabelElementUI();
|
|
|
- elem->SetText(CLewaimaiString::UTF8ToUnicode(username).c_str());
|
|
|
+ std::map<string, string> users = CSetting::getUsers();
|
|
|
+ for (std::map<string, string>::iterator it = users.begin(); it != users.end(); it++)
|
|
|
+ {
|
|
|
+ std::string username = it->first;
|
|
|
+
|
|
|
+ CListLabelElementUI* elem = new CListLabelElementUI();
|
|
|
+ elem->SetText(CLewaimaiString::UTF8ToUnicode(username).c_str());
|
|
|
|
|
|
- pCom->Add(elem);
|
|
|
- }
|
|
|
+ pCom->Add(elem);
|
|
|
+ }
|
|
|
|
|
|
- CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
- CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
+ CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
+ CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
|
|
|
- if(CSetting::GetParam("setting_is_remember_password") == "1")
|
|
|
- {
|
|
|
- pRemember->Selected(true, false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pRemember->Selected(false, false);
|
|
|
- }
|
|
|
+ if (CSetting::GetParam("setting_is_remember_password") == "1")
|
|
|
+ {
|
|
|
+ pRemember->Selected(true, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pRemember->Selected(false, false);
|
|
|
+ }
|
|
|
|
|
|
- if(CSetting::GetParam("setting_is_auto_login") == "1")
|
|
|
- {
|
|
|
- //自动登录开启了,记住密码一定要开启
|
|
|
- pAuto->Selected(true, false);
|
|
|
- pRemember->Selected(true, false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pAuto->Selected(false, false);
|
|
|
- }
|
|
|
+ if (CSetting::GetParam("setting_is_auto_login") == "1")
|
|
|
+ {
|
|
|
+ //自动登录开启了,记住密码一定要开启
|
|
|
+ pAuto->Selected(true, false);
|
|
|
+ pRemember->Selected(true, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pAuto->Selected(false, false);
|
|
|
+ }
|
|
|
|
|
|
- std::string last_login_username = CSetting::GetParam("last_login_username");
|
|
|
- std::string password = CSetting::GetUser(last_login_username);
|
|
|
+ std::string last_login_username = CSetting::GetParam("last_login_username");
|
|
|
+ std::string password = CSetting::GetUser(last_login_username);
|
|
|
|
|
|
- CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
- CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
+ CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
+ CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
|
|
|
- pAccountEdit->SetText(CLewaimaiString::UTF8ToUnicode(last_login_username).c_str());
|
|
|
- pPasswordEdit->SetText(CLewaimaiString::UTF8ToUnicode(password).c_str());
|
|
|
+ pAccountEdit->SetText(CLewaimaiString::UTF8ToUnicode(last_login_username).c_str());
|
|
|
+ pPasswordEdit->SetText(CLewaimaiString::UTF8ToUnicode(password).c_str());
|
|
|
|
|
|
- if(CSetting::GetParam("setting_is_auto_login") == "1")
|
|
|
- {
|
|
|
- StartLogin();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
|
|
|
- pInput->SetVisible(true);
|
|
|
+ if (CSetting::GetParam("setting_is_auto_login") == "1")
|
|
|
+ {
|
|
|
+ StartLogin();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
|
|
|
+ pInput->SetVisible(true);
|
|
|
|
|
|
- CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
|
|
|
- pLoading->SetVisible(false);
|
|
|
- }
|
|
|
+ CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
|
|
|
+ pLoading->SetVisible(false);
|
|
|
+ }
|
|
|
|
|
|
- if(m_mode == 2)
|
|
|
- {
|
|
|
- PostMessage(WM_LOGIN_AGAIN_OUT);
|
|
|
- }
|
|
|
+ if (m_mode == 2)
|
|
|
+ {
|
|
|
+ PostMessage(WM_LOGIN_AGAIN_OUT);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void CLoginWnd::Notify(TNotifyUI& msg)
|
|
|
@@ -80,58 +81,58 @@ void CLoginWnd::Notify(TNotifyUI& msg)
|
|
|
{
|
|
|
if(msg.pSender->GetName() == _T("closebtn"))
|
|
|
{
|
|
|
- PostQuitMessage(0);
|
|
|
+ PostQuitMessage(0);
|
|
|
return;
|
|
|
}
|
|
|
else if(msg.pSender->GetName() == _T("loginBtn"))
|
|
|
{
|
|
|
- StartLogin();
|
|
|
+ StartLogin();
|
|
|
return;
|
|
|
}
|
|
|
- else if(msg.pSender->GetName() == _T("login_auto_login"))
|
|
|
- {
|
|
|
- CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
- CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
+ else if (msg.pSender->GetName() == _T("login_auto_login"))
|
|
|
+ {
|
|
|
+ CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
+ CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
|
|
|
- if(!pAuto->IsSelected())
|
|
|
- {
|
|
|
- pRemember->Selected(true, false);
|
|
|
- }
|
|
|
- }
|
|
|
- else if(msg.pSender->GetName() == _T("login_remember_password"))
|
|
|
- {
|
|
|
- CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
- CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
+ if (!pAuto->IsSelected())
|
|
|
+ {
|
|
|
+ pRemember->Selected(true, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == _T("login_remember_password"))
|
|
|
+ {
|
|
|
+ CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
+ CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
|
|
|
- if(pRemember->IsSelected())
|
|
|
- {
|
|
|
- pAuto->Selected(false, false);
|
|
|
- }
|
|
|
- }
|
|
|
- else if(msg.pSender->GetName() == _T("guanwang"))
|
|
|
- {
|
|
|
- ShellExecute(NULL, _T("open"), _T("explorer.exe"), _T("https://www.zhipuzi.com"), NULL, SW_SHOW);
|
|
|
- }
|
|
|
+ if (pRemember->IsSelected())
|
|
|
+ {
|
|
|
+ pAuto->Selected(false, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.pSender->GetName() == _T("guanwang"))
|
|
|
+ {
|
|
|
+ ShellExecute(NULL, _T("open"), _T("explorer.exe"), _T("https://www.lewaimai.com"), NULL, SW_SHOW);
|
|
|
+ }
|
|
|
}
|
|
|
- else if(msg.sType == _T("itemselect"))
|
|
|
- {
|
|
|
- CDuiString name = msg.pSender->GetName();
|
|
|
+ else if (msg.sType == _T("itemselect"))
|
|
|
+ {
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
|
|
|
- if(name == _T("accountcombo"))
|
|
|
- {
|
|
|
- CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
|
|
|
+ if (name == _T("accountcombo"))
|
|
|
+ {
|
|
|
+ CComboUI* pCom = static_cast<CComboUI*>(m_pm.FindControl(_T("accountcombo")));
|
|
|
|
|
|
- std::wstring name = pCom->GetItemAt(pCom->GetCurSel())->GetText();
|
|
|
- std::string password = CSetting::GetUser(CLewaimaiString::UnicodeToUTF8(name));
|
|
|
- std::wstring wspassword = CLewaimaiString::UTF8ToUnicode(password);
|
|
|
+ std::wstring name = pCom->GetItemAt(pCom->GetCurSel())->GetText();
|
|
|
+ std::string password = CSetting::GetUser(CLewaimaiString::UnicodeToUTF8(name));
|
|
|
+ std::wstring wspassword = CLewaimaiString::UTF8ToUnicode(password);
|
|
|
|
|
|
- CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
- pEdit->SetText(name.c_str());
|
|
|
+ CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
+ pEdit->SetText(name.c_str());
|
|
|
|
|
|
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
- pPassword->SetText(wspassword.c_str());
|
|
|
- }
|
|
|
- }
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
+ pPassword->SetText(wspassword.c_str());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
LRESULT CLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
@@ -140,9 +141,8 @@ LRESULT CLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
|
|
|
styleValue &= ~WS_CAPTION;
|
|
|
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
|
|
|
|
|
- // 把自己的窗口句柄与窗口绘制管理器挂接在一起
|
|
|
+ // 把自己的窗口句柄与窗口绘制管理器挂接在一起
|
|
|
m_pm.Init(m_hWnd);
|
|
|
-
|
|
|
m_pm.AddPreMessageFilter(this);
|
|
|
|
|
|
CDialogBuilder builder;
|
|
|
@@ -150,10 +150,10 @@ LRESULT CLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
|
|
|
CControlUI* pRoot = builder.Create(_T("login.xml"), (UINT)0, NULL, &m_pm);
|
|
|
ASSERT(pRoot && "Failed to parse XML");
|
|
|
|
|
|
- // 鎶婅繖浜涙帶浠剁粯鍒跺埌鏈�獥鍙d笂
|
|
|
+ // 把这些控件绘制到本窗口上
|
|
|
m_pm.AttachDialog(pRoot);
|
|
|
|
|
|
- // 鎶婅嚜宸卞姞鍏ュ埌CPaintManagerUI鐨刴_aNotifiers鏁扮粍涓�紝鐢ㄤ簬澶勭悊Notify鍑芥暟
|
|
|
+ // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
|
|
|
m_pm.AddNotifier(this);
|
|
|
|
|
|
Init();
|
|
|
@@ -163,17 +163,17 @@ LRESULT CLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
|
|
|
|
|
|
LRESULT CLoginWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
{
|
|
|
- bHandled = FALSE;
|
|
|
- return 0;
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- *杩欎釜鏄�獥鍙h�閿€姣佺殑鏃跺€欒皟鐢ㄧ殑
|
|
|
+ *这个是窗口被销毁的时候调用的
|
|
|
**/
|
|
|
LRESULT CLoginWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
{
|
|
|
- bHandled = FALSE;
|
|
|
- return 0;
|
|
|
+ bHandled = FALSE;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
LRESULT CLoginWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
@@ -192,14 +192,21 @@ LRESULT CLoginWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
|
|
|
|
|
|
LRESULT CLoginWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
{
|
|
|
- //鍦ㄨ繖閲岃�缃�劍鐐规墠鏈夌敤
|
|
|
- CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
- if(pAccountEdit)
|
|
|
- {
|
|
|
- pAccountEdit->SetFocus();
|
|
|
- }
|
|
|
+ //在这里设置焦点才有用
|
|
|
+ CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
+ if (pAccountEdit)
|
|
|
+ {
|
|
|
+ //下一个焦点的,就设置为这个控件
|
|
|
+ m_pm.SetFocusNeeded(pAccountEdit);
|
|
|
|
|
|
- return 0;
|
|
|
+ //用户名设置为焦点
|
|
|
+ pAccountEdit->SetFocus();
|
|
|
+
|
|
|
+ //这个干嘛的不知道,但是不加好像不行
|
|
|
+ //m_pm.SetNextTabControl(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
LRESULT CLoginWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
@@ -247,80 +254,80 @@ LRESULT CLoginWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandle
|
|
|
|
|
|
LRESULT CLoginWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
{
|
|
|
- LRESULT lRes = 0;
|
|
|
- BOOL bHandled = TRUE;
|
|
|
- switch (uMsg)
|
|
|
- {
|
|
|
- case WM_CREATE:
|
|
|
- lRes = OnCreate(uMsg, wParam, lParam, bHandled);
|
|
|
- break;
|
|
|
+ LRESULT lRes = 0;
|
|
|
+ BOOL bHandled = TRUE;
|
|
|
+ switch(uMsg)
|
|
|
+ {
|
|
|
+ case WM_CREATE:
|
|
|
+ lRes = OnCreate(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
case WM_CLOSE:
|
|
|
lRes = OnClose(uMsg, wParam, lParam, bHandled);
|
|
|
break;
|
|
|
case WM_DESTROY:
|
|
|
lRes = OnDestroy(uMsg, wParam, lParam, bHandled);
|
|
|
break;
|
|
|
- case WM_NCACTIVATE:
|
|
|
- lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
|
|
|
- break;
|
|
|
- case WM_NCCALCSIZE:
|
|
|
- lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
|
|
|
- break;
|
|
|
- case WM_NCPAINT:
|
|
|
- lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
|
|
|
- break;
|
|
|
- case WM_NCHITTEST:
|
|
|
- lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
|
|
|
- break;
|
|
|
- case WM_SIZE:
|
|
|
- lRes = OnSize(uMsg, wParam, lParam, bHandled);
|
|
|
- break;
|
|
|
- default:
|
|
|
- bHandled = FALSE;
|
|
|
- }
|
|
|
- if (bHandled)
|
|
|
- {
|
|
|
- return lRes;
|
|
|
- }
|
|
|
- if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
|
|
|
- {
|
|
|
- return lRes;
|
|
|
- }
|
|
|
- return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
+ case WM_NCACTIVATE:
|
|
|
+ lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCCALCSIZE:
|
|
|
+ lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCPAINT:
|
|
|
+ lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_NCHITTEST:
|
|
|
+ lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ case WM_SIZE:
|
|
|
+ lRes = OnSize(uMsg, wParam, lParam, bHandled);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ bHandled = FALSE;
|
|
|
+ }
|
|
|
+ if(bHandled)
|
|
|
+ {
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+ if(m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
|
|
|
+ {
|
|
|
+ return lRes;
|
|
|
+ }
|
|
|
+ return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
}
|
|
|
|
|
|
LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
{
|
|
|
- if (uMsg == WM_KEYDOWN)
|
|
|
- {
|
|
|
- if (wParam == VK_RETURN)
|
|
|
- {
|
|
|
- CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
- if (pEdit->GetText().IsEmpty())
|
|
|
- {
|
|
|
- pEdit->SetFocus();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
- if (pEdit->GetText().IsEmpty())
|
|
|
- {
|
|
|
- pEdit->SetFocus();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this->HandleLogin();
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- else if (wParam == VK_ESCAPE)
|
|
|
- {
|
|
|
- PostQuitMessage(0);
|
|
|
- return true;
|
|
|
- }
|
|
|
+ if(uMsg == WM_KEYDOWN)
|
|
|
+ {
|
|
|
+ if(wParam == VK_RETURN)
|
|
|
+ {
|
|
|
+ CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
+ if(pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ pEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
+ if(pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ pEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ this->HandleLogin();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if(wParam == VK_ESCAPE)
|
|
|
+ {
|
|
|
+ PostQuitMessage(0);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
else if (uMsg == WM_LOGIN_SUCCESS)
|
|
|
{
|
|
|
LoginSuccess();
|
|
|
@@ -333,7 +340,7 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
|
|
|
}
|
|
|
else if (uMsg == WM_NEED_UPDATE)
|
|
|
{
|
|
|
- //璇存槑闇€瑕佸崌绾т簡
|
|
|
+ //说明需要升级了
|
|
|
|
|
|
Update();
|
|
|
|
|
|
@@ -346,122 +353,122 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
void CLoginWnd::StartLogin()
|
|
|
{
|
|
|
- //隐藏密码输入框,显示进度条
|
|
|
- CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
|
|
|
- pInput->SetVisible(false);
|
|
|
+ //隐藏密码输入框,显示进度条
|
|
|
+ CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
|
|
|
+ pInput->SetVisible(false);
|
|
|
|
|
|
- CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
|
|
|
- pLoading->SetVisible(true);
|
|
|
+ CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
|
|
|
+ pLoading->SetVisible(true);
|
|
|
|
|
|
- CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
- pLoginResultLabel->SetVisible(false);
|
|
|
+ CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
+ pLoginResultLabel->SetVisible(false);
|
|
|
|
|
|
- //开启一个线程,开始处理登录
|
|
|
- std::thread(&CLoginWnd::HandleLogin, this).detach();
|
|
|
+ //开启一个线程,开始处理登录
|
|
|
+ std::thread(&CLoginWnd::HandleLogin, this).detach();
|
|
|
}
|
|
|
|
|
|
void CLoginWnd::HandleLogin()
|
|
|
{
|
|
|
CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
|
|
|
- //真正登录前,先检测是否有需要更新
|
|
|
- //std::map<string, string> params;
|
|
|
-
|
|
|
- //std::string response;
|
|
|
- //bool ret = CZhipuziHttpClient::Request("/version/getwindowsversion", params, response);
|
|
|
- //if (!ret)
|
|
|
- //{
|
|
|
- // pLoginResultLabel->SetText(std::wstring(_T("缃戠粶璇锋眰鍑洪敊")).c_str());
|
|
|
- // pLoginResultLabel->SetVisible(true);
|
|
|
+ //真正登录前,先检测是否有需要更新
|
|
|
+ std::map<string, string> params;
|
|
|
|
|
|
- // PostMessage(WM_LOGIN_ERROR);
|
|
|
+ std::string response;
|
|
|
+ bool ret = CLewaimaiHttpClient::Request("/version/getwindowsversion", params, response);
|
|
|
+ if (!ret)
|
|
|
+ {
|
|
|
+ pLoginResultLabel->SetText(std::wstring(_T("网络请求出错")).c_str());
|
|
|
+ pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
- // return;
|
|
|
- //}
|
|
|
+ PostMessage(WM_LOGIN_ERROR);
|
|
|
|
|
|
- //rapidjson::Document document;
|
|
|
- //document.Parse(response.c_str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //if (document.HasParseError())
|
|
|
- //{
|
|
|
- // pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
|
|
|
- // pLoginResultLabel->SetVisible(true);
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
|
|
|
- // PostMessage(WM_LOGIN_ERROR);
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
|
|
|
+ pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
- // return;
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
- // {
|
|
|
- // pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
|
|
|
- // pLoginResultLabel->SetVisible(true);
|
|
|
+ PostMessage(WM_LOGIN_ERROR);
|
|
|
|
|
|
- // PostMessage(WM_LOGIN_ERROR);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
+ {
|
|
|
+ pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
|
|
|
+ pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ PostMessage(WM_LOGIN_ERROR);
|
|
|
|
|
|
- // rapidjson::Value& v_errcode = document["errcode"];
|
|
|
- // int errcode = v_errcode.GetInt();
|
|
|
- // if (errcode != 0)
|
|
|
- // {
|
|
|
- // std::string errmsg = "response failed! message:" + string(document["errmsg"].GetString());
|
|
|
- // pLoginResultLabel->SetText(CLewaimaiString::UTF8ToUnicode(errmsg).c_str());
|
|
|
- // pLoginResultLabel->SetVisible(true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // PostMessage(WM_LOGIN_ERROR);
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ std::string errmsg = "response failed! message:" + string(document["errmsg"].GetString());
|
|
|
+ pLoginResultLabel->SetText(CLewaimaiString::UTF8ToUnicode(errmsg).c_str());
|
|
|
+ pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
- // return;
|
|
|
- // }
|
|
|
+ PostMessage(WM_LOGIN_ERROR);
|
|
|
|
|
|
- // rapidjson::Value& data = document["data"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // std::string newest_version = data["newest_version"].GetString();
|
|
|
- // m_update_url = data["url"].GetString();
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
|
|
|
- // if (newest_version > CSystem::GetVersion())
|
|
|
- // {
|
|
|
- // //璇存槑鏈夋柊鐗堟湰锛岃�鏇存柊
|
|
|
- // PostMessage(WM_NEED_UPDATE);
|
|
|
- // return;
|
|
|
- // }
|
|
|
- //}
|
|
|
+ std::string newest_version = data["newest_version"].GetString();
|
|
|
+ m_update_url = data["url"].GetString();
|
|
|
|
|
|
- //鍒ゆ柇璐﹀彿瀵嗙爜鏄�惁姝g‘
|
|
|
- std::wstring account, password;
|
|
|
- CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
- if (pAccountEdit)
|
|
|
- {
|
|
|
- account = pAccountEdit->GetText().GetData();
|
|
|
+ if (newest_version > CSystem::GetVersion())
|
|
|
+ {
|
|
|
+ //说明有新版本,要更新
|
|
|
+ PostMessage(WM_NEED_UPDATE);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
- if (pPasswordEdit)
|
|
|
- {
|
|
|
- password = pPasswordEdit->GetText().GetData();
|
|
|
- }
|
|
|
+ //判断账号密码是否正确
|
|
|
+ std::wstring account, password;
|
|
|
+ CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
|
|
|
+ if(pAccountEdit)
|
|
|
+ {
|
|
|
+ account = pAccountEdit->GetText().GetData();
|
|
|
+ }
|
|
|
+
|
|
|
+ CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("pwdedit")));
|
|
|
+ if(pPasswordEdit)
|
|
|
+ {
|
|
|
+ password = pPasswordEdit->GetText().GetData();
|
|
|
+ }
|
|
|
|
|
|
- //鎶婄�1涓�腑鏂囧啋鍙锋浛鎹㈡垚鑻辨枃鍐掑彿
|
|
|
- CLewaimaiString::Replace(account, _T(":"), _T(":"), 1);
|
|
|
+ //把第1个中文冒号替换成英文冒号
|
|
|
+ CLewaimaiString::Replace(account, _T(":"), _T(":"), 1);
|
|
|
|
|
|
- //LOG_INFO("account:" << account.c_str() << ", password:" << password.c_str());
|
|
|
+ //LOG_INFO("account:" << account.c_str() << ", password:" << password.c_str());
|
|
|
|
|
|
- string s_account = CLewaimaiString::UnicodeToUTF8(account);
|
|
|
- string s_password = CLewaimaiString::UnicodeToUTF8(password);
|
|
|
+ string s_account = CLewaimaiString::UnicodeToUTF8(account);
|
|
|
+ string s_password = CLewaimaiString::UnicodeToUTF8(password);
|
|
|
|
|
|
CLewaimaiString::trim(s_account);
|
|
|
CLewaimaiString::trim(s_password);
|
|
|
|
|
|
if (s_account.compare("") == 0)
|
|
|
{
|
|
|
- pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
|
|
|
+ pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
PostMessage(WM_LOGIN_ERROR);
|
|
|
@@ -471,7 +478,7 @@ void CLoginWnd::HandleLogin()
|
|
|
|
|
|
if (s_password.compare("") == 0)
|
|
|
{
|
|
|
- pLoginResultLabel->SetText(std::wstring(_T("瀵嗙爜涓嶈兘涓虹┖")).c_str());
|
|
|
+ pLoginResultLabel->SetText(std::wstring(_T("密码不能为空")).c_str());
|
|
|
pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
PostMessage(WM_LOGIN_ERROR);
|
|
|
@@ -479,13 +486,13 @@ void CLoginWnd::HandleLogin()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- CZhipuziHttpClient::Init(s_account, s_password);
|
|
|
+ CLewaimaiHttpClient::Init(s_account, s_password);
|
|
|
|
|
|
- std::string errmsg;
|
|
|
- bool res = CZhipuziHttpClient::Login(errmsg);
|
|
|
+ std::string errmsg;
|
|
|
+ bool res = CLewaimaiHttpClient::Login(errmsg);
|
|
|
|
|
|
- if (res)
|
|
|
- {
|
|
|
+ if(res)
|
|
|
+ {
|
|
|
CCheckBoxUI* pAuto = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_auto_login")));
|
|
|
CCheckBoxUI* pRemember = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("login_remember_password")));
|
|
|
|
|
|
@@ -494,7 +501,7 @@ void CLoginWnd::HandleLogin()
|
|
|
CSetting::SetParam("setting_is_auto_login", "1", false);
|
|
|
CSetting::SetParam("setting_is_remember_password", "1", false);
|
|
|
|
|
|
- //相当于开启自动登录,默认就是开启了记住密码了
|
|
|
+ //相当于开启自动登录,默认就是开启了记住密码了
|
|
|
CSetting::SetUser(s_account, s_password, true);
|
|
|
}
|
|
|
else
|
|
|
@@ -519,57 +526,57 @@ void CLoginWnd::HandleLogin()
|
|
|
{
|
|
|
CSetting::SetUser(s_account, "", true);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- //鍦ㄨ繖閲岃�缃�畬鍙傛暟鍚庯紝缁熶竴淇濆瓨鍒版暟鎹�簱
|
|
|
+ //在这里设置完参数后,统一保存到数据库
|
|
|
CSetting::SetParam("last_login_username", s_account, true);
|
|
|
|
|
|
- //把用户名和密码保存起来
|
|
|
+ //把用户名和密码保存起来
|
|
|
CSetting::SetLoginInfo(s_account, s_password);
|
|
|
|
|
|
PostMessage(WM_LOGIN_SUCCESS);
|
|
|
|
|
|
return;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //登录失败了
|
|
|
- CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
-
|
|
|
- pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
|
|
|
- pLoginResultLabel->SetVisible(true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //登录失败了
|
|
|
+ pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
|
|
|
+ pLoginResultLabel->SetVisible(true);
|
|
|
|
|
|
PostMessage(WM_LOGIN_ERROR);
|
|
|
- }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void CLoginWnd::LoginSuccess()
|
|
|
{
|
|
|
- CMainWnd* pFrame = new CMainWnd();
|
|
|
- if(pFrame == NULL)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ CMainWnd* pFrame = new CMainWnd();
|
|
|
+ if (pFrame == NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- pFrame->SetIcon(IDI_ICON_DUILIB);
|
|
|
- pFrame->Create(NULL, _T("智铺子收银软件"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 768);
|
|
|
- pFrame->CenterWindow();
|
|
|
+ pFrame->SetIcon(IDI_ICON_DUILIB);
|
|
|
+ pFrame->Create(NULL, _T("乐外卖接单软件"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 768);
|
|
|
+ pFrame->CenterWindow();
|
|
|
|
|
|
- ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
|
|
|
+ ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
|
|
|
|
|
|
- Close();
|
|
|
+ Close();
|
|
|
}
|
|
|
|
|
|
void CLoginWnd::LoginError()
|
|
|
{
|
|
|
- CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
|
|
|
- pInput->SetVisible(true);
|
|
|
+ CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
|
|
|
+ pInput->SetVisible(true);
|
|
|
|
|
|
- CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
|
|
|
- pLoading->SetVisible(false);
|
|
|
+ CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
|
|
|
+ pLoading->SetVisible(false);
|
|
|
|
|
|
- CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
- pLoginResultLabel->SetVisible(true);
|
|
|
+ CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
|
|
|
+ pLoginResultLabel->SetVisible(true);
|
|
|
}
|
|
|
|
|
|
void CLoginWnd::Update()
|
|
|
@@ -588,7 +595,7 @@ void CLoginWnd::Update()
|
|
|
pFrame->InitData(url, filename);
|
|
|
|
|
|
pFrame->SetIcon(IDI_ICON_DUILIB);
|
|
|
- pFrame->Create(NULL, _T("鑷�姩鏇存柊"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
|
|
|
+ pFrame->Create(NULL, _T("自动更新"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
|
|
|
pFrame->CenterWindow();
|
|
|
|
|
|
::ShowWindow(*pFrame, SW_SHOWNORMAL);
|
|
|
@@ -598,12 +605,10 @@ void CLoginWnd::Update()
|
|
|
|
|
|
void CLoginWnd::ShowLoginAgainOut()
|
|
|
{
|
|
|
- //这种模式是本人强制挤下线了
|
|
|
- CMessageboxWnd* pMessagebox = new CMessageboxWnd;
|
|
|
- pMessagebox->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
|
|
|
- pMessagebox->SetIcon(IDI_ICON_DUILIB);
|
|
|
- pMessagebox->CenterWindow();
|
|
|
- UINT ret = pMessagebox->ShowModal();
|
|
|
+ //这种模式是本人强制挤下线了
|
|
|
+ CMessageboxWnd* pMessagebox = new CMessageboxWnd;
|
|
|
+ pMessagebox->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
|
|
|
+ pMessagebox->SetIcon(IDI_ICON_DUILIB);
|
|
|
+ pMessagebox->CenterWindow();
|
|
|
+ UINT ret = pMessagebox->ShowModal();
|
|
|
}
|
|
|
-
|
|
|
-
|