CHuiyuanPageUI.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. #include "../pch/pch.h"
  2. #include "CHuiyuanPageUI.h"
  3. #include "../wnd/CHuiyuanChongzhiWnd.h"
  4. #include "../wnd/CHuiyuanAddWnd.h"
  5. #include "../wnd/CHuiyuanXiugaiziliaoWnd.h"
  6. #include "../wnd/CHuiyuanXiugaimimaWnd.h"
  7. #include "../wnd/CHuiyuanBangkaWnd.h"
  8. #include "../wnd/CAttentionWnd.h"
  9. #include "../zhipuzi/CHuiyuanchognzhiOrder.h"
  10. #include "../print/CPosPrinter.h"
  11. CHuiyuanPageUI::CHuiyuanPageUI()
  12. {
  13. }
  14. CHuiyuanPageUI::~CHuiyuanPageUI()
  15. {
  16. }
  17. //初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
  18. void CHuiyuanPageUI::InitShow()
  19. {
  20. CEditUI* pFukuanEdit = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  21. pFukuanEdit->SetFocus();
  22. }
  23. //处理按钮点击类事件
  24. void CHuiyuanPageUI::HandleClickMsg(TNotifyUI& msg)
  25. {
  26. CDuiString senderName = msg.pSender->GetName();
  27. if (senderName == L"jianpan_1")
  28. {
  29. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  30. wstring wsReason = pContent->GetText();
  31. wsReason += L"1";
  32. pContent->SetText(wsReason.c_str());
  33. pContent->SetFocus();
  34. }
  35. else if (senderName == L"jianpan_2")
  36. {
  37. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  38. wstring wsReason = pContent->GetText();
  39. wsReason += L"2";
  40. pContent->SetText(wsReason.c_str());
  41. pContent->SetFocus();
  42. }
  43. else if (senderName == L"jianpan_3")
  44. {
  45. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  46. wstring wsReason = pContent->GetText();
  47. wsReason += L"3";
  48. pContent->SetText(wsReason.c_str());
  49. pContent->SetFocus();
  50. }
  51. else if (senderName == L"jianpan_4")
  52. {
  53. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  54. wstring wsReason = pContent->GetText();
  55. wsReason += L"4";
  56. pContent->SetText(wsReason.c_str());
  57. pContent->SetFocus();
  58. }
  59. else if (senderName == L"jianpan_5")
  60. {
  61. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  62. wstring wsReason = pContent->GetText();
  63. wsReason += L"5";
  64. pContent->SetText(wsReason.c_str());
  65. pContent->SetFocus();
  66. }
  67. else if (senderName == L"jianpan_6")
  68. {
  69. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  70. wstring wsReason = pContent->GetText();
  71. wsReason += L"6";
  72. pContent->SetText(wsReason.c_str());
  73. pContent->SetFocus();
  74. }
  75. else if (senderName == L"jianpan_7")
  76. {
  77. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  78. wstring wsReason = pContent->GetText();
  79. wsReason += L"7";
  80. pContent->SetText(wsReason.c_str());
  81. pContent->SetFocus();
  82. }
  83. else if (senderName == L"jianpan_8")
  84. {
  85. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  86. wstring wsReason = pContent->GetText();
  87. wsReason += L"8";
  88. pContent->SetText(wsReason.c_str());
  89. pContent->SetFocus();
  90. }
  91. else if (senderName == L"jianpan_9")
  92. {
  93. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  94. wstring wsReason = pContent->GetText();
  95. wsReason += L"9";
  96. pContent->SetText(wsReason.c_str());
  97. pContent->SetFocus();
  98. }
  99. else if (senderName == L"jianpan_0")
  100. {
  101. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  102. wstring wsReason = pContent->GetText();
  103. wsReason += L"0";
  104. pContent->SetText(wsReason.c_str());
  105. pContent->SetFocus();
  106. }
  107. else if (senderName == L"jianpan_x")
  108. {
  109. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  110. wstring wsReason = pContent->GetText();
  111. wsReason = wsReason.substr(0, wsReason.length() - 1);
  112. pContent->SetText(wsReason.c_str());
  113. pContent->SetFocus();
  114. }
  115. else if (senderName == L"jianpan_qingkong")
  116. {
  117. CEditUI* pContent = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  118. wstring wsReason = pContent->GetText();
  119. wsReason.clear();
  120. pContent->SetText(wsReason.c_str());
  121. pContent->SetFocus();
  122. }
  123. else if (senderName == _T("huiiyuan_page_sousuo_btn"))
  124. {
  125. //如果是手动点击了,就重置这个搜索手机号
  126. CEditUI* m_pEdit = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  127. wstring ws_Value = m_pEdit->GetText();
  128. m_sousuo_phone = CLewaimaiString::UnicodeToUTF8(ws_Value);
  129. StartHuiyuanSousuo();
  130. }
  131. else if (senderName == L"huiiyuan_page_chongzhi_btn")
  132. {
  133. StartHuiyuanChongzhi();
  134. }
  135. else if (senderName == L"huiyuan_page_add_btn")
  136. {
  137. StartAddHuiyuan();
  138. }
  139. else if (senderName == L"huiiyuan_page_xiugaiziliao_btn")
  140. {
  141. StartXiugaiziliao();
  142. }
  143. else if (senderName == L"huiiyuan_page_xiugaipassword_btn")
  144. {
  145. StartXiugaimima();
  146. }
  147. else if (senderName == L"huiiyuan_page_bangka_btn")
  148. {
  149. StartBangka();
  150. }
  151. else if (senderName == L"huiiyuan_page_guashi_btn")
  152. {
  153. StartGuashi();
  154. }
  155. else if (senderName == L"huiiyuan_page_dongjie_btn")
  156. {
  157. StartDongjie();
  158. }
  159. else if (senderName == L"huiiyuan_page_jiedong_btn")
  160. {
  161. StartJiedong();
  162. }
  163. }
  164. //处理option切换事件
  165. void CHuiyuanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
  166. {
  167. }
  168. //处理下拉框、radio的切换事件
  169. void CHuiyuanPageUI::HandleItemSelectMsg(TNotifyUI& msg)
  170. {
  171. }
  172. //处理编辑框输入内容改变事件
  173. void CHuiyuanPageUI::HandleTextChangedMsg(TNotifyUI& msg)
  174. {
  175. DuiLib::CDuiString senderName = msg.pSender->GetName();
  176. if (senderName == L"huiyuan_page_shoujihao_edit")
  177. {
  178. //只能输入数字,其他的全部删除
  179. CEditUI* m_pEdit = static_cast<CEditUI*>(this->FindSubControl(_T("huiyuan_page_shoujihao_edit")));
  180. if (!m_pEdit->GetText().IsEmpty())
  181. {
  182. wstring ws_Value = m_pEdit->GetText();
  183. string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
  184. m_sousuo_phone = strValue;
  185. for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
  186. {
  187. unsigned char tmp = strValue.at(nIndex);
  188. if (tmp > 57 || tmp < 48)
  189. {
  190. //ASCII码不是数字的都过滤掉
  191. strValue = strValue.substr(0, nIndex);
  192. m_sousuo_phone = strValue;
  193. m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
  194. m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
  195. break;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. //处理扫码枪捕捉到的扫码信息
  202. void CHuiyuanPageUI::HandleTextCapture(std::string content)
  203. {
  204. if (m_is_show_modal_wnd == true)
  205. {
  206. m_curModalWnd->HandleTextCapture(content);
  207. }
  208. }
  209. void CHuiyuanPageUI::StartHuiyuanSousuo()
  210. {
  211. if (m_is_handle == true)
  212. {
  213. return;
  214. }
  215. std::wstring ws_phone = CLewaimaiString::UTF8ToUnicode(m_sousuo_phone);
  216. if (ws_phone.length() != 11)
  217. {
  218. //手机号格式错误
  219. ShowError(L"手机号格式不对!");
  220. }
  221. //手机号格式正确,开始处理
  222. m_is_handle = true;
  223. m_phone = CLewaimaiString::UnicodeToUTF8(ws_phone);
  224. std::map<string, string> params;
  225. params["phone"] = m_phone;
  226. std::string response;
  227. bool ret = CZhipuziHttpClient::GetInstance()->Request("/member/membercheckbyphone", params, response);
  228. if (!ret)
  229. {
  230. ShowError(L"网络请求出错");
  231. m_is_handle = false;
  232. return;
  233. }
  234. rapidjson::Document document;
  235. document.Parse(response.c_str());
  236. if (document.HasParseError())
  237. {
  238. ShowError(L"服务器返回数据格式错误");
  239. m_is_handle = false;
  240. return;
  241. }
  242. else
  243. {
  244. if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
  245. {
  246. ShowError(L"服务器返回数据格式错误");
  247. m_is_handle = false;
  248. return;
  249. }
  250. rapidjson::Value& v_errcode = document["errcode"];
  251. int errcode = v_errcode.GetInt();
  252. if (errcode != 0)
  253. {
  254. std::string errmsg = CLewaimaiString::UnicodeToUTF8(L"搜索结果:") + string(document["errmsg"].GetString());
  255. std::wstring m_errorInfo = CLewaimaiString::UTF8ToUnicode(errmsg);
  256. ShowError(m_errorInfo);
  257. m_is_handle = false;
  258. return;
  259. }
  260. rapidjson::Value& data = document["data"];
  261. rapidjson::Value& rows = data["rows"];
  262. if (rows.Size() < 1)
  263. {
  264. ShowError(L"会员信息为空");
  265. m_is_handle = false;
  266. return;
  267. }
  268. rapidjson::Value& rowinfo = rows[0];
  269. m_name = rowinfo["name"].GetString();
  270. m_phone = rowinfo["phone"].GetString();
  271. m_sex = rowinfo["sex"].GetString();
  272. m_birthday = rowinfo["birthday"].GetString();
  273. m_balance = rowinfo["balance"].GetString();
  274. std::string member_level_name = rowinfo["member_level_name"].GetString();
  275. m_address = rowinfo["address"].GetString();
  276. m_card_identify = rowinfo["card_identify"].GetString();
  277. bool is_card;
  278. if (m_card_identify == "")
  279. {
  280. is_card = false;
  281. }
  282. else
  283. {
  284. is_card = true;
  285. }
  286. m_freeze = rowinfo["freeze"].GetString();
  287. m_is_open_pay_password = rowinfo["open_no_card_payment"].GetString();
  288. m_md5_password = rowinfo["pay_password"].GetString();
  289. m_member_id = rowinfo["id"].GetString();
  290. m_member_card_no = rowinfo["card_no"].GetString();
  291. this->FindSubControl(L"huiyuan_num")->SetText((L"会员卡号:" + CLewaimaiString::UTF8ToUnicode(m_member_card_no)).c_str());
  292. this->FindSubControl(L"huiyuan_phone")->SetText((L"手机号:" + CLewaimaiString::UTF8ToUnicode(m_phone)).c_str());
  293. if (m_is_open_pay_password == "1")
  294. {
  295. this->FindSubControl(L"huiyuan_mimazhifu")->SetText(L"密码登录:已开启");
  296. }
  297. else
  298. {
  299. this->FindSubControl(L"huiyuan_mimazhifu")->SetText(L"密码登录:未开启");
  300. }
  301. this->FindSubControl(L"huiyuan_name")->SetText((L"会员姓名:" + CLewaimaiString::UTF8ToUnicode(m_name)).c_str());
  302. this->FindSubControl(L"huiyuan_sex")->SetText((L"性别:" + CLewaimaiString::UTF8ToUnicode(m_sex)).c_str());
  303. this->FindSubControl(L"huiyuan_address")->SetText((L"地址:" + CLewaimaiString::UTF8ToUnicode(m_address)).c_str());
  304. this->FindSubControl(L"huiyuan_birthday")->SetText((L"生日:" + CLewaimaiString::UTF8ToUnicode(m_birthday)).c_str());
  305. this->FindSubControl(L"huiyuan_levelname")->SetText((L"会员级别:" + CLewaimaiString::UTF8ToUnicode(member_level_name)).c_str());
  306. this->FindSubControl(L"huiyuan_yue")->SetText((L"当前余额:" + CLewaimaiString::UTF8ToUnicode(m_balance)).c_str());
  307. if (is_card)
  308. {
  309. this->FindSubControl(L"huiyuan_shitika")->SetText(L"实体会员卡:已绑定");
  310. }
  311. else
  312. {
  313. this->FindSubControl(L"huiyuan_shitika")->SetText(L"实体会员卡:未绑定");
  314. }
  315. if (m_freeze == "0")
  316. {
  317. this->FindSubControl(L"huiyuan_status")->SetText(L"会员状态:正常");
  318. this->FindSubControl(L"huiiyuan_page_dongjie_btn")->SetVisible(true);
  319. this->FindSubControl(L"huiiyuan_page_jiedong_btn")->SetVisible(false);
  320. }
  321. else
  322. {
  323. this->FindSubControl(L"huiyuan_status")->SetText(L"会员状态:已冻结");
  324. this->FindSubControl(L"huiiyuan_page_dongjie_btn")->SetVisible(false);
  325. this->FindSubControl(L"huiiyuan_page_jiedong_btn")->SetVisible(true);
  326. }
  327. this->FindSubControl(L"huiyuan_info_layout")->SetVisible(true);
  328. this->FindSubControl(L"huiyuan_page_no_layout")->SetVisible(false);
  329. m_is_handle = false;
  330. HideError();
  331. }
  332. }
  333. void CHuiyuanPageUI::ShowError(std::wstring err)
  334. {
  335. CLabelUI* m_pLabel= static_cast<CLabelUI*>(this->FindSubControl(_T("errorinfo")));
  336. m_pLabel->SetText(err.c_str());
  337. m_pLabel->SetVisible(true);
  338. this->FindSubControl(L"huiyuan_info_layout")->SetVisible(false);
  339. this->FindSubControl(L"huiyuan_page_no_layout")->SetVisible(true);
  340. }
  341. void CHuiyuanPageUI::StartAddHuiyuan()
  342. {
  343. if (m_is_show_modal_wnd == true)
  344. {
  345. return;
  346. }
  347. CHuiyuanAddWnd* pShoukuanWnd = new CHuiyuanAddWnd();
  348. if (pShoukuanWnd != NULL)
  349. {
  350. m_is_show_modal_wnd = true;
  351. m_curModalWnd = pShoukuanWnd;
  352. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  353. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  354. pShoukuanWnd->CenterWindow();
  355. UINT ret = pShoukuanWnd->ShowModal();
  356. if (ret == IDOK)
  357. {
  358. //会员开通成功
  359. m_pMainWnd->ShowToast(L"会员开通成功");
  360. m_sousuo_phone = pShoukuanWnd->m_phone;
  361. StartHuiyuanSousuo();
  362. }
  363. m_is_show_modal_wnd = false;
  364. delete pShoukuanWnd;
  365. }
  366. }
  367. void CHuiyuanPageUI::StartHuiyuanChongzhi()
  368. {
  369. if (m_is_show_modal_wnd == true)
  370. {
  371. return;
  372. }
  373. //充值之前,保存一下搜索电话,因为充值成功后要刷新的
  374. m_sousuo_phone = m_phone;
  375. CHuiyuanChongzhiWnd* pShoukuanWnd = new CHuiyuanChongzhiWnd();
  376. if (pShoukuanWnd != NULL)
  377. {
  378. m_is_show_modal_wnd = true;
  379. m_curModalWnd = pShoukuanWnd;
  380. pShoukuanWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  381. pShoukuanWnd->SetIcon(IDI_ICON_DUILIB);
  382. pShoukuanWnd->CenterWindow();
  383. pShoukuanWnd->SetCurBalance(m_balance);
  384. pShoukuanWnd->m_member_id = m_member_id;
  385. pShoukuanWnd->m_member_card_no = m_member_card_no;
  386. UINT ret = pShoukuanWnd->ShowModal();
  387. if (ret == IDOK)
  388. {
  389. //然后处理小票打印
  390. CHuiyuanchongzhiOrder order;
  391. order.shopname = CShopinfo::GetInstance()->m_shop_name;
  392. order.show_trade_no = pShoukuanWnd->m_show_trade_no;
  393. order.init_time = CLewaimaiTime::DatetimeToString(time(NULL));
  394. order.account = CSetting::GetInstance()->getUsername();
  395. order.member_num = pShoukuanWnd->m_member_card_no;
  396. order.chongzhi_value = pShoukuanWnd->m_chongzhi;
  397. order.zengsong_value = pShoukuanWnd->m_zengsong;
  398. order.balance_before = pShoukuanWnd->m_cur_balance;
  399. order.balance_after = CLewaimaiString::DoubleToString(atof(m_balance.c_str()) + atof(order.chongzhi_value.c_str()) + atof(order.zengsong_value.c_str()), 2);
  400. if (pShoukuanWnd->m_shoukuan_type == 1)
  401. {
  402. if (pShoukuanWnd->m_fukuanma_type == 1)
  403. {
  404. order.pay_type = "微信支付";
  405. }
  406. else if (pShoukuanWnd->m_fukuanma_type == 2)
  407. {
  408. order.pay_type = "支付宝";
  409. }
  410. else if (pShoukuanWnd->m_fukuanma_type == 2)
  411. {
  412. order.pay_type = "云闪付";
  413. }
  414. }
  415. else if (pShoukuanWnd ->m_shoukuan_type == 2)
  416. {
  417. order.pay_type = "现金支付";
  418. }
  419. else if (pShoukuanWnd->m_shoukuan_type == 3)
  420. {
  421. order.pay_type = CLewaimaiString::UTF8ToANSI(pShoukuanWnd->m_zidingyi_name);
  422. }
  423. CPosPrinter printer;
  424. printer.PrintHuiyuanchongzhiOrder(order);
  425. //这个表示充值成功了,这个时候刷新会员信息
  426. StartHuiyuanSousuo();
  427. }
  428. m_is_show_modal_wnd = false;
  429. delete pShoukuanWnd;
  430. }
  431. }
  432. void CHuiyuanPageUI::StartXiugaiziliao()
  433. {
  434. if (m_is_show_modal_wnd == true)
  435. {
  436. return;
  437. }
  438. CHuiyuanXiugaiziliaoWnd* pXiugaiziliaoWnd = new CHuiyuanXiugaiziliaoWnd();
  439. if (pXiugaiziliaoWnd != NULL)
  440. {
  441. m_is_show_modal_wnd = true;
  442. m_curModalWnd = pXiugaiziliaoWnd;
  443. pXiugaiziliaoWnd->SetMemberInfo(m_member_id, m_phone, m_is_open_pay_password, m_name, m_member_card_no, m_sex, m_birthday, m_address, m_card_identify, m_md5_password);
  444. pXiugaiziliaoWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  445. pXiugaiziliaoWnd->SetIcon(IDI_ICON_DUILIB);
  446. pXiugaiziliaoWnd->CenterWindow();
  447. UINT ret = pXiugaiziliaoWnd->ShowModal();
  448. if (ret == IDOK)
  449. {
  450. //重新搜索,更新会员信息
  451. StartHuiyuanSousuo();
  452. }
  453. m_is_show_modal_wnd = false;
  454. delete pXiugaiziliaoWnd;
  455. }
  456. }
  457. //修改登录密码
  458. void CHuiyuanPageUI::StartXiugaimima()
  459. {
  460. if (m_is_show_modal_wnd == true)
  461. {
  462. return;
  463. }
  464. CHuiyuanXiugaimimaWnd* pXiugaiziliaoWnd = new CHuiyuanXiugaimimaWnd();
  465. if (pXiugaiziliaoWnd != NULL)
  466. {
  467. m_is_show_modal_wnd = true;
  468. m_curModalWnd = pXiugaiziliaoWnd;
  469. pXiugaiziliaoWnd->SetMemberInfo(m_member_id, m_phone, m_is_open_pay_password, m_name, m_member_card_no, m_sex, m_birthday, m_address, m_card_identify);
  470. pXiugaiziliaoWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  471. pXiugaiziliaoWnd->SetIcon(IDI_ICON_DUILIB);
  472. pXiugaiziliaoWnd->CenterWindow();
  473. UINT ret = pXiugaiziliaoWnd->ShowModal();
  474. if (ret == IDOK)
  475. {
  476. //重新搜索,更新会员信息
  477. StartHuiyuanSousuo();
  478. }
  479. m_is_show_modal_wnd = false;
  480. delete pXiugaiziliaoWnd;
  481. }
  482. }
  483. void CHuiyuanPageUI::StartBangka()
  484. {
  485. if (m_card_identify != "")
  486. {
  487. m_pMainWnd->ShowToast(L"该会员已绑卡,无需再次绑卡");
  488. return;
  489. }
  490. if (m_is_show_modal_wnd == true)
  491. {
  492. return;
  493. }
  494. CHuiyuanBangkaWnd* pXiugaiziliaoWnd = new CHuiyuanBangkaWnd();
  495. if (pXiugaiziliaoWnd != NULL)
  496. {
  497. m_is_show_modal_wnd = true;
  498. m_curModalWnd = pXiugaiziliaoWnd;
  499. pXiugaiziliaoWnd->SetMemberInfo(m_member_id, m_phone, m_is_open_pay_password, m_name, m_member_card_no, m_sex, m_birthday, m_address, m_card_identify, m_md5_password);
  500. pXiugaiziliaoWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  501. pXiugaiziliaoWnd->SetIcon(IDI_ICON_DUILIB);
  502. pXiugaiziliaoWnd->CenterWindow();
  503. UINT ret = pXiugaiziliaoWnd->ShowModal();
  504. if (ret == IDOK)
  505. {
  506. m_pMainWnd->ShowToast(L"绑定实体卡成功");
  507. //重新搜索,更新会员信息
  508. StartHuiyuanSousuo();
  509. }
  510. m_is_show_modal_wnd = false;
  511. delete pXiugaiziliaoWnd;
  512. }
  513. }
  514. void CHuiyuanPageUI::StartGuashi()
  515. {
  516. if (m_card_identify == "")
  517. {
  518. m_pMainWnd->ShowToast(L"该会员还未绑实体卡,无需挂失");
  519. return;
  520. }
  521. if (m_is_show_modal_wnd == true)
  522. {
  523. return;
  524. }
  525. CAttentionWnd* pXiugaiziliaoWnd = new CAttentionWnd();
  526. if (pXiugaiziliaoWnd != NULL)
  527. {
  528. m_is_show_modal_wnd = true;
  529. m_curModalWnd = pXiugaiziliaoWnd;
  530. pXiugaiziliaoWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  531. pXiugaiziliaoWnd->SetIcon(IDI_ICON_DUILIB);
  532. pXiugaiziliaoWnd->CenterWindow();
  533. pXiugaiziliaoWnd->SetTitle(L"会员挂失确认");
  534. pXiugaiziliaoWnd->SetContent(L"确认挂失该会员卡吗,挂失后会员的实体会员卡将无法使用");
  535. UINT ret = pXiugaiziliaoWnd->ShowModal();
  536. if (ret == IDOK)
  537. {
  538. std::map<string, string> params;
  539. params["card_no"] = m_member_card_no;
  540. params["name"] = m_name;
  541. params["birthday"] = m_birthday;
  542. params["address"] = m_address;
  543. params["sex"] = m_sex;
  544. params["captcha"] = "";
  545. params["pay_password"] = m_md5_password;
  546. params["open_no_card_payment"] = m_is_open_pay_password;
  547. params["is_no_card"] = "1";
  548. params["member_id"] = m_member_id;
  549. params["card_identify"] = "";
  550. std::string response;
  551. bool ret = CZhipuziHttpClient::GetInstance()->Request("/member/changeinfo", params, response);
  552. if (!ret)
  553. {
  554. m_pMainWnd->ShowToast(L"网络错误");
  555. return;
  556. }
  557. rapidjson::Document document;
  558. document.Parse(response.c_str());
  559. if (document.HasParseError())
  560. {
  561. m_pMainWnd->ShowToast(L"服务器返回数据格式错误");
  562. return;
  563. }
  564. else
  565. {
  566. if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
  567. {
  568. m_pMainWnd->ShowToast(L"服务器返回数据格式错误");
  569. return;
  570. }
  571. rapidjson::Value& v_errcode = document["errcode"];
  572. int errcode = v_errcode.GetInt();
  573. if (errcode != 0)
  574. {
  575. std::string errmsg = CLewaimaiString::UnicodeToUTF8(L"挂失会员失败:") + string(document["errmsg"].GetString());
  576. std::wstring errorInfo = CLewaimaiString::UTF8ToUnicode(errmsg);
  577. m_pMainWnd->ShowToast(errorInfo);
  578. return;
  579. }
  580. m_pMainWnd->ShowToast(L"实体卡挂失成功");
  581. //重新搜索,更新会员信息
  582. StartHuiyuanSousuo();
  583. }
  584. }
  585. m_is_show_modal_wnd = false;
  586. delete pXiugaiziliaoWnd;
  587. }
  588. }
  589. void CHuiyuanPageUI::StartDongjie()
  590. {
  591. if (m_freeze == "1")
  592. {
  593. m_pMainWnd->ShowToast(L"该会员已冻结,无法继续冻结");
  594. return;
  595. }
  596. if (m_is_show_modal_wnd == true)
  597. {
  598. return;
  599. }
  600. CAttentionWnd* pXiugaiziliaoWnd = new CAttentionWnd();
  601. if (pXiugaiziliaoWnd != NULL)
  602. {
  603. m_is_show_modal_wnd = true;
  604. m_curModalWnd = pXiugaiziliaoWnd;
  605. pXiugaiziliaoWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  606. pXiugaiziliaoWnd->SetIcon(IDI_ICON_DUILIB);
  607. pXiugaiziliaoWnd->CenterWindow();
  608. pXiugaiziliaoWnd->SetTitle(L"会员冻结确认");
  609. pXiugaiziliaoWnd->SetContent(L"确认冻结该会员吗,冻结后该会员的功能暂时无法使用");
  610. UINT ret = pXiugaiziliaoWnd->ShowModal();
  611. if (ret == IDOK)
  612. {
  613. std::map<string, string> params;
  614. params["member_id"] = m_member_id;
  615. std::string response;
  616. bool ret = CZhipuziHttpClient::GetInstance()->Request("/member/freeze", params, response);
  617. if (!ret)
  618. {
  619. m_pMainWnd->ShowToast(L"网络错误");
  620. return;
  621. }
  622. rapidjson::Document document;
  623. document.Parse(response.c_str());
  624. if (document.HasParseError())
  625. {
  626. m_pMainWnd->ShowToast(L"服务器返回数据格式错误");
  627. return;
  628. }
  629. else
  630. {
  631. if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
  632. {
  633. m_pMainWnd->ShowToast(L"服务器返回数据格式错误");
  634. return;
  635. }
  636. rapidjson::Value& v_errcode = document["errcode"];
  637. int errcode = v_errcode.GetInt();
  638. if (errcode != 0)
  639. {
  640. std::string errmsg = CLewaimaiString::UnicodeToUTF8(L"冻结会员失败:") + string(document["errmsg"].GetString());
  641. std::wstring errorInfo = CLewaimaiString::UTF8ToUnicode(errmsg);
  642. m_pMainWnd->ShowToast(errorInfo);
  643. return;
  644. }
  645. m_pMainWnd->ShowToast(L"会员冻结成功");
  646. //重新搜索,更新会员信息
  647. StartHuiyuanSousuo();
  648. }
  649. }
  650. m_is_show_modal_wnd = false;
  651. delete pXiugaiziliaoWnd;
  652. }
  653. }
  654. void CHuiyuanPageUI::StartJiedong()
  655. {
  656. if (m_freeze == "0")
  657. {
  658. m_pMainWnd->ShowToast(L"该会员未冻结,无法继续解冻");
  659. return;
  660. }
  661. if (m_is_show_modal_wnd == true)
  662. {
  663. return;
  664. }
  665. CAttentionWnd* pXiugaiziliaoWnd = new CAttentionWnd();
  666. if (pXiugaiziliaoWnd != NULL)
  667. {
  668. m_is_show_modal_wnd = true;
  669. m_curModalWnd = pXiugaiziliaoWnd;
  670. pXiugaiziliaoWnd->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
  671. pXiugaiziliaoWnd->SetIcon(IDI_ICON_DUILIB);
  672. pXiugaiziliaoWnd->CenterWindow();
  673. pXiugaiziliaoWnd->SetTitle(L"会员解冻确认");
  674. pXiugaiziliaoWnd->SetContent(L"确认解冻该会员吗,解冻后该会员将恢复正常的会员功能");
  675. UINT ret = pXiugaiziliaoWnd->ShowModal();
  676. if (ret == IDOK)
  677. {
  678. std::map<string, string> params;
  679. params["member_id"] = m_member_id;
  680. std::string response;
  681. bool ret = CZhipuziHttpClient::GetInstance()->Request("/member/unfreeze", params, response);
  682. if (!ret)
  683. {
  684. m_pMainWnd->ShowToast(L"网络错误");
  685. return;
  686. }
  687. rapidjson::Document document;
  688. document.Parse(response.c_str());
  689. if (document.HasParseError())
  690. {
  691. m_pMainWnd->ShowToast(L"服务器返回数据格式错误");
  692. return;
  693. }
  694. else
  695. {
  696. if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
  697. {
  698. m_pMainWnd->ShowToast(L"服务器返回数据格式错误");
  699. return;
  700. }
  701. rapidjson::Value& v_errcode = document["errcode"];
  702. int errcode = v_errcode.GetInt();
  703. if (errcode != 0)
  704. {
  705. std::string errmsg = CLewaimaiString::UnicodeToUTF8(L"解冻会员失败:") + string(document["errmsg"].GetString());
  706. std::wstring errorInfo = CLewaimaiString::UTF8ToUnicode(errmsg);
  707. m_pMainWnd->ShowToast(errorInfo);
  708. return;
  709. }
  710. m_pMainWnd->ShowToast(L"会员解冻成功");
  711. //重新搜索,更新会员信息
  712. StartHuiyuanSousuo();
  713. }
  714. }
  715. m_is_show_modal_wnd = false;
  716. delete pXiugaiziliaoWnd;
  717. }
  718. }
  719. void CHuiyuanPageUI::HideError()
  720. {
  721. CLabelUI* m_pLabel = static_cast<CLabelUI*>(this->FindSubControl(_T("errorinfo")));
  722. m_pLabel->SetVisible(false);
  723. }