CDiandanFoodItemUI.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #include "CDiandanFoodItemUI.h"
  2. #include "../pch/pch.h"
  3. CDiandanFoodItemUI::CDiandanFoodItemUI()
  4. {
  5. }
  6. CDiandanFoodItemUI::~CDiandanFoodItemUI()
  7. {
  8. }
  9. void CDiandanFoodItemUI::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 CDiandanFoodItemUI::SetFoodInfo(CFood info)
  30. {
  31. m_foodinfo = info;
  32. }
  33. void CDiandanFoodItemUI::SetFoodpackageInfo(CFoodpackage info)
  34. {
  35. m_foodpackageinfo = info;
  36. m_is_taocan = true;
  37. }
  38. void CDiandanFoodItemUI::SetIsTaocan(bool is_taocan)
  39. {
  40. m_is_taocan = is_taocan;
  41. }
  42. CFood CDiandanFoodItemUI::GetFoodInfo()
  43. {
  44. return m_foodinfo;
  45. }
  46. CFoodpackage CDiandanFoodItemUI::GetFoodpackageInfo()
  47. {
  48. return m_foodpackageinfo;
  49. }
  50. bool CDiandanFoodItemUI::GetIsTaocan()
  51. {
  52. return m_is_taocan;
  53. }
  54. void CDiandanFoodItemUI::UpdateShow()
  55. {
  56. if (m_is_taocan)
  57. {
  58. if (m_is_youtu)
  59. {
  60. CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image")));
  61. //获取本地图片的路径
  62. std::wstring imagepath = m_foodpackageinfo.getImageTmpPath();
  63. if (CSystem::IsFileExist(imagepath.c_str()))
  64. {
  65. //图片已经存在,直接显示
  66. pImage->SetBkImage(imagepath.c_str());
  67. }
  68. }
  69. CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("foodname")));
  70. pName->SetText(CLewaimaiString::UTF8ToUnicode(m_foodpackageinfo.name).c_str());
  71. CLabelUI* pPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("price")));
  72. std::wstring price = L"¥" + CLewaimaiString::UTF8ToUnicode(m_foodpackageinfo.price);
  73. pPrice->SetText(price.c_str());
  74. //属性商品,显示多属性标签
  75. CLabelUI* pNature = static_cast<CLabelUI*>(this->FindSubControl(_T("nature")));
  76. pNature->SetVisible(true);
  77. }
  78. else
  79. {
  80. if (m_is_youtu)
  81. {
  82. CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image")));
  83. //获取本地图片的路径
  84. std::wstring imagepath = m_foodinfo.getImageTmpPath();
  85. if (CSystem::IsFileExist(imagepath.c_str()))
  86. {
  87. //图片已经存在,直接显示
  88. pImage->SetBkImage(imagepath.c_str());
  89. }
  90. }
  91. CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("foodname")));
  92. pName->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.name).c_str());
  93. CLabelUI* pPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("price")));
  94. std::wstring price = L"¥" + CLewaimaiString::UTF8ToUnicode(m_foodinfo.price);
  95. if (m_foodinfo.is_nature == "1")
  96. {
  97. price += L"起";
  98. }
  99. pPrice->SetText(price.c_str());
  100. if (m_foodinfo.is_weight == "1")
  101. {
  102. //称重商品,显示称重的标签(称重的标签与属性的标签不同时存在,优先显示称重的)
  103. CLabelUI* pChenzhong = static_cast<CLabelUI*>(this->FindSubControl(_T("chengzhong")));
  104. pChenzhong->SetVisible(true);
  105. }
  106. else
  107. {
  108. if (m_foodinfo.is_nature == "1")
  109. {
  110. //属性商品,显示多属性标签
  111. CLabelUI* pNature = static_cast<CLabelUI*>(this->FindSubControl(_T("nature")));
  112. pNature->SetVisible(true);
  113. }
  114. }
  115. if (m_foodinfo.stockvalid == "1" && atof(m_foodinfo.stock.c_str()) < 0.001)
  116. {
  117. //库存为0了
  118. CLabelUI* pKucun = static_cast<CLabelUI*>(this->FindSubControl(_T("kucun")));
  119. pKucun->SetVisible(true);
  120. }
  121. }
  122. }
  123. void CDiandanFoodItemUI::SetYoutuModel(bool is_youtu)
  124. {
  125. m_is_youtu = is_youtu;
  126. }