CZhengcanTableItemUI.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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)
  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. }
  41. void CZhengcanTableItemUI::UpdateShow()
  42. {
  43. CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("tablename")));
  44. pName->SetText(CLewaimaiString::UTF8ToUnicode(m_table_name).c_str());
  45. CLabelUI* pStatus = static_cast<CLabelUI*>(this->FindSubControl(_T("status")));
  46. CLabelUI* pRenshu = static_cast<CLabelUI*>(this->FindSubControl(_T("renshu")));
  47. CLabelUI* pShijian = static_cast<CLabelUI*>(this->FindSubControl(_T("shijian")));
  48. CControlUI* pPeopleImage = static_cast<CControlUI*>(this->FindSubControl(_T("people_image")));
  49. CControlUI* pTimeImage = static_cast<CControlUI*>(this->FindSubControl(_T("time_image")));
  50. pRenshu->SetText(CLewaimaiString::UTF8ToUnicode(m_limit_number).c_str());
  51. if (m_status == "0")
  52. {
  53. //未开台
  54. pStatus->SetText(L"未开台");
  55. //隐藏时钟
  56. pTimeImage->SetVisible(false);
  57. pShijian->SetVisible(false);
  58. }
  59. else if (m_status == "1")
  60. {
  61. //预约中
  62. }
  63. else if (m_status == "2")
  64. {
  65. //已开台
  66. pName->SetTextColor(0xFFFFFFFF);
  67. pStatus->SetTextColor(0xFFFFFFFF);
  68. pRenshu->SetTextColor(0xFFFFFFFF);
  69. pShijian->SetTextColor(0xFFFFFFFF);
  70. pPeopleImage->SetBkImage(L"zhengcan_people_1.png");
  71. pTimeImage->SetBkImage(L"zhengcan_time_1.png");
  72. time_t now = time(NULL);
  73. time_t init_time = CLewaimaiTime::StringToDatetime(m_order_init_time);
  74. time_t diff = now - init_time;
  75. int fenzhong = (int)(diff / 60);
  76. std::wstring ws_fenzhong;
  77. if (fenzhong > 999)
  78. {
  79. ws_fenzhong = L">999";
  80. }
  81. else
  82. {
  83. ws_fenzhong = to_wstring(fenzhong);
  84. }
  85. pShijian->SetText((ws_fenzhong + L"分钟").c_str());
  86. CHorizontalLayoutUI* pBottom = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(L"zhengcan_tableitem_bottom"));
  87. //区分待下单、待结账、待清台这3个状态
  88. if (m_order_id == "0")
  89. {
  90. //说明还未下单,处于待下单状态,用绿色
  91. this->SetBkColor(0xFF3CB371);
  92. pBottom->SetBkColor(0xFF28A25E);
  93. pStatus->SetText(L"待下单");
  94. }
  95. else if (m_order_status == "SUCCESS")
  96. {
  97. //待清台,用蓝色
  98. this->SetBkColor(0xFF497FC7);
  99. pBottom->SetBkColor(0xFF3A74C2);
  100. pStatus->SetText(L"待清台");
  101. }
  102. else
  103. {
  104. //包含OPEN PASSWORD CLOSE等,只要没支付成功,就是未支付状态
  105. //说明已下单,未支付,处于待支付状态,用红色
  106. this->SetBkColor(0xFFF95252);
  107. pBottom->SetBkColor(0xFFF73F3F);
  108. pStatus->SetText(L"待结账");
  109. }
  110. }
  111. }
  112. void CZhengcanTableItemUI::ShowZhuanchu(bool is_show)
  113. {
  114. CControlUI* zhuanchuControl = static_cast<CControlUI*>(this->FindSubControl(L"zhuantai_zhuanchu"));
  115. if (is_show == true)
  116. {
  117. zhuanchuControl->SetVisible(true);
  118. }
  119. else
  120. {
  121. zhuanchuControl->SetVisible(false);
  122. }
  123. }
  124. void CZhengcanTableItemUI::ShowZhuanru(bool is_show)
  125. {
  126. CControlUI* zhuanruControl = static_cast<CControlUI*>(this->FindSubControl(L"zhuantai_zhuanru"));
  127. if (is_show == true)
  128. {
  129. zhuanruControl->SetVisible(true);
  130. }
  131. else
  132. {
  133. zhuanruControl->SetVisible(false);
  134. }
  135. }