CHuiyuanAddWnd.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. #include "../pch/pch.h"
  2. #include "CHuiyuanAddWnd.h"
  3. #include "../helper/MD5.h"
  4. LRESULT CHuiyuanAddWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  5. {
  6. POINT pt;
  7. pt.x = GET_X_LPARAM(lParam);
  8. pt.y = GET_Y_LPARAM(lParam);
  9. ::ScreenToClient(*this, &pt);
  10. RECT rcClient;
  11. ::GetClientRect(*this, &rcClient);
  12. RECT rcCaption = m_pm.GetCaptionRect();
  13. if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
  14. && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
  15. {
  16. CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
  17. if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
  18. {
  19. return HTCAPTION;
  20. }
  21. }
  22. return HTCLIENT;
  23. }
  24. LRESULT CHuiyuanAddWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  25. {
  26. SIZE szRoundCorner = m_pm.GetRoundCorner();
  27. if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
  28. {
  29. CDuiRect rcWnd;
  30. ::GetWindowRect(*this, &rcWnd);
  31. rcWnd.Offset(-rcWnd.left, -rcWnd.top);
  32. rcWnd.right++;
  33. rcWnd.bottom++;
  34. HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
  35. ::SetWindowRgn(*this, hRgn, TRUE);
  36. ::DeleteObject(hRgn);
  37. }
  38. bHandled = FALSE;
  39. return 0;
  40. }
  41. LRESULT CHuiyuanAddWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  42. {
  43. LRESULT lRes = 0;
  44. BOOL bHandled = TRUE;
  45. switch (uMsg)
  46. {
  47. case WM_CREATE:
  48. lRes = OnCreate(uMsg, wParam, lParam, bHandled);
  49. break;
  50. case WM_NCACTIVATE:
  51. lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
  52. break;
  53. case WM_NCCALCSIZE:
  54. lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
  55. break;
  56. case WM_NCPAINT:
  57. lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
  58. break;
  59. case WM_NCHITTEST:
  60. lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
  61. break;
  62. case WM_SIZE:
  63. lRes = OnSize(uMsg, wParam, lParam, bHandled);
  64. break;
  65. default:
  66. bHandled = FALSE;
  67. }
  68. if (bHandled)
  69. {
  70. return lRes;
  71. }
  72. if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
  73. {
  74. return lRes;
  75. }
  76. return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
  77. }
  78. LRESULT CHuiyuanAddWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
  79. {
  80. if (uMsg == WM_KEYDOWN)
  81. {
  82. if (wParam == VK_RETURN)
  83. {
  84. StartYanzheng();
  85. return true;
  86. }
  87. else if (wParam == VK_ESCAPE)
  88. {
  89. if (m_is_qingqiu == false)
  90. {
  91. Close(IDCANCEL);
  92. }
  93. return true;
  94. }
  95. }
  96. else if (uMsg == WM_MEMBER_CHECK_SUCCESS)
  97. {
  98. m_qingqiu_mutex.lock();
  99. m_is_qingqiu = false;
  100. m_qingqiu_mutex.unlock();
  101. //验证成功了
  102. Close(IDOK);
  103. return true;
  104. }
  105. else if (uMsg == WM_MEMBER_CHECK_FAIL)
  106. {
  107. //验证失败了
  108. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  109. pPhone->SetEnabled(true);
  110. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  111. pPassword->SetEnabled(true);
  112. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  113. pName->SetEnabled(true);
  114. CButtonUI* pSave = static_cast<CButtonUI*>(m_pm.FindControl(_T("save")));
  115. pSave->SetEnabled(true);
  116. //失败原因
  117. CLabelUI* pErrorInfo = static_cast<CLabelUI*>(m_pm.FindControl(_T("shoukuanresult")));
  118. pErrorInfo->SetText(m_errorInfo.c_str());
  119. pErrorInfo->SetVisible(true);
  120. m_qingqiu_mutex.lock();
  121. m_is_qingqiu = false;
  122. m_qingqiu_mutex.unlock();
  123. return true;
  124. }
  125. return false;
  126. }
  127. LRESULT CHuiyuanAddWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  128. {
  129. LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
  130. styleValue &= ~WS_CAPTION;
  131. ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  132. // 把自己的窗口句柄与窗口绘制管理器挂接在一起
  133. m_pm.Init(m_hWnd);
  134. m_pm.AddPreMessageFilter(this);
  135. CDialogBuilder builder;
  136. CControlUI* pRoot = builder.Create(_T("huiyuan_add_wnd.xml"), (UINT)0, NULL, &m_pm);
  137. ASSERT(pRoot && "Failed to parse XML");
  138. // 把这些控件绘制到本窗口上
  139. m_pm.AttachDialog(pRoot);
  140. // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
  141. m_pm.AddNotifier(this);
  142. Init();
  143. return 0;
  144. }
  145. void CHuiyuanAddWnd::Notify(TNotifyUI& msg)
  146. {
  147. DuiLib::CDuiString senderName = msg.pSender->GetName();
  148. if (msg.sType == _T("click"))
  149. {
  150. DuiLib::CDuiString senderName = msg.pSender->GetName();
  151. if (senderName == _T("closebtn"))
  152. {
  153. if (m_is_qingqiu == false)
  154. {
  155. Close(IDCANCEL);
  156. }
  157. return;
  158. }
  159. else if (senderName == _T("save"))
  160. {
  161. StartYanzheng();
  162. }
  163. else if (senderName == L"jianpan_1")
  164. {
  165. CEditUI* curEdit;
  166. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  167. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  168. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  169. if (m_inputType == 1)
  170. {
  171. curEdit = pPhone;
  172. }
  173. else if (m_inputType == 2)
  174. {
  175. curEdit = pPassword;
  176. }
  177. else
  178. {
  179. curEdit = pName;
  180. }
  181. wstring wsReason = curEdit->GetText();
  182. wsReason += L"1";
  183. curEdit->SetText(wsReason.c_str());
  184. curEdit->SetFocus();
  185. }
  186. else if (senderName == L"jianpan_2")
  187. {
  188. CEditUI* curEdit;
  189. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  190. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  191. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  192. if (m_inputType == 1)
  193. {
  194. curEdit = pPhone;
  195. }
  196. else if (m_inputType == 2)
  197. {
  198. curEdit = pPassword;
  199. }
  200. else
  201. {
  202. curEdit = pName;
  203. }
  204. wstring wsReason = curEdit->GetText();
  205. wsReason += L"2";
  206. curEdit->SetText(wsReason.c_str());
  207. curEdit->SetFocus();
  208. }
  209. else if (senderName == L"jianpan_3")
  210. {
  211. CEditUI* curEdit;
  212. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  213. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  214. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  215. if (m_inputType == 1)
  216. {
  217. curEdit = pPhone;
  218. }
  219. else if (m_inputType == 2)
  220. {
  221. curEdit = pPassword;
  222. }
  223. else
  224. {
  225. curEdit = pName;
  226. }
  227. wstring wsReason = curEdit->GetText();
  228. wsReason += L"3";
  229. curEdit->SetText(wsReason.c_str());
  230. curEdit->SetFocus();
  231. }
  232. else if (senderName == L"jianpan_4")
  233. {
  234. CEditUI* curEdit;
  235. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  236. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  237. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  238. if (m_inputType == 1)
  239. {
  240. curEdit = pPhone;
  241. }
  242. else if (m_inputType == 2)
  243. {
  244. curEdit = pPassword;
  245. }
  246. else
  247. {
  248. curEdit = pName;
  249. }
  250. wstring wsReason = curEdit->GetText();
  251. wsReason += L"4";
  252. curEdit->SetText(wsReason.c_str());
  253. curEdit->SetFocus();
  254. }
  255. else if (senderName == L"jianpan_5")
  256. {
  257. CEditUI* curEdit;
  258. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  259. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  260. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  261. if (m_inputType == 1)
  262. {
  263. curEdit = pPhone;
  264. }
  265. else if (m_inputType == 2)
  266. {
  267. curEdit = pPassword;
  268. }
  269. else
  270. {
  271. curEdit = pName;
  272. }
  273. wstring wsReason = curEdit->GetText();
  274. wsReason += L"5";
  275. curEdit->SetText(wsReason.c_str());
  276. curEdit->SetFocus();
  277. }
  278. else if (senderName == L"jianpan_6")
  279. {
  280. CEditUI* curEdit;
  281. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  282. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  283. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  284. if (m_inputType == 1)
  285. {
  286. curEdit = pPhone;
  287. }
  288. else if (m_inputType == 2)
  289. {
  290. curEdit = pPassword;
  291. }
  292. else
  293. {
  294. curEdit = pName;
  295. }
  296. wstring wsReason = curEdit->GetText();
  297. wsReason += L"6";
  298. curEdit->SetText(wsReason.c_str());
  299. curEdit->SetFocus();
  300. }
  301. else if (senderName == L"jianpan_7")
  302. {
  303. CEditUI* curEdit;
  304. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  305. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  306. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  307. if (m_inputType == 1)
  308. {
  309. curEdit = pPhone;
  310. }
  311. else if (m_inputType == 2)
  312. {
  313. curEdit = pPassword;
  314. }
  315. else
  316. {
  317. curEdit = pName;
  318. }
  319. wstring wsReason = curEdit->GetText();
  320. wsReason += L"7";
  321. curEdit->SetText(wsReason.c_str());
  322. curEdit->SetFocus();
  323. }
  324. else if (senderName == L"jianpan_8")
  325. {
  326. CEditUI* curEdit;
  327. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  328. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  329. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  330. if (m_inputType == 1)
  331. {
  332. curEdit = pPhone;
  333. }
  334. else if (m_inputType == 2)
  335. {
  336. curEdit = pPassword;
  337. }
  338. else
  339. {
  340. curEdit = pName;
  341. }
  342. wstring wsReason = curEdit->GetText();
  343. wsReason += L"8";
  344. curEdit->SetText(wsReason.c_str());
  345. curEdit->SetFocus();
  346. }
  347. else if (senderName == L"jianpan_9")
  348. {
  349. CEditUI* curEdit;
  350. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  351. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  352. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  353. if (m_inputType == 1)
  354. {
  355. curEdit = pPhone;
  356. }
  357. else if (m_inputType == 2)
  358. {
  359. curEdit = pPassword;
  360. }
  361. else
  362. {
  363. curEdit = pName;
  364. }
  365. wstring wsReason = curEdit->GetText();
  366. wsReason += L"9";
  367. curEdit->SetText(wsReason.c_str());
  368. curEdit->SetFocus();
  369. }
  370. else if (senderName == L"jianpan_0")
  371. {
  372. CEditUI* curEdit;
  373. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  374. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  375. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  376. if (m_inputType == 1)
  377. {
  378. curEdit = pPhone;
  379. }
  380. else if (m_inputType == 2)
  381. {
  382. curEdit = pPassword;
  383. }
  384. else
  385. {
  386. curEdit = pName;
  387. }
  388. wstring wsReason = curEdit->GetText();
  389. wsReason += L"0";
  390. curEdit->SetText(wsReason.c_str());
  391. curEdit->SetFocus();
  392. }
  393. else if (senderName == L"jianpan_x")
  394. {
  395. CEditUI* curEdit;
  396. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  397. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  398. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  399. if (m_inputType == 1)
  400. {
  401. curEdit = pPhone;
  402. }
  403. else if (m_inputType == 2)
  404. {
  405. curEdit = pPassword;
  406. }
  407. else
  408. {
  409. curEdit = pName;
  410. }
  411. wstring wsReason = curEdit->GetText();
  412. wsReason = wsReason.substr(0, wsReason.length() - 1);
  413. curEdit->SetText(wsReason.c_str());
  414. curEdit->SetFocus();
  415. }
  416. else if (senderName == L"jianpan_qingkong")
  417. {
  418. CEditUI* curEdit;
  419. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  420. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  421. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  422. if (m_inputType == 1)
  423. {
  424. curEdit = pPhone;
  425. }
  426. else if (m_inputType == 2)
  427. {
  428. curEdit = pPassword;
  429. }
  430. else
  431. {
  432. curEdit = pName;
  433. }
  434. wstring wsReason = curEdit->GetText();
  435. wsReason.clear();
  436. curEdit->SetText(wsReason.c_str());
  437. curEdit->SetFocus();
  438. }
  439. }
  440. else if (msg.sType == _T("textchanged"))
  441. {
  442. if (senderName == L"phone_edit")
  443. {
  444. //只能输入数字,其他的全部删除
  445. CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  446. if (!m_pEdit->GetText().IsEmpty())
  447. {
  448. wstring ws_Value = m_pEdit->GetText();
  449. string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
  450. for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
  451. {
  452. unsigned char tmp = strValue.at(nIndex);
  453. if (tmp > 57 || tmp < 48)
  454. {
  455. //ASCII码不是数字的都过滤掉
  456. strValue = strValue.substr(0, nIndex);
  457. m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
  458. m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
  459. break;
  460. }
  461. }
  462. }
  463. }
  464. if (senderName == L"password_edit")
  465. {
  466. //只能输入数字,其他的全部删除
  467. CEditUI* m_pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  468. if (!m_pEdit->GetText().IsEmpty())
  469. {
  470. wstring ws_Value = m_pEdit->GetText();
  471. string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
  472. for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
  473. {
  474. unsigned char tmp = strValue.at(nIndex);
  475. if (tmp > 57 || tmp < 48)
  476. {
  477. //ASCII码不是数字的都过滤掉
  478. strValue = strValue.substr(0, nIndex);
  479. m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
  480. m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
  481. break;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. else if (msg.sType == L"windowinit")
  488. {
  489. m_pm.SetNextTabControl(false);
  490. CEditUI* pFukuanEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  491. pFukuanEdit->SetFocus();
  492. }
  493. else if (msg.sType == _T("setfocus"))
  494. {
  495. if (senderName == L"phone_edit")
  496. {
  497. m_inputType = 1;
  498. }
  499. else if (senderName == L"password_edit")
  500. {
  501. m_inputType = 2;
  502. }
  503. else if (senderName == L"name_edit")
  504. {
  505. m_inputType = 3;
  506. }
  507. }
  508. }
  509. void CHuiyuanAddWnd::Init()
  510. {
  511. }
  512. void CHuiyuanAddWnd::StartYanzheng()
  513. {
  514. CEditUI* pPhone = static_cast<CEditUI*>(m_pm.FindControl(_T("phone_edit")));
  515. wstring wsPhone = pPhone->GetText();
  516. m_phone = CLewaimaiString::UnicodeToUTF8(wsPhone);
  517. if (wsPhone.length() == 0)
  518. {
  519. m_errorInfo = _T("手机号不能为空");
  520. PostMessage(WM_MEMBER_CHECK_FAIL);
  521. return;
  522. }
  523. if (wsPhone.length() != 11)
  524. {
  525. m_errorInfo = _T("手机号格式不对");
  526. PostMessage(WM_MEMBER_CHECK_FAIL);
  527. return;
  528. }
  529. pPhone->SetEnabled(false);
  530. CEditUI* pPassword = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
  531. wstring wsPassword = pPassword->GetText();
  532. m_password = CLewaimaiString::UnicodeToUTF8(wsPassword);
  533. if (wsPassword.length() == 0)
  534. {
  535. m_errorInfo = _T("支付密码不能为空");
  536. PostMessage(WM_MEMBER_CHECK_FAIL);
  537. return;
  538. }
  539. if (wsPassword.length() != 6)
  540. {
  541. m_errorInfo = _T("支付密码只能为6位数字");
  542. PostMessage(WM_MEMBER_CHECK_FAIL);
  543. return;
  544. }
  545. pPassword->SetEnabled(false);
  546. CEditUI* pName = static_cast<CEditUI*>(m_pm.FindControl(_T("name_edit")));
  547. wstring wsName = pName->GetText();
  548. m_name = CLewaimaiString::UnicodeToUTF8(wsName);
  549. pName->SetEnabled(false);
  550. CButtonUI* pSave = static_cast<CButtonUI*>(m_pm.FindControl(_T("save")));
  551. pSave->SetEnabled(false);
  552. m_qingqiu_mutex.lock();
  553. m_is_qingqiu = true;
  554. m_qingqiu_mutex.unlock();
  555. //开始处理
  556. std::thread(&CHuiyuanAddWnd::ConfirmMember, this).detach();
  557. }
  558. void CHuiyuanAddWnd::ConfirmMember()
  559. {
  560. std::map<string, string> params;
  561. params["phone"] = m_phone;
  562. params["name"] = m_name;
  563. params["pay_password"] = md5(m_password);
  564. params["open_no_card_payment"] = "1";
  565. params["is_no_card"] = "1";
  566. std::string response;
  567. bool ret = CZhipuziHttpClient::GetInstance()->Request("/member/add", params, response);
  568. if (!ret)
  569. {
  570. m_errorInfo = _T("网络请求出错");
  571. PostMessage(WM_MEMBER_CHECK_FAIL);
  572. return;
  573. }
  574. rapidjson::Document document;
  575. document.Parse(response.c_str());
  576. if (document.HasParseError())
  577. {
  578. m_errorInfo = _T("服务器返回数据格式错误");
  579. PostMessage(WM_MEMBER_CHECK_FAIL);
  580. return;
  581. }
  582. else
  583. {
  584. if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
  585. {
  586. m_errorInfo = _T("服务器返回数据格式错误");
  587. PostMessage(WM_MEMBER_CHECK_FAIL);
  588. return;
  589. }
  590. rapidjson::Value& v_errcode = document["errcode"];
  591. int errcode = v_errcode.GetInt();
  592. if (errcode != 0)
  593. {
  594. std::string errmsg = CLewaimaiString::UnicodeToUTF8(L"添加会员失败:") + string(document["errmsg"].GetString());
  595. m_errorInfo = CLewaimaiString::UTF8ToUnicode(errmsg);
  596. PostMessage(WM_MEMBER_CHECK_FAIL);
  597. return;
  598. }
  599. PostMessage(WM_MEMBER_CHECK_SUCCESS);
  600. }
  601. }