|
|
@@ -34,12 +34,27 @@ CDiandanPageUI::~CDiandanPageUI()
|
|
|
//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
void CDiandanPageUI::InitShow()
|
|
|
{
|
|
|
- //根据店铺设置,初始化结算信息
|
|
|
- this->InitJiesuanInfo();
|
|
|
+ //先初始化商品分类
|
|
|
+ this->InitFoodtypeShow();
|
|
|
+
|
|
|
+ //再初始化商品显示
|
|
|
+ this->InitFoodShow();
|
|
|
+
|
|
|
+ //初始化结算页面相关的展示
|
|
|
+ this->InitJiesuanShow();
|
|
|
+
|
|
|
+ //调整所有与价格相关的展示
|
|
|
+ this->UpdateJiesuanInfo();
|
|
|
|
|
|
+ //默认展示选购页面
|
|
|
+ this->ShowXuangouPage();
|
|
|
+}
|
|
|
+
|
|
|
+void CDiandanPageUI::InitFoodtypeShow()
|
|
|
+{
|
|
|
//初始化商品渲染相关的信息
|
|
|
- m_foodLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("diandan_foodlist")));
|
|
|
m_foodtypeLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_fenlei_layout")));
|
|
|
+ m_foodtypeLayout->RemoveAll();
|
|
|
|
|
|
CSqlite3 sqlite;
|
|
|
m_nFoodpackageNum = sqlite.GetFoodpackageNum();
|
|
|
@@ -58,8 +73,38 @@ void CDiandanPageUI::InitShow()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //先初始化商品分类
|
|
|
- this->InitFoodtypeShow();
|
|
|
+ //先判断有没有套餐分类
|
|
|
+ if (m_nFoodpackageNum > 0)
|
|
|
+ {
|
|
|
+ CDialogBuilder builder;
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
+
|
|
|
+ CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
+
|
|
|
+ pItem->SetName(L"商品套餐");
|
|
|
+ pItem->SetTypeId("taocan");
|
|
|
+ pItem->SetTaocan();
|
|
|
+ pItem->SetGroup(L"diandan_foodtype");
|
|
|
+
|
|
|
+ m_foodtypeLayout->Add(pItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ //接下来开始处理商品分类
|
|
|
+ for (std::vector<CFoodType>::iterator it = m_types.begin(); it != m_types.end(); it++)
|
|
|
+ {
|
|
|
+ CFoodType type = *it;
|
|
|
+
|
|
|
+ CDialogBuilder builder;
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
+
|
|
|
+ CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
+
|
|
|
+ pItem->SetName(CLewaimaiString::UTF8ToUnicode(type.name));
|
|
|
+ pItem->SetTypeId(type.id);
|
|
|
+ pItem->SetGroup(L"diandan_foodtype");
|
|
|
+
|
|
|
+ m_foodtypeLayout->Add(pItem);
|
|
|
+ }
|
|
|
|
|
|
//如果不是一个分类都没有,选中第一个分类
|
|
|
if (m_cur_type_id != "")
|
|
|
@@ -68,18 +113,68 @@ void CDiandanPageUI::InitShow()
|
|
|
|
|
|
curTypeUI->Selected(true, false);
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+void CDiandanPageUI::InitFoodShow()
|
|
|
+{
|
|
|
+ m_foodLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("diandan_foodlist")));
|
|
|
+ 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);
|
|
|
+
|
|
|
+ for (std::vector<CFoodpackage>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
+ {
|
|
|
+ CFoodpackage food = *it;
|
|
|
+
|
|
|
+ CDialogBuilder builder;
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
|
|
|
- this->RefreshFoodlist();
|
|
|
+ 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
|
|
|
+ {
|
|
|
+ CSqlite3 sqlite;
|
|
|
+ std::vector<CFood> foodlist = sqlite.GetFoodByTypeid(m_cur_type_id);
|
|
|
+
|
|
|
+ for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
+ {
|
|
|
+ CFood food = *it;
|
|
|
+
|
|
|
+ CDialogBuilder builder;
|
|
|
+ CDialogBuilderCallbackEx cb;
|
|
|
+
|
|
|
+ CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(_T("diandan_fooditem.xml"), (UINT)0, &cb, m_pManager));
|
|
|
+
|
|
|
+ pItem->SetFoodInfo(food);
|
|
|
+ pItem->UpdateShow();
|
|
|
+
|
|
|
+ m_foodLayout->Add(pItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-//初始化结算页面的信息
|
|
|
-void CDiandanPageUI::InitJiesuanInfo()
|
|
|
+//仅仅初始化结算相关的显示(比如折扣、优惠、价格等)
|
|
|
+void CDiandanPageUI::InitJiesuanShow()
|
|
|
{
|
|
|
CShopinfo shopinfo = CShopinfo::m_shopinfo;
|
|
|
|
|
|
//清空购物车
|
|
|
m_cur_diandan_order.Clear();
|
|
|
-
|
|
|
this->ClearDiandanOrderItemShow();
|
|
|
|
|
|
//先清空会员登录状态
|
|
|
@@ -139,9 +234,6 @@ void CDiandanPageUI::InitJiesuanInfo()
|
|
|
CCheckBoxUI* pMolingCheck = static_cast<CCheckBoxUI*>(this->FindSubControl(_T("diandan_jiesuan_moling_bumoling")));
|
|
|
pMolingCheck->Selected(true, false);
|
|
|
|
|
|
- //调整所有与价格相关的展示
|
|
|
- UpdateJiesuanInfo();
|
|
|
-
|
|
|
//添加支付方式
|
|
|
CHorizontalLayoutUI* pZhifufangshiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_jiesuan_zhifufangshi_layout")));
|
|
|
|
|
|
@@ -165,7 +257,7 @@ void CDiandanPageUI::InitJiesuanInfo()
|
|
|
pWeixinLayout->SetFloat(true);
|
|
|
pWeixinLayout->SetPos(rect);
|
|
|
|
|
|
- num++;
|
|
|
+ num++;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -338,11 +430,48 @@ void CDiandanPageUI::InitJiesuanInfo()
|
|
|
}
|
|
|
|
|
|
//调整区域高度
|
|
|
- int lastRow = (num - 1) / 3 + 1;
|
|
|
+ int lastRow = (num - 1) / 3 + 1;
|
|
|
pZhifufangshiLayout->SetFixedHeight(lastRow * 105);
|
|
|
+}
|
|
|
|
|
|
- //默认展示选购页面
|
|
|
- ShowXuangouPage();
|
|
|
+//展示结算页面,隐藏选购页面
|
|
|
+void CDiandanPageUI::ShowJiesuanPage()
|
|
|
+{
|
|
|
+ //先隐藏商品页面
|
|
|
+ CVerticalLayoutUI* pFoodLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_food_layout")));
|
|
|
+ pFoodLayout->SetVisible(false);
|
|
|
+
|
|
|
+ //隐藏结算按钮
|
|
|
+ CHorizontalLayoutUI* pPayLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_pay_layout")));
|
|
|
+ pPayLayout->SetVisible(false);
|
|
|
+
|
|
|
+ //再展示结算页面
|
|
|
+ CHorizontalLayoutUI* pJiesuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_jiesuan_layout")));
|
|
|
+ pJiesuanLayout->SetVisible(true);
|
|
|
+
|
|
|
+ //展示继续加菜的按钮
|
|
|
+ CButtonUI* pJiacaiBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_diandan_jixujiacai")));
|
|
|
+ pJiacaiBtn->SetVisible(true);
|
|
|
+}
|
|
|
+
|
|
|
+//展示选购页面,隐藏结算页面
|
|
|
+void CDiandanPageUI::ShowXuangouPage()
|
|
|
+{
|
|
|
+ //先展示商品页面
|
|
|
+ CVerticalLayoutUI* pFoodLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_food_layout")));
|
|
|
+ pFoodLayout->SetVisible(true);
|
|
|
+
|
|
|
+ //展示结算按钮
|
|
|
+ CHorizontalLayoutUI* pPayLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_pay_layout")));
|
|
|
+ pPayLayout->SetVisible(true);
|
|
|
+
|
|
|
+ //再隐藏结算页面
|
|
|
+ CHorizontalLayoutUI* pJiesuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_jiesuan_layout")));
|
|
|
+ pJiesuanLayout->SetVisible(false);
|
|
|
+
|
|
|
+ //隐藏继续加菜的按钮
|
|
|
+ CButtonUI* pJiacaiBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_diandan_jixujiacai")));
|
|
|
+ pJiacaiBtn->SetVisible(false);
|
|
|
}
|
|
|
|
|
|
//处理按钮点击类事件
|
|
|
@@ -485,7 +614,7 @@ void CDiandanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
|
|
|
m_cur_type_id = id;
|
|
|
|
|
|
- this->RefreshFoodlist();
|
|
|
+ this->InitFoodShow();
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
@@ -526,94 +655,6 @@ void CDiandanPageUI::HandleTextChangedMsg(TNotifyUI& msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
-void CDiandanPageUI::InitFoodtypeShow()
|
|
|
-{
|
|
|
- //先判断有没有套餐分类
|
|
|
- if (m_nFoodpackageNum > 0)
|
|
|
- {
|
|
|
- CDialogBuilder builder;
|
|
|
- CDialogBuilderCallbackEx cb;
|
|
|
-
|
|
|
- CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
-
|
|
|
- pItem->SetName(L"商品套餐");
|
|
|
- pItem->SetTypeId("taocan");
|
|
|
- pItem->SetTaocan();
|
|
|
- pItem->SetGroup(L"diandan_foodtype");
|
|
|
-
|
|
|
- m_foodtypeLayout->Add(pItem);
|
|
|
- }
|
|
|
-
|
|
|
- //接下来开始处理商品分类
|
|
|
- for (std::vector<CFoodType>::iterator it = m_types.begin(); it != m_types.end(); it++)
|
|
|
- {
|
|
|
- CFoodType type = *it;
|
|
|
-
|
|
|
- CDialogBuilder builder;
|
|
|
- CDialogBuilderCallbackEx cb;
|
|
|
-
|
|
|
- CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("foodtype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
-
|
|
|
- pItem->SetName(CLewaimaiString::UTF8ToUnicode(type.name));
|
|
|
- pItem->SetTypeId(type.id);
|
|
|
- pItem->SetGroup(L"diandan_foodtype");
|
|
|
-
|
|
|
- m_foodtypeLayout->Add(pItem);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-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);
|
|
|
-
|
|
|
- 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
|
|
|
- {
|
|
|
- CSqlite3 sqlite;
|
|
|
- std::vector<CFood> foodlist = sqlite.GetFoodByTypeid(m_cur_type_id);
|
|
|
-
|
|
|
- for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
|
|
|
- {
|
|
|
- CFood food = *it;
|
|
|
-
|
|
|
- CDialogBuilder builder;
|
|
|
- CDialogBuilderCallbackEx cb;
|
|
|
-
|
|
|
- CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(_T("diandan_fooditem.xml"), (UINT)0, &cb, m_pManager));
|
|
|
-
|
|
|
- pItem->SetFoodInfo(food);
|
|
|
- pItem->UpdateShow();
|
|
|
-
|
|
|
- m_foodLayout->Add(pItem);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void CDiandanPageUI::AddDiandanOrderItemShow(int index)
|
|
|
{
|
|
|
CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(index);
|
|
|
@@ -1297,46 +1338,6 @@ void CDiandanPageUI::UpdateJiesuanInfo()
|
|
|
pYingshou->SetText((L"应收金额:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(cur_price, 2)) + L"元").c_str());
|
|
|
}
|
|
|
|
|
|
-//展示结算页面,隐藏选购页面
|
|
|
-void CDiandanPageUI::ShowJiesuanPage()
|
|
|
-{
|
|
|
- //先隐藏商品页面
|
|
|
- CVerticalLayoutUI* pFoodLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_food_layout")));
|
|
|
- pFoodLayout->SetVisible(false);
|
|
|
-
|
|
|
- //隐藏结算按钮
|
|
|
- CHorizontalLayoutUI* pPayLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_pay_layout")));
|
|
|
- pPayLayout->SetVisible(false);
|
|
|
-
|
|
|
- //再展示结算页面
|
|
|
- CHorizontalLayoutUI* pJiesuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_jiesuan_layout")));
|
|
|
- pJiesuanLayout->SetVisible(true);
|
|
|
-
|
|
|
- //展示继续加菜的按钮
|
|
|
- CButtonUI* pJiacaiBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_diandan_jixujiacai")));
|
|
|
- pJiacaiBtn->SetVisible(true);
|
|
|
-}
|
|
|
-
|
|
|
-//展示选购页面,隐藏结算页面
|
|
|
-void CDiandanPageUI::ShowXuangouPage()
|
|
|
-{
|
|
|
- //先展示商品页面
|
|
|
- CVerticalLayoutUI* pFoodLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("diandan_food_layout")));
|
|
|
- pFoodLayout->SetVisible(true);
|
|
|
-
|
|
|
- //展示结算按钮
|
|
|
- CHorizontalLayoutUI* pPayLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_pay_layout")));
|
|
|
- pPayLayout->SetVisible(true);
|
|
|
-
|
|
|
- //再隐藏结算页面
|
|
|
- CHorizontalLayoutUI* pJiesuanLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_jiesuan_layout")));
|
|
|
- pJiesuanLayout->SetVisible(false);
|
|
|
-
|
|
|
- //隐藏继续加菜的按钮
|
|
|
- CButtonUI* pJiacaiBtn = static_cast<CButtonUI*>(this->FindSubControl(_T("btn_diandan_jixujiacai")));
|
|
|
- pJiacaiBtn->SetVisible(false);
|
|
|
-}
|
|
|
-
|
|
|
void CDiandanPageUI::ClickFoodAction()
|
|
|
{
|
|
|
bool is_taocan = m_cur_click_food_item->GetIsTaocan();
|
|
|
@@ -2153,7 +2154,7 @@ void CDiandanPageUI::StartWeixinzhifuShoukuan()
|
|
|
//说明收款成功了,需要进行一些后续的处理
|
|
|
|
|
|
//初始化页面信息
|
|
|
- InitJiesuanInfo();
|
|
|
+ InitShow();
|
|
|
|
|
|
//处理打印
|
|
|
|
|
|
@@ -2206,7 +2207,7 @@ void CDiandanPageUI::StartHuiyuanShoukuan()
|
|
|
//说明收款成功了,需要进行一些后续的处理
|
|
|
|
|
|
//初始化页面信息
|
|
|
- InitJiesuanInfo();
|
|
|
+ InitShow();
|
|
|
|
|
|
//处理打印
|
|
|
|
|
|
@@ -2379,7 +2380,7 @@ void CDiandanPageUI::StartXianjinShoukuan()
|
|
|
//说明收款成功了,需要进行一些后续的处理
|
|
|
|
|
|
//初始化页面信息
|
|
|
- InitJiesuanInfo();
|
|
|
+ InitShow();
|
|
|
|
|
|
//处理打印
|
|
|
|
|
|
@@ -2432,7 +2433,7 @@ void CDiandanPageUI::StartFulikaShoukuan()
|
|
|
//说明收款成功了,需要进行一些后续的处理
|
|
|
|
|
|
//初始化页面信息
|
|
|
- InitJiesuanInfo();
|
|
|
+ InitShow();
|
|
|
|
|
|
//处理打印
|
|
|
|