| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #include "CDiandanFoodItemUI.h"
- #include "../pch/pch.h"
- CDiandanFoodItemUI::CDiandanFoodItemUI()
- {
- }
- CDiandanFoodItemUI::~CDiandanFoodItemUI()
- {
- }
- void CDiandanFoodItemUI::DoEvent(TEventUI& event)
- {
- if (event.Type == UIEVENT_BUTTONUP)
- {
- m_pManager->SendNotify(this, DUI_MSGTYPE_CLICK);
- }
- else if (event.Type == UIEVENT_MOUSEENTER)
- {
- HCURSOR hcur = LoadCursor(NULL, IDC_HAND); //加载系统自带鼠标样式
- HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
- //SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
- }
- else if (event.Type == UIEVENT_MOUSELEAVE)
- {
- HCURSOR hcur = LoadCursor(NULL, IDC_ARROW); //加载系统自带鼠标样式
- HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
- //SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
- }
- CVerticalLayoutUI::DoEvent(event);
- }
- void CDiandanFoodItemUI::SetFoodInfo(CFood info)
- {
- m_foodinfo = info;
- }
- void CDiandanFoodItemUI::SetFoodpackageInfo(CFoodpackage info)
- {
- m_foodpackageinfo = info;
- m_is_taocan = true;
- }
- void CDiandanFoodItemUI::SetIsTaocan(bool is_taocan)
- {
- m_is_taocan = is_taocan;
- }
- CFood CDiandanFoodItemUI::GetFoodInfo()
- {
- return m_foodinfo;
- }
- CFoodpackage CDiandanFoodItemUI::GetFoodpackageInfo()
- {
- return m_foodpackageinfo;
- }
- bool CDiandanFoodItemUI::GetIsTaocan()
- {
- return m_is_taocan;
- }
- void CDiandanFoodItemUI::UpdateShow()
- {
- if (m_is_taocan)
- {
- if (m_is_youtu)
- {
- CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image")));
- //获取本地图片的路径
- std::wstring imagepath = m_foodpackageinfo.getImageTmpPath();
- if (CSystem::IsFileExist(imagepath.c_str()))
- {
- //图片已经存在,直接显示
- pImage->SetBkImage(imagepath.c_str());
- }
- }
- CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("foodname")));
- pName->SetText(CLewaimaiString::UTF8ToUnicode(m_foodpackageinfo.name).c_str());
- CLabelUI* pPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("price")));
- std::wstring price = L"¥" + CLewaimaiString::UTF8ToUnicode(m_foodpackageinfo.price);
- pPrice->SetText(price.c_str());
- //属性商品,显示多属性标签
- CLabelUI* pNature = static_cast<CLabelUI*>(this->FindSubControl(_T("nature")));
- pNature->SetVisible(true);
- }
- else
- {
- if (m_is_youtu)
- {
- CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image")));
- //获取本地图片的路径
- std::wstring imagepath = m_foodinfo.getImageTmpPath();
- if (CSystem::IsFileExist(imagepath.c_str()))
- {
- //图片已经存在,直接显示
- pImage->SetBkImage(imagepath.c_str());
- }
- }
- CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("foodname")));
- pName->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.name).c_str());
- CLabelUI* pPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("price")));
- std::wstring price = L"¥" + CLewaimaiString::UTF8ToUnicode(m_foodinfo.price);
- if (m_foodinfo.is_nature == "1")
- {
- price += L"起";
- }
- pPrice->SetText(price.c_str());
- if (m_foodinfo.is_weight == "1")
- {
- //称重商品,显示称重的标签(称重的标签与属性的标签不同时存在,优先显示称重的)
- CLabelUI* pChenzhong = static_cast<CLabelUI*>(this->FindSubControl(_T("chengzhong")));
- pChenzhong->SetVisible(true);
- }
- else
- {
- if (m_foodinfo.is_nature == "1")
- {
- //属性商品,显示多属性标签
- CLabelUI* pNature = static_cast<CLabelUI*>(this->FindSubControl(_T("nature")));
- pNature->SetVisible(true);
- }
- }
- if (m_foodinfo.stockvalid == "1" && atof(m_foodinfo.stock.c_str()) < 0.001)
- {
- //库存为0了
- CLabelUI* pKucun = static_cast<CLabelUI*>(this->FindSubControl(_T("kucun")));
- pKucun->SetVisible(true);
- }
- }
- }
- void CDiandanFoodItemUI::SetYoutuModel(bool is_youtu)
- {
- m_is_youtu = is_youtu;
- }
|