|
|
@@ -1,10 +1,12 @@
|
|
|
-#include "../pch/pch.h"
|
|
|
+#include "../pch/pch.h"
|
|
|
#include "CDiandanPageUI.h"
|
|
|
|
|
|
#include "../control/ControlEx.h"
|
|
|
|
|
|
#include "../tool/CSqlite3.h"
|
|
|
|
|
|
+#include "../wnd/CDiandanNatureWnd.h"
|
|
|
+
|
|
|
CDiandanPageUI::CDiandanPageUI()
|
|
|
{
|
|
|
}
|
|
|
@@ -14,7 +16,7 @@ CDiandanPageUI::~CDiandanPageUI()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
+//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
void CDiandanPageUI::InitShow()
|
|
|
{
|
|
|
m_foodLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("diandan_foodlist")));
|
|
|
@@ -22,25 +24,25 @@ void CDiandanPageUI::InitShow()
|
|
|
|
|
|
CSqlite3 sqlite;
|
|
|
m_nFoodpackageNum = sqlite.GetFoodpackageNum();
|
|
|
- m_types = sqlite.GetFoodtypes(); //只包含收银机显示的分类
|
|
|
+ m_types = sqlite.GetFoodtypes(); //只包含收银机显示的分类
|
|
|
if (m_nFoodpackageNum > 0)
|
|
|
{
|
|
|
- //默认选中的分类是商品套餐
|
|
|
+ //榛樿�閫変腑鐨勫垎绫绘槸鍟嗗搧濂楅�
|
|
|
m_cur_type_id = "taocan";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //没有套餐,默认选中第一个商品分类
|
|
|
+ //没有套餐,默认选中第一个商品分类
|
|
|
if (m_types.size() > 0)
|
|
|
{
|
|
|
m_cur_type_id = m_types[0].id;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //先初始化商品分类
|
|
|
+ //鍏堝垵濮嬪寲鍟嗗搧鍒嗙被
|
|
|
this->InitFoodtypeShow();
|
|
|
|
|
|
- //如果不是一个分类都没有,选中第一个分类
|
|
|
+ //如果不是一个分类都没有,选中第一个分类
|
|
|
if (m_cur_type_id != "")
|
|
|
{
|
|
|
CFoodtypeOptionUI* curTypeUI = static_cast<CFoodtypeOptionUI*>(m_foodtypeLayout->GetItemAt(0));
|
|
|
@@ -51,7 +53,7 @@ void CDiandanPageUI::InitShow()
|
|
|
this->RefreshFoodlist();
|
|
|
}
|
|
|
|
|
|
-//处理按钮点击类事件
|
|
|
+//处理按钮点击类事件
|
|
|
void CDiandanPageUI::HandleClickMsg(TNotifyUI& msg)
|
|
|
{
|
|
|
CDuiString name = msg.pSender->GetName();
|
|
|
@@ -66,7 +68,7 @@ void CDiandanPageUI::HandleClickMsg(TNotifyUI& msg)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//处理option切换事件
|
|
|
+//澶勭悊option鍒囨崲浜嬩欢
|
|
|
void CDiandanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
{
|
|
|
COptionUI* curOption = static_cast<COptionUI*>(msg.pSender);
|
|
|
@@ -75,7 +77,7 @@ void CDiandanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
|
|
|
if (groupname == L"diandan_foodtype")
|
|
|
{
|
|
|
- //商品分类切换
|
|
|
+ //鍟嗗搧鍒嗙被鍒囨崲
|
|
|
CFoodtypeOptionUI* typeUI = static_cast<CFoodtypeOptionUI*>(curOption);
|
|
|
std::string id = typeUI->GetTypeId();
|
|
|
|
|
|
@@ -85,7 +87,7 @@ void CDiandanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//处理下拉框、radio的切换事件
|
|
|
+//处理下拉框、radio的切换事件
|
|
|
void CDiandanPageUI::HandleItemSelectMsg(TNotifyUI& msg)
|
|
|
{
|
|
|
|
|
|
@@ -93,7 +95,7 @@ void CDiandanPageUI::HandleItemSelectMsg(TNotifyUI& msg)
|
|
|
|
|
|
void CDiandanPageUI::InitFoodtypeShow()
|
|
|
{
|
|
|
- //先判断有没有套餐分类
|
|
|
+ //鍏堝垽鏂�湁娌℃湁濂楅�鍒嗙被
|
|
|
if (m_nFoodpackageNum > 0)
|
|
|
{
|
|
|
CDialogBuilder builder;
|
|
|
@@ -101,7 +103,7 @@ void CDiandanPageUI::InitFoodtypeShow()
|
|
|
|
|
|
CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
|
|
|
- pItem->SetName(L"商品套餐");
|
|
|
+ pItem->SetName(L"鍟嗗搧濂楅�");
|
|
|
pItem->SetTypeId("taocan");
|
|
|
pItem->SetTaocan();
|
|
|
pItem->SetGroup(L"diandan_foodtype");
|
|
|
@@ -109,7 +111,7 @@ void CDiandanPageUI::InitFoodtypeShow()
|
|
|
m_foodtypeLayout->Add(pItem);
|
|
|
}
|
|
|
|
|
|
- //接下来开始处理商品分类
|
|
|
+ //接下来开始处理商品分类
|
|
|
for (std::vector<CFoodType>::iterator it = m_types.begin(); it != m_types.end(); it++)
|
|
|
{
|
|
|
CFoodType type = *it;
|
|
|
@@ -131,14 +133,14 @@ void CDiandanPageUI::RefreshFoodlist()
|
|
|
{
|
|
|
m_foodLayout->RemoveAll();
|
|
|
|
|
|
- //如果当前一个分类都没有,那么就不处理了
|
|
|
+ //濡傛灉褰撳墠涓€涓�垎绫婚兘娌℃湁锛岄偅涔堝氨涓嶅�鐞嗕簡
|
|
|
if (m_cur_type_id == "")
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
else if (m_cur_type_id == "taocan")
|
|
|
{
|
|
|
- //选择的是套餐分类
|
|
|
+ //閫夋嫨鐨勬槸濂楅�鍒嗙被
|
|
|
CSqlite3 sqlite;
|
|
|
std::vector<CFoodpackage> foodlist = sqlite.GetFoodpackages(true);
|
|
|
|
|
|
@@ -179,13 +181,17 @@ void CDiandanPageUI::RefreshFoodlist()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CDiandanPageUI::AddDiandanOrderItemShow(CDiandanOrderItem item)
|
|
|
+void CDiandanPageUI::AddDiandanOrderItemShow(int index)
|
|
|
{
|
|
|
+ CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(index);
|
|
|
+
|
|
|
CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_diandan_cart")));
|
|
|
|
|
|
CDialogBuilder builder;
|
|
|
CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("diandan_cart_item.xml"), (UINT)0, NULL, m_pManager));
|
|
|
|
|
|
+ pList->Add(pEle);
|
|
|
+
|
|
|
CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
|
|
|
|
|
|
@@ -193,9 +199,24 @@ void CDiandanPageUI::AddDiandanOrderItemShow(CDiandanOrderItem item)
|
|
|
pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
|
|
|
|
|
|
CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
|
|
|
- pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.price).c_str());
|
|
|
+ pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
|
|
|
|
|
|
- pList->Add(pEle);
|
|
|
+ CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
|
|
|
+ if (item.is_nature)
|
|
|
+ {
|
|
|
+ pEle->SetFixedHeight(84);
|
|
|
+ pNature->SetVisible(true);
|
|
|
+ pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pEle->SetFixedHeight(42);
|
|
|
+ pNature->SetVisible(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //鏇存柊鎬讳环鏄剧ず
|
|
|
+ CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_totalprice")));
|
|
|
+ pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(m_cur_diandan_order.getTotalPriceShow())).c_str());
|
|
|
}
|
|
|
|
|
|
void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
|
|
|
@@ -213,7 +234,24 @@ void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
|
|
|
pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
|
|
|
|
|
|
CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
|
|
|
- pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.price).c_str());
|
|
|
+ pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
|
|
|
+
|
|
|
+ CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
|
|
|
+ if (item.is_nature)
|
|
|
+ {
|
|
|
+ pEle->SetFixedHeight(84);
|
|
|
+ pNature->SetVisible(true);
|
|
|
+ pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pEle->SetFixedHeight(42);
|
|
|
+ pNature->SetVisible(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //鏇存柊鎬讳环鏄剧ず
|
|
|
+ CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_totalprice")));
|
|
|
+ pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(m_cur_diandan_order.getTotalPriceShow())).c_str());
|
|
|
}
|
|
|
|
|
|
void CDiandanPageUI::ClickFoodAction()
|
|
|
@@ -222,45 +260,69 @@ void CDiandanPageUI::ClickFoodAction()
|
|
|
|
|
|
if (is_taocan)
|
|
|
{
|
|
|
- //点击套餐之后的处理逻辑
|
|
|
+ //鐐瑰嚮濂楅�涔嬪悗鐨勫�鐞嗛€昏緫
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //点击普通商品之后的处理逻辑
|
|
|
+ //鐐瑰嚮鏅�€氬晢鍝佷箣鍚庣殑澶勭悊閫昏緫
|
|
|
CFood foodinfo = m_cur_click_food_item->GetFoodInfo();
|
|
|
|
|
|
- if (foodinfo.is_nature == "1")
|
|
|
- {
|
|
|
- //商品有商品属性
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //商品没有商品属性
|
|
|
- CDiandanOrderItem clickItem;
|
|
|
+ CDiandanOrderItem clickItem;
|
|
|
|
|
|
- clickItem.food_id = foodinfo.id;
|
|
|
- clickItem.food_name = foodinfo.name;
|
|
|
- clickItem.type_id = foodinfo.type_id;
|
|
|
- clickItem.price = foodinfo.price;
|
|
|
- clickItem.is_dabao = "";
|
|
|
- clickItem.num = "1";
|
|
|
- clickItem.is_foodpackage = "0";
|
|
|
- clickItem.is_weight = "0";
|
|
|
+ clickItem.food_id = foodinfo.id;
|
|
|
+ clickItem.food_name = foodinfo.name;
|
|
|
+ clickItem.type_id = foodinfo.type_id;
|
|
|
+ clickItem.price = foodinfo.price;
|
|
|
+ clickItem.is_dabao = "";
|
|
|
+ clickItem.num = "1";
|
|
|
+ clickItem.is_foodpackage = "0";
|
|
|
+ clickItem.is_weight = "0";
|
|
|
|
|
|
- bool is_add_new = false;
|
|
|
+ if (foodinfo.is_nature == "1")
|
|
|
+ {
|
|
|
+ //商品有商品属性
|
|
|
+ clickItem.is_nature = true;
|
|
|
|
|
|
- int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
+ //先弹框进行选择属性
|
|
|
+ CDiandanNatureWnd* pNatureFrame = new CDiandanNatureWnd(1);
|
|
|
+ pNatureFrame->SetFooditemUI(m_cur_click_food_item);
|
|
|
|
|
|
- if (is_add_new)
|
|
|
+ if (pNatureFrame != NULL)
|
|
|
{
|
|
|
- //说明是新增了一项,要刷新一下购物车展示
|
|
|
- this->AddDiandanOrderItemShow(clickItem);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(index);
|
|
|
+ pNatureFrame->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
|
|
|
+ pNatureFrame->SetIcon(IDI_ICON_DUILIB);
|
|
|
+ pNatureFrame->CenterWindow();
|
|
|
+ UINT ret = pNatureFrame->ShowModal();
|
|
|
+
|
|
|
+ if (ret == IDOK)
|
|
|
+ {
|
|
|
+ //保存选择的属性
|
|
|
+ std::vector<FoodNatureSelectValue> natureSelectedArray = pNatureFrame->GetNatureSelectedArray();
|
|
|
+ clickItem.natureSelectedArray = natureSelectedArray;
|
|
|
+
|
|
|
+ delete pNatureFrame;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //商品没有商品属性
|
|
|
+ bool is_add_new = false;
|
|
|
+
|
|
|
+ int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
+
|
|
|
+ if (is_add_new)
|
|
|
+ {
|
|
|
+ //璇存槑鏄�柊澧炰簡涓€椤癸紝瑕佸埛鏂颁竴涓嬭喘鐗╄溅灞曠ず
|
|
|
+ this->AddDiandanOrderItemShow(index);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //没有新增,而是修改了一项
|
|
|
+ this->UpdateDiandanOrderItemShow(index);
|
|
|
+ }
|
|
|
}
|
|
|
}
|