|
|
@@ -48,13 +48,22 @@ void CDiandanPageUI::InitShow()
|
|
|
curTypeUI->Selected(true, false);
|
|
|
}
|
|
|
|
|
|
- this->RefreshFoodShow();
|
|
|
+ this->RefreshFoodlist();
|
|
|
}
|
|
|
|
|
|
//处理按钮点击类事件
|
|
|
void CDiandanPageUI::HandleClickMsg(TNotifyUI& msg)
|
|
|
{
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
|
|
|
+ if (name == L"diandan_fooditem")
|
|
|
+ {
|
|
|
+ CDiandanFoodItemUI* fooditemUI = static_cast<CDiandanFoodItemUI*>(msg.pSender);
|
|
|
+
|
|
|
+ m_cur_click_food_item = fooditemUI;
|
|
|
+
|
|
|
+ this->ClickFoodAction();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//处理option切换事件
|
|
|
@@ -72,7 +81,7 @@ void CDiandanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
|
|
|
m_cur_type_id = id;
|
|
|
|
|
|
- this->RefreshFoodShow();
|
|
|
+ this->RefreshFoodlist();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -93,7 +102,7 @@ void CDiandanPageUI::InitFoodtypeShow()
|
|
|
CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
|
|
|
pItem->SetName(L"商品套餐");
|
|
|
- pItem->SetTypeId("0");
|
|
|
+ pItem->SetTypeId("taocan");
|
|
|
pItem->SetTaocan();
|
|
|
pItem->SetGroup(L"diandan_foodtype");
|
|
|
|
|
|
@@ -118,11 +127,11 @@ void CDiandanPageUI::InitFoodtypeShow()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CDiandanPageUI::RefreshFoodShow()
|
|
|
+void CDiandanPageUI::RefreshFoodlist()
|
|
|
{
|
|
|
m_foodLayout->RemoveAll();
|
|
|
|
|
|
- //如果当前一个分类都没有,那么就处理了
|
|
|
+ //如果当前一个分类都没有,那么就不处理了
|
|
|
if (m_cur_type_id == "")
|
|
|
{
|
|
|
return;
|
|
|
@@ -130,6 +139,23 @@ void CDiandanPageUI::RefreshFoodShow()
|
|
|
else if (m_cur_type_id == "taocan")
|
|
|
{
|
|
|
//选择的是套餐分类
|
|
|
+ CSqlite3 sqlite;
|
|
|
+ std::vector<CFoodpackage> foodlist = sqlite.GetFoodpackages(true);
|
|
|
+
|
|
|
+ for (std::vector<CFoodpackage>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
+ {
|
|
|
+ CFoodpackage food = *it;
|
|
|
+
|
|
|
+ CDialogBuilder builder;
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
+
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(_T("diandan_fooditem.xml"), (UINT)0, &cb, m_pManager));
|
|
|
+
|
|
|
+ pItem->SetFoodpackageInfo(food);
|
|
|
+ pItem->UpdateShow();
|
|
|
+
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -152,3 +178,89 @@ void CDiandanPageUI::RefreshFoodShow()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+void CDiandanPageUI::AddDiandanOrderItemShow(CDiandanOrderItem item)
|
|
|
+{
|
|
|
+ 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));
|
|
|
+
|
|
|
+ CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
+ pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
|
|
|
+
|
|
|
+ CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
|
|
|
+ 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());
|
|
|
+
|
|
|
+ pList->Add(pEle);
|
|
|
+}
|
|
|
+
|
|
|
+void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
|
|
|
+{
|
|
|
+ CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(index);
|
|
|
+
|
|
|
+ CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_diandan_cart")));
|
|
|
+
|
|
|
+ CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(pList->GetItemAt(index));
|
|
|
+
|
|
|
+ CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
+ pName->SetText(CLewaimaiString::UTF8ToUnicode(item.food_name).c_str());
|
|
|
+
|
|
|
+ CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
|
|
|
+ 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());
|
|
|
+}
|
|
|
+
|
|
|
+void CDiandanPageUI::ClickFoodAction()
|
|
|
+{
|
|
|
+ bool is_taocan = m_cur_click_food_item->GetIsTaocan();
|
|
|
+
|
|
|
+ if (is_taocan)
|
|
|
+ {
|
|
|
+ //点击套餐之后的处理逻辑
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //点击普通商品之后的处理逻辑
|
|
|
+ CFood foodinfo = m_cur_click_food_item->GetFoodInfo();
|
|
|
+
|
|
|
+ if (foodinfo.is_nature == "1")
|
|
|
+ {
|
|
|
+ //商品有商品属性
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //商品没有商品属性
|
|
|
+ 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";
|
|
|
+
|
|
|
+ bool is_add_new = false;
|
|
|
+
|
|
|
+ int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
+
|
|
|
+ if (is_add_new)
|
|
|
+ {
|
|
|
+ //说明是新增了一项,要刷新一下购物车展示
|
|
|
+ this->AddDiandanOrderItemShow(clickItem);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //没有新增,而是修改了一项
|
|
|
+ this->UpdateDiandanOrderItemShow(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|