|
|
@@ -0,0 +1,713 @@
|
|
|
+#include "../pch/pch.h"
|
|
|
+#include "CHuiyuanAddWnd.h"
|
|
|
+
|
|
|
+#include "../helper/MD5.h"
|
|
|
+
|
|
|
+LRESULT CHuiyuanAddWnd::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 CHuiyuanAddWnd::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 CHuiyuanAddWnd::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_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 CHuiyuanAddWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
+{
|
|
|
+ if (uMsg == WM_KEYDOWN)
|
|
|
+ {
|
|
|
+ if (wParam == VK_RETURN)
|
|
|
+ {
|
|
|
+ StartYanzheng();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (wParam == VK_ESCAPE)
|
|
|
+ {
|
|
|
+ if (m_is_qingqiu == false)
|
|
|
+ {
|
|
|
+ Close(IDCANCEL);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (uMsg == WM_MEMBER_CHECK_SUCCESS)
|
|
|
+ {
|
|
|
+ m_qingqiu_mutex.lock();
|
|
|
+
|
|
|
+ m_is_qingqiu = false;
|
|
|
+
|
|
|
+ m_qingqiu_mutex.unlock();
|
|
|
+
|
|
|
+ //验证成功了
|
|
|
+ Close(IDOK);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (uMsg == WM_MEMBER_CHECK_FAIL)
|
|
|
+ {
|
|
|
+ //验证失败了
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ pPhone->SetEnabled(true);
|
|
|
+
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ pPassword->SetEnabled(true);
|
|
|
+
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ pName->SetEnabled(true);
|
|
|
+
|
|
|
+ CButtonUI* pSave = static_cast<CButtonUI*>(m_pm.FindControl(_T("save")));
|
|
|
+ pSave->SetEnabled(true);
|
|
|
+
|
|
|
+ //失败原因
|
|
|
+ CLabelUI* pErrorInfo = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
|
|
|
+ pErrorInfo->SetText(m_errorInfo.c_str());
|
|
|
+ pErrorInfo->SetVisible(true);
|
|
|
+
|
|
|
+ m_qingqiu_mutex.lock();
|
|
|
+
|
|
|
+ m_is_qingqiu = false;
|
|
|
+
|
|
|
+ m_qingqiu_mutex.unlock();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+LRESULT CHuiyuanAddWnd::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("huiyuan_add_wnd.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;
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanAddWnd::Notify(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ DuiLib::CDuiString senderName = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (msg.sType == _T("click"))
|
|
|
+ {
|
|
|
+ DuiLib::CDuiString senderName = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (senderName == _T("closebtn"))
|
|
|
+ {
|
|
|
+ if (m_is_qingqiu == false)
|
|
|
+ {
|
|
|
+ Close(IDCANCEL);
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (senderName == _T("save"))
|
|
|
+ {
|
|
|
+ StartYanzheng();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_1")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"1";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_2")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"2";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_3")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"3";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_4")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"4";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_5")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"5";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_6")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"6";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_7")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"7";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_8")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"8";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_9")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"9";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_0")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason += L"0";
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (senderName == L"jianpan_x")
|
|
|
+ {
|
|
|
+ CEditUI* curEdit;
|
|
|
+
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ 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* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ if (m_inputType == 1)
|
|
|
+ {
|
|
|
+ curEdit = pPhone;
|
|
|
+ }
|
|
|
+ else if (m_inputType == 2)
|
|
|
+ {
|
|
|
+ curEdit = pPassword;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ curEdit = pName;
|
|
|
+ }
|
|
|
+ wstring wsReason = curEdit->GetText();
|
|
|
+
|
|
|
+ wsReason.clear();
|
|
|
+
|
|
|
+ curEdit->SetText(wsReason.c_str());
|
|
|
+ curEdit->SetFocus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (msg.sType == _T("textchanged"))
|
|
|
+ {
|
|
|
+ if (senderName == L"phone_edit")
|
|
|
+ {
|
|
|
+
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ 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())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ 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 == L"windowinit")
|
|
|
+ {
|
|
|
+ m_pm.SetNextTabControl(false);
|
|
|
+
|
|
|
+ CEditUI* pFukuanEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ pFukuanEdit->SetFocus();
|
|
|
+ }
|
|
|
+ else if (msg.sType == _T("setfocus"))
|
|
|
+ {
|
|
|
+ if (senderName == L"phone_edit")
|
|
|
+ {
|
|
|
+ m_inputType = 1;
|
|
|
+ }
|
|
|
+ else if (senderName == L"password_edit")
|
|
|
+ {
|
|
|
+ m_inputType = 2;
|
|
|
+ }
|
|
|
+ else if (senderName == L"name_edit")
|
|
|
+ {
|
|
|
+ m_inputType = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanAddWnd::Init()
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+void CHuiyuanAddWnd::StartYanzheng()
|
|
|
+{
|
|
|
+ CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
|
|
|
+ wstring wsPhone = pPhone->GetText();
|
|
|
+ m_phone = CLewaimaiString::UnicodeToUTF8(wsPhone);
|
|
|
+
|
|
|
+ if (wsPhone.length() == 0)
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("手机号不能为空");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wsPhone.length() != 11)
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("手机号格式不对");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ pPhone->SetEnabled(false);
|
|
|
+
|
|
|
+ CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
|
|
|
+ wstring wsPassword = pPassword->GetText();
|
|
|
+ m_password = CLewaimaiString::UnicodeToUTF8(wsPassword);
|
|
|
+
|
|
|
+ if (wsPassword.length() == 0)
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("支付密码不能为空");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wsPassword.length() != 6)
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("支付密码只能为6位数字");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ pPassword->SetEnabled(false);
|
|
|
+
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
|
|
|
+ wstring wsName = pName->GetText();
|
|
|
+ m_name = CLewaimaiString::UnicodeToUTF8(wsName);
|
|
|
+ pName->SetEnabled(false);
|
|
|
+
|
|
|
+ CButtonUI* pSave = static_cast<CButtonUI*>(m_pm.FindControl(_T("save")));
|
|
|
+ pSave->SetEnabled(false);
|
|
|
+
|
|
|
+ m_qingqiu_mutex.lock();
|
|
|
+
|
|
|
+ m_is_qingqiu = true;
|
|
|
+
|
|
|
+ m_qingqiu_mutex.unlock();
|
|
|
+
|
|
|
+ //开始处理
|
|
|
+ std::thread(&CHuiyuanAddWnd::ConfirmMember, this).detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CHuiyuanAddWnd::ConfirmMember()
|
|
|
+{
|
|
|
+ std::map<string, string> params;
|
|
|
+ params["phone"] = m_phone;
|
|
|
+ params["name"] = m_name;
|
|
|
+ params["pay_password"] = md5(m_password);
|
|
|
+ params["open_no_card_payment"] = "1";
|
|
|
+ params["is_no_card"] = "1";
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+ bool ret = CZhipuziHttpClient::Request("/member/add", params, response);
|
|
|
+ if (!ret)
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("网络请求出错");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("服务器返回数据格式错误");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
|
|
|
+ {
|
|
|
+ m_errorInfo = _T("服务器返回数据格式错误");
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ std::string errmsg = CLewaimaiString::UnicodeToUTF8(L"添加会员失败:") + string(document["errmsg"].GetString());
|
|
|
+ m_errorInfo = CLewaimaiString::UTF8ToUnicode(errmsg);
|
|
|
+ PostMessage(WM_MEMBER_CHECK_FAIL);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PostMessage(WM_MEMBER_CHECK_SUCCESS);
|
|
|
+ }
|
|
|
+}
|