| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990 |
- #include "../pch/pch.h"
- #include "CMemberLoginWnd.h"
- #include "CMessageboxWnd.h"
- #include "../helper/CSpeech.h"
- #include "../helper/MD5.h"
- #define WM_TIMER_WND_CLOSE 200001
- void CMemberLoginWnd::Init()
- {
- //::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
- }
- void CMemberLoginWnd::Notify(TNotifyUI& msg)
- {
- DuiLib::CDuiString senderName = msg.pSender->GetName();
- if (msg.sType == _T("click"))
- {
- if (msg.pSender->GetName() == _T("closebtn"))
- {
- StartClose();
- }
- else if (msg.pSender->GetName() == _T("shoukuanBtn"))
- {
- StartLogin();
- }
- else if (msg.pSender->GetName() == L"shoukuan_btn_saomazhifu")
- {
- CHorizontalLayoutUI* pFukuanmaLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_fukuanma_layout")));
- pFukuanmaLayout->SetVisible(true);
- CHorizontalLayoutUI* pShoujihaoLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_shoujihao_layout")));
- pShoujihaoLayout->SetVisible(false);
- CHorizontalLayoutUI* pShitikaLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_shitika_layout")));
- pShitikaLayout->SetVisible(false);
- CButtonUI* pFukuanmaBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_saomazhifu")));
- pFukuanmaBtn->SetTextColor(0xFF43A947);
- CButtonUI* pShoujihaoBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_shoujihao")));
- pShoujihaoBtn->SetTextColor(0xFF555555);
- CButtonUI* pShitikaBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_shitika")));
- pShitikaBtn->SetTextColor(0xFF555555);
- CControlUI* pFukuanmaLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_saomazhifu_line")));
- pFukuanmaLine->SetVisible(true);
- CControlUI* pShoujihaoLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_shoujihao_line")));
- pShoujihaoLine->SetVisible(false);
- CControlUI* pShitikaLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_shitika_line")));
- pShitikaLine->SetVisible(false);
- m_shoukuanModel = 1;
- }
- else if (msg.pSender->GetName() == L"shoukuan_btn_shoujihao")
- {
- CHorizontalLayoutUI* pFukuanmaLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_fukuanma_layout")));
- pFukuanmaLayout->SetVisible(false);
- CHorizontalLayoutUI* pShoujihaoLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_shoujihao_layout")));
- pShoujihaoLayout->SetVisible(true);
- CHorizontalLayoutUI* pShitikaLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_shitika_layout")));
- pShitikaLayout->SetVisible(false);
- CButtonUI* pFukuanmaBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_saomazhifu")));
- pFukuanmaBtn->SetTextColor(0xFF555555);
- CButtonUI* pShoujihaoBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_shoujihao")));
- pShoujihaoBtn->SetTextColor(0xFF43A947);
- CButtonUI* pShitikaBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_shitika")));
- pShitikaBtn->SetTextColor(0xFF555555);
- CControlUI* pFukuanmaLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_saomazhifu_line")));
- pFukuanmaLine->SetVisible(false);
- CControlUI* pShoujihaoLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_shoujihao_line")));
- pShoujihaoLine->SetVisible(true);
- CControlUI* pShitikaLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_shitika_line")));
- pShitikaLine->SetVisible(false);
- m_shoukuanModel = 2;
- m_pm.SetNextTabControl(false);
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- pShoujihao->SetFocus();
- }
- else if (msg.pSender->GetName() == L"shoukuan_btn_shitika")
- {
- CHorizontalLayoutUI* pFukuanmaLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_fukuanma_layout")));
- pFukuanmaLayout->SetVisible(false);
- CHorizontalLayoutUI* pShoujihaoLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_shoujihao_layout")));
- pShoujihaoLayout->SetVisible(false);
- CHorizontalLayoutUI* pShitikaLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("fukuan_input_shitika_layout")));
- pShitikaLayout->SetVisible(true);
- CButtonUI* pFukuanmaBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_saomazhifu")));
- pFukuanmaBtn->SetTextColor(0xFF555555);
- CButtonUI* pShoujihaoBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_shoujihao")));
- pShoujihaoBtn->SetTextColor(0xFF555555);
- CButtonUI* pShitikaBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("shoukuan_btn_shitika")));
- pShitikaBtn->SetTextColor(0xFF43A947);
- CControlUI* pFukuanmaLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_saomazhifu_line")));
- pFukuanmaLine->SetVisible(false);
- CControlUI* pShoujihaoLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_shoujihao_line")));
- pShoujihaoLine->SetVisible(false);
- CControlUI* pShitikaLine = static_cast<CControlUI*>(m_pm.FindControl(_T("shoukuan_btn_shitika_line")));
- pShitikaLine->SetVisible(true);
- m_shoukuanModel = 3;
- }
- else if (senderName == L"jianpan_1")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"1";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_2")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"2";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_3")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"3";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_4")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"4";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_5")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"5";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_6")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"6";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_7")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"7";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_8")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"8";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_9")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"9";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_0")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason += L"0";
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_x")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason = wsReason.substr(0, wsReason.length() - 1);
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- else if (senderName == L"jianpan_qingkong")
- {
- CEditUI* curEdit;
- CEditUI* pShoujihao = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (m_inputType == 1)
- {
- curEdit = pShoujihao;
- }
- else
- {
- curEdit = pPassword;
- }
- std::wstring wsReason = curEdit->GetText();
- wsReason.clear();
- curEdit->SetText(wsReason.c_str());
- curEdit->SetFocus();
- }
- }
- else if (msg.sType == _T("textchanged"))
- {
- if (senderName == L"shoujihao_edit")
- {
- //只能输入数字,其他的全部删除
- CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- if (!m_pEdit->GetText().IsEmpty())
- {
- std::wstring ws_Value = m_pEdit->GetText();
- std::string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
- for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
- {
- unsigned char tmp = strValue.at(nIndex);
- if (tmp > 57 || tmp < 48)
- {
- //ASCII码不是数字的都过滤掉
- strValue = strValue.substr(0, nIndex);
- m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
- m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
- break;
- }
- }
- }
- }
- if (senderName == L"password_edit")
- {
- //只能输入数字,其他的全部删除
- CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- if (!m_pEdit->GetText().IsEmpty())
- {
- std::wstring ws_Value = m_pEdit->GetText();
- std::string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
- for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
- {
- unsigned char tmp = strValue.at(nIndex);
- if (tmp > 57 || tmp < 48)
- {
- //ASCII码不是数字的都过滤掉
- strValue = strValue.substr(0, nIndex);
- m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
- m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
- break;
- }
- }
- }
- }
- }
- else if (msg.sType == _T("setfocus"))
- {
- if (senderName == L"shoujihao_edit")
- {
- m_inputType = 1;
- }
- else if (senderName == L"password_edit")
- {
- m_inputType = 2;
- }
- }
- }
- LRESULT CMemberLoginWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
- styleValue &= ~WS_CAPTION;
- ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
- // 把自己的窗口句柄与窗口绘制管理器挂接在一起
- m_pm.Init(m_hWnd);
- m_pm.AddPreMessageFilter(this);
- CDialogBuilder builder;
- CControlUI* pRoot = builder.Create(_T("member_login_dlg.xml"), (UINT)0, NULL, &m_pm);
- ASSERT(pRoot && "Failed to parse XML");
- // 把这些控件绘制到本窗口上
- m_pm.AttachDialog(pRoot);
- // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
- m_pm.AddNotifier(this);
- Init();
- return 0;
- }
- LRESULT CMemberLoginWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- //销毁定时器
- KillTimer(m_hWnd, WM_TIMER_WND_CLOSE);
- bHandled = FALSE;
- return 0;
- }
- /*
- *这个是窗口被销毁的时候调用的
- **/
- LRESULT CMemberLoginWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- bHandled = FALSE;
- return 0;
- }
- LRESULT CMemberLoginWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- if (::IsIconic(*this))
- {
- bHandled = FALSE;
- }
- return (wParam == 0) ? TRUE : FALSE;
- }
- LRESULT CMemberLoginWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- return 0;
- }
- LRESULT CMemberLoginWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- return 0;
- }
- LRESULT CMemberLoginWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- POINT pt;
- pt.x = GET_X_LPARAM(lParam);
- pt.y = GET_Y_LPARAM(lParam);
- ::ScreenToClient(*this, &pt);
- RECT rcClient;
- ::GetClientRect(*this, &rcClient);
- RECT rcCaption = m_pm.GetCaptionRect();
- if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
- && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
- {
- CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
- if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
- {
- return HTCAPTION;
- }
- }
- return HTCLIENT;
- }
- LRESULT CMemberLoginWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- SIZE szRoundCorner = m_pm.GetRoundCorner();
- if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
- {
- CDuiRect rcWnd;
- ::GetWindowRect(*this, &rcWnd);
- rcWnd.Offset(-rcWnd.left, -rcWnd.top);
- rcWnd.right++;
- rcWnd.bottom++;
- HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
- ::SetWindowRgn(*this, hRgn, TRUE);
- ::DeleteObject(hRgn);
- }
- bHandled = FALSE;
- return 0;
- }
- LRESULT CMemberLoginWnd::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- bHandled = TRUE;
- return 0;
- }
- LRESULT CMemberLoginWnd::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- if (wParam != WM_TIMER_WND_CLOSE)
- {
- bHandled = FALSE;
- return 0;
- }
- if (m_shoukuan_status == 0 || m_shoukuan_status == 1)
- {
- }
- else if (m_shoukuan_status == 2)
- {
- }
- else if (m_shoukuan_status == 3)
- {
- m_timer_now--;
- if (m_timer_now > 0)
- {
- CLabelUI* attention = static_cast<CLabelUI*>(m_pm.FindControl(_T("shouyin_pay_success_attention")));
- std::wstring ws_attention = L"按任意键关闭窗口," + std::to_wstring(m_timer_now) + L" 秒后自动关闭";
- attention->SetText(ws_attention.c_str());
- }
- else
- {
- Close(IDOK);
- }
- }
- else if (m_shoukuan_status == 4)
- {
- m_timer_now--;
- if (m_timer_now > 0)
- {
- CLabelUI* pFailMessage = static_cast<CLabelUI*>(m_pm.FindControl(_T("shouyin_pay_fail_attention")));
- std::wstring ws_fail_message = L"失败信息:" + m_fail_message + L",按任意键关闭窗口,";
- std::wstring ws_attention = ws_fail_message + std::to_wstring(m_timer_now) + L" 秒后自动关闭";
- pFailMessage->SetText(ws_attention.c_str());
- }
- else
- {
- Close(IDCANCEL);
- }
- }
- bHandled = TRUE;
- return 0;
- }
- LRESULT CMemberLoginWnd::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;
- 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;
- case WM_MOUSEHOVER:
- lRes = OnMouseMove(uMsg, wParam, lParam, bHandled);
- break;
- case WM_SHOUKUAN_STATUS_SUCCESS:
- lRes = OnLoginSuccess(uMsg, wParam, lParam, bHandled);
- break;
- case WM_SHOUKUAN_STATUS_FAIL:
- lRes = OnLoginFail(uMsg, wParam, lParam, bHandled);
- break;
- case WM_TIMER:
- lRes = OnTimer(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 CMemberLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
- {
- if (uMsg == WM_KEYDOWN)
- {
- if (wParam == VK_RETURN)
- {
- if (m_shoukuan_status == 0)
- {
- if (m_shoukuanModel == 2)
- {
- StartLogin();
- }
- }
- else if (m_shoukuan_status == 1 || m_shoukuan_status == 2 || m_shoukuan_status == 5)
- {
- //正在支付的过程中,这个时候按Enter键,不做任何处理
- }
- else if (m_shoukuan_status == 3)
- {
- Close(IDOK);
- }
- else if (m_shoukuan_status == 4)
- {
- //Close(IDCANCEL);
- if (m_shoukuanModel == 2)
- {
- StartLogin();
- }
- }
- return true;
- }
- else if (wParam == VK_ESCAPE)
- {
- StartClose();
- return true;
- }
- if (m_shoukuan_status == 3)
- {
- Close(IDOK);
- return true;
- }
- else if (m_shoukuan_status == 4)
- {
- //Close(IDCANCEL);
- return true;
- }
- }
- return false;
- }
- void CMemberLoginWnd::SetCommonParams(std::map<std::string, std::string> params)
- {
- m_commonParams = params;
- }
- LRESULT CMemberLoginWnd::OnLoginSuccess(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- Close(IDOK);
- bHandled = TRUE;
- return 0;
- }
- LRESULT CMemberLoginWnd::OnLoginFail(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
- {
- CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
- paying_layout->SetVisible(false);
- CVerticalLayoutUI* before_pay_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_before_pay_layout")));
- before_pay_layout->SetVisible(true);
- CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
- pLabel->SetText((L"登录失败:" + m_fail_message).c_str());
- pLabel->SetVisible(true);
- SetFocus(m_hWnd);
- bHandled = TRUE;
- return 0;
- }
- void CMemberLoginWnd::StartLogin()
- {
- CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
- //先判断登录码的格式是否正确
- CEditUI* pShoujihaoEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
- std::wstring ws_Shoujihao = pShoujihaoEdit->GetText();
- m_shoujihao = CLewaimaiString::UnicodeToUTF8(ws_Shoujihao);
- CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
- std::wstring ws_Password = pPasswordEdit->GetText();
- m_password = CLewaimaiString::UnicodeToUTF8(ws_Password);
- if (m_shoukuanModel == 2)
- {
- if (ws_Shoujihao.length() == 0)
- {
- pLabel->SetText(L"手机号不能为空");
- pLabel->SetVisible(true);
- return;
- }
- /*
- if (ws_Password.length() == 0)
- {
- pLabel->SetText(L"密码不能为空");
- pLabel->SetVisible(true);
- return;
- }
- }*/
- }
- //全部验证通过,就可以开始修改状态了
- m_shoukuan_status = 1;
- //不加这个的话,edit按回车之后样式有问题
- SetFocus(m_hWnd);
- CVerticalLayoutUI* before_pay_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_before_pay_layout")));
- before_pay_layout->SetVisible(false);
- CVerticalLayoutUI* paying_layout = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("shoukuan_paying_layout")));
- paying_layout->SetVisible(true);
- //开启一个线程,开始处理登录
- std::thread(&CMemberLoginWnd::HandleLogin, this).detach();
- }
- void CMemberLoginWnd::StartClose()
- {
- if (m_shoukuan_status == 0)
- {
- //还没开始支付,直接退出
- Close(IDCANCEL);
- }
- else if (m_shoukuan_status == 1 || m_shoukuan_status == 5)
- {
- //不能做任何处理
- }
- else if (m_shoukuan_status == 2)
- {
- }
- else if (m_shoukuan_status == 3)
- {
- Sleep(100);
- Close(IDOK);
- }
- else if (m_shoukuan_status == 4)
- {
- Sleep(100);
- Close(IDCANCEL);
- }
- }
- void CMemberLoginWnd::HandleLogin()
- {
- std::string url;
- if (m_shoukuanModel == 1)
- {
- url = "/member/membercheckbyqrcode";
- m_commonParams["weixin_password"] = m_fukuanma;
- }
- else if (m_shoukuanModel == 2)
- {
- url = "/member/membercheckbyphone";
- m_commonParams["phone"] = m_shoujihao;
- }
- else if (m_shoukuanModel == 3)
- {
- url = "/member/membercheck";
- m_commonParams["card_identify"] = m_card_identify;
- }
- std::string response;
- bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), m_commonParams, response);
- if (ret == false)
- {
- m_shoukuan_status = 4;
- m_fail_message = L"请求服务器失败,请检查网络设置!";
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- rapidjson::Document document;
- document.Parse(response.c_str());
- if (document.HasParseError())
- {
- LOG_INFO("parse response error!");
- m_shoukuan_status = 4;
- m_fail_message = L"服务器错误";
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
- {
- LOG_INFO("json error!");
- m_shoukuan_status = 4;
- m_fail_message = L"服务器错误";
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- rapidjson::Value& v_errcode = document["errcode"];
- int errcode = v_errcode.GetInt();
- if (errcode != 0)
- {
- LOG_INFO("response failed! message:" << document["errmsg"].GetString());
- m_shoukuan_status = 4;
- std::string errmsg = document["errmsg"].GetString();
- m_fail_message = CLewaimaiString::UTF8ToUnicode(errmsg);
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- if (!document.HasMember("data"))
- {
- LOG_INFO("json error!");
- m_shoukuan_status = 4;
- m_fail_message = L"服务器错误";
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- rapidjson::Value& data = document["data"];
- rapidjson::Value& info = data["rows"][0];
- //支付成功
- m_shoukuan_status = 3;
- m_card_no = info["card_no"].GetString();
- m_card_identify = info["card_identify"].GetString();
- m_balance = info["balance"].GetString();
- m_name = info["name"].GetString();
- m_sex = info["sex"].GetString();
- m_birthday = info["birthday"].GetString();
- m_phone = info["phone"].GetString();
- m_address = info["address"].GetString();
- m_is_card = info["is_card"].GetString();
- m_member_id = info["id"].GetString();
- m_point = info["point"].GetString();
- m_open_no_card_payment = info["open_no_card_payment"].GetString();
- m_pay_password = info["pay_password"].GetString();
- m_freeze = info["freeze"].GetString();
- m_member_level = info["member_level"].GetString();
- m_member_level_name = info["member_level_name"].GetString();
- if (m_shoukuanModel == 2)
- {
- if (m_open_no_card_payment == "0")
- {
- m_shoukuan_status = 4;
- m_fail_message = L"该会员未开启手机号密码登录";
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- //进行支付密码比对
- if (m_pay_password != md5(m_password))
- {
- m_shoukuan_status = 4;
- m_fail_message = L"登录密码错误";
- PostMessage(WM_SHOUKUAN_STATUS_FAIL, 0, 0);
- return;
- }
- }
- PostMessage(WM_SHOUKUAN_STATUS_SUCCESS, 0, 0);
- }
- //处理键盘捕捉结果
- void CMemberLoginWnd::HandleTextCapture(std::string content)
- {
- if (m_shoukuanModel == 1)
- {
- m_fukuanma = content;
- StartLogin();
- }
- else if (m_shoukuanModel == 3)
- {
- m_card_identify = content;
- StartLogin();
- }
- }
|