CZhengcanTableItemUI.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #include "CZhengcanTableItemUI.h"
  2. #include "../pch/pch.h"
  3. CZhengcanTableItemUI::CZhengcanTableItemUI()
  4. {
  5. }
  6. CZhengcanTableItemUI::~CZhengcanTableItemUI()
  7. {
  8. }
  9. void CZhengcanTableItemUI::DoEvent(TEventUI& event)
  10. {
  11. if (event.Type == UIEVENT_BUTTONUP)
  12. {
  13. m_pManager->SendNotify(this, DUI_MSGTYPE_CLICK);
  14. }
  15. else if (event.Type == UIEVENT_MOUSEENTER)
  16. {
  17. HCURSOR hcur = LoadCursor(NULL, IDC_HAND); //加载系统自带鼠标样式
  18. HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
  19. SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
  20. }
  21. else if (event.Type == UIEVENT_MOUSELEAVE)
  22. {
  23. HCURSOR hcur = LoadCursor(NULL, IDC_ARROW); //加载系统自带鼠标样式
  24. HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
  25. SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
  26. }
  27. CVerticalLayoutUI::DoEvent(event);
  28. }
  29. void CZhengcanTableItemUI::SetInfo(std::string table_id, std::string table_name, std::string type_id, std::string status, std::string order_init_time, std::string from_type, std::string order_status, std::string order_id, std::string limit_number, std::string person_num)
  30. {
  31. m_table_id = table_id;
  32. m_table_name = table_name;
  33. m_type_id = type_id;
  34. m_status = status;
  35. m_order_init_time = order_init_time;
  36. m_from_type = from_type;
  37. m_order_status = order_status;
  38. m_order_id = order_id;
  39. m_limit_number = limit_number;
  40. m_person_num = person_num;
  41. }
  42. void CZhengcanTableItemUI::UpdateShow()
  43. {
  44. CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("tablename")));
  45. pName->SetText(CLewaimaiString::UTF8ToUnicode(m_table_name).c_str());
  46. CLabelUI* pStatus = static_cast<CLabelUI*>(this->FindSubControl(_T("status")));
  47. CLabelUI* pRenshu = static_cast<CLabelUI*>(this->FindSubControl(_T("renshu")));
  48. CLabelUI* pShijian = static_cast<CLabelUI*>(this->FindSubControl(_T("shijian")));
  49. CControlUI* pPeopleImage = static_cast<CControlUI*>(this->FindSubControl(_T("people_image")));
  50. CControlUI* pTimeImage = static_cast<CControlUI*>(this->FindSubControl(_T("time_image")));
  51. pRenshu->SetText(CLewaimaiString::UTF8ToUnicode(m_limit_number).c_str());
  52. if (m_status == "0")
  53. {
  54. //未开台
  55. pStatus->SetText(L"未开台");
  56. //隐藏时钟
  57. pTimeImage->SetVisible(false);
  58. pShijian->SetVisible(false);
  59. }
  60. else if (m_status == "1")
  61. {
  62. //预约中
  63. }
  64. else if (m_status == "2")
  65. {
  66. //已开台
  67. pRenshu->SetText((CLewaimaiString::UTF8ToUnicode(m_person_num) + L"人").c_str());
  68. pName->SetTextColor(0xFFFFFFFF);
  69. pStatus->SetTextColor(0xFFFFFFFF);
  70. pRenshu->SetTextColor(0xFFFFFFFF);
  71. pShijian->SetTextColor(0xFFFFFFFF);
  72. pPeopleImage->SetBkImage(L"zhengcan_people_1.png");
  73. pTimeImage->SetBkImage(L"zhengcan_time_1.png");
  74. time_t now = time(NULL);
  75. time_t init_time = CLewaimaiTime::StringToDatetime(m_order_init_time);
  76. time_t diff = now - init_time;
  77. int fenzhong = (int)(diff / 60);
  78. std::wstring ws_fenzhong;
  79. if (fenzhong > 999)
  80. {
  81. ws_fenzhong = L">999";
  82. }
  83. else
  84. {
  85. ws_fenzhong = to_wstring(fenzhong);
  86. }
  87. pShijian->SetText((ws_fenzhong + L"分钟").c_str());
  88. CHorizontalLayoutUI* pBottom = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(L"zhengcan_tableitem_bottom"));
  89. //区分待下单、待结账、待清台这3个状态
  90. if (m_order_id == "0")
  91. {
  92. //说明还未下单,处于待下单状态,用绿色
  93. this->SetBkColor(0xFF3CB371);
  94. pBottom->SetBkColor(0xFF28A25E);
  95. pStatus->SetText(L"待下单");
  96. }
  97. else if (m_order_status == "SUCCESS")
  98. {
  99. //待清台,用蓝色
  100. this->SetBkColor(0xFF497FC7);
  101. pBottom->SetBkColor(0xFF3A74C2);
  102. pStatus->SetText(L"待清台");
  103. }
  104. else
  105. {
  106. //包含OPEN PASSWORD CLOSE等,只要没支付成功,就是未支付状态
  107. //说明已下单,未支付,处于待支付状态,用红色
  108. this->SetBkColor(0xFFF95252);
  109. pBottom->SetBkColor(0xFFF73F3F);
  110. pStatus->SetText(L"待结账");
  111. }
  112. }
  113. }
  114. void CZhengcanTableItemUI::ShowZhuanchu(bool is_show)
  115. {
  116. CControlUI* zhuanchuControl = static_cast<CControlUI*>(this->FindSubControl(L"zhuantai_zhuanchu"));
  117. if (is_show == true)
  118. {
  119. zhuanchuControl->SetVisible(true);
  120. }
  121. else
  122. {
  123. zhuanchuControl->SetVisible(false);
  124. }
  125. }
  126. void CZhengcanTableItemUI::ShowZhuanru(bool is_show)
  127. {
  128. CControlUI* zhuanruControl = static_cast<CControlUI*>(this->FindSubControl(L"zhuantai_zhuanru"));
  129. if (is_show == true)
  130. {
  131. zhuanruControl->SetVisible(true);
  132. }
  133. else
  134. {
  135. zhuanruControl->SetVisible(false);
  136. }
  137. }