|
|
@@ -73,14 +73,11 @@ void CDiandanPageUI::RefreshShow()
|
|
|
//初始化商品显示(因为这里要刷新商品库存状态)
|
|
|
this->InitFoodShow();
|
|
|
|
|
|
- //清空购物车
|
|
|
- this->ClearDiandanOrderItemShow();
|
|
|
-
|
|
|
//初始化结算页面相关的展示,把所有活动清零
|
|
|
this->InitJiesuanShow();
|
|
|
|
|
|
- //计算所有活动优惠,并且调整所有与价格相关的展示
|
|
|
- this->UpdateJiesuanInfo();
|
|
|
+ //渲染左侧购物车(包含了调用UpdateJiesuanInfo重新计算价格)
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
//展示选购页面
|
|
|
this->ShowXuangouPage();
|
|
|
@@ -1006,110 +1003,78 @@ void CDiandanPageUI::HandleTextCapture(std::string content)
|
|
|
this->StartWeixinzhifuShoukuan(content);
|
|
|
}
|
|
|
|
|
|
-void CDiandanPageUI::AddDiandanOrderItemShow(int index)
|
|
|
+void CDiandanPageUI::UpdateShopcartShow()
|
|
|
{
|
|
|
- CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(index);
|
|
|
-
|
|
|
+ //先保留选中
|
|
|
CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_diandan_cart")));
|
|
|
+ int nIndex = pList->GetCurSel();
|
|
|
|
|
|
- CDialogBuilder builder;
|
|
|
- CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("diandan_cart_item.xml"), (UINT)0, NULL, m_pManager));
|
|
|
-
|
|
|
- pList->Add(pEle);
|
|
|
+ //先清空
|
|
|
+ pList->RemoveAll();
|
|
|
|
|
|
- if (item.m_is_taocan)
|
|
|
+ int nItemNum = m_cur_diandan_order.getItemNum();
|
|
|
+ for (int i = 0; i < nItemNum; i++)
|
|
|
{
|
|
|
- CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
- pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).c_str());
|
|
|
+ CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(i);
|
|
|
|
|
|
- CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
|
|
|
- pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
|
|
|
+ CDialogBuilder builder;
|
|
|
+ CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("diandan_cart_item.xml"), (UINT)0, NULL, m_pManager));
|
|
|
|
|
|
- CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
|
|
|
- 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.m_is_taocan)
|
|
|
+ {
|
|
|
+ CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
+ pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).c_str());
|
|
|
|
|
|
- pEle->SetFixedHeight(84);
|
|
|
- pNature->SetVisible(true);
|
|
|
- pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
- pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).c_str());
|
|
|
+ CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
|
|
|
+ pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).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.show_price).c_str());
|
|
|
|
|
|
- CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
|
|
|
- pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
|
|
|
+ CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //更新结算信息
|
|
|
- UpdateJiesuanInfo();
|
|
|
-}
|
|
|
+ CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
+ pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).c_str());
|
|
|
|
|
|
-void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
|
|
|
-{
|
|
|
- CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(index);
|
|
|
-
|
|
|
- CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_diandan_cart")));
|
|
|
+ CLabelUI* pNum = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_num")));
|
|
|
+ pNum->SetText(CLewaimaiString::UTF8ToUnicode(item.num).c_str());
|
|
|
|
|
|
- CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(pList->GetItemAt(index));
|
|
|
+ CLabelUI* pPrice = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_price")));
|
|
|
+ pPrice->SetText(CLewaimaiString::UTF8ToUnicode(item.show_price).c_str());
|
|
|
|
|
|
- if (item.m_is_taocan)
|
|
|
- {
|
|
|
- CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
- pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).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.show_price).c_str());
|
|
|
-
|
|
|
- CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
|
|
|
-
|
|
|
- pEle->SetFixedHeight(84);
|
|
|
- pNature->SetVisible(true);
|
|
|
- pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_name")));
|
|
|
- pName->SetText(CLewaimaiString::UTF8ToUnicode(item.getNameShow()).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.show_price).c_str());
|
|
|
-
|
|
|
- CLabelUI* pNature = static_cast<CLabelUI*>(pEle->FindSubControl(_T("diandan_cart_item_nature")));
|
|
|
- if (item.is_nature)
|
|
|
+ //保留选中
|
|
|
+ if (nIndex != -1 && pList->GetCount() > 0)
|
|
|
+ {
|
|
|
+ if (nIndex <= pList->GetCount() - 1)
|
|
|
{
|
|
|
- pEle->SetFixedHeight(84);
|
|
|
- pNature->SetVisible(true);
|
|
|
- pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
|
|
|
+ pList->SelectItem(nIndex, false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- pEle->SetFixedHeight(42);
|
|
|
- pNature->SetVisible(false);
|
|
|
+ pList->SelectItem(pList->GetCount() - 1, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1117,26 +1082,6 @@ void CDiandanPageUI::UpdateDiandanOrderItemShow(int index)
|
|
|
UpdateJiesuanInfo();
|
|
|
}
|
|
|
|
|
|
-void CDiandanPageUI::DelDiandanOrderItemShow(int index)
|
|
|
-{
|
|
|
- CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_diandan_cart")));
|
|
|
-
|
|
|
- pList->RemoveAt(index);
|
|
|
-
|
|
|
- //更新结算信息
|
|
|
- UpdateJiesuanInfo();
|
|
|
-}
|
|
|
-
|
|
|
-void CDiandanPageUI::ClearDiandanOrderItemShow()
|
|
|
-{
|
|
|
- CListUI* pList = static_cast<CListUI*>(this->FindSubControl(_T("list_diandan_cart")));
|
|
|
-
|
|
|
- pList->RemoveAll();
|
|
|
-
|
|
|
- //更新结算信息
|
|
|
- UpdateJiesuanInfo();
|
|
|
-}
|
|
|
-
|
|
|
void CDiandanPageUI::UpdateJiesuanInfo()
|
|
|
{
|
|
|
//先按所有的价格公式规则,计算一次价格
|
|
|
@@ -1753,16 +1698,7 @@ void CDiandanPageUI::ClickFoodAction()
|
|
|
|
|
|
int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
|
|
|
- if (is_add_new)
|
|
|
- {
|
|
|
- //说明是新增了一项,要刷新一下购物车展示
|
|
|
- this->AddDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
+ this->UpdateShopcartShow();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -1927,16 +1863,7 @@ void CDiandanPageUI::ClickFoodAction()
|
|
|
|
|
|
int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
|
|
|
- if (is_add_new)
|
|
|
- {
|
|
|
- //说明是新增了一项,要刷新一下购物车展示
|
|
|
- this->AddDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
+ this->UpdateShopcartShow();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1953,8 +1880,7 @@ void CDiandanPageUI::ClickAdd()
|
|
|
|
|
|
m_cur_diandan_order.AddNum(nIndex);
|
|
|
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(nIndex);
|
|
|
+ this->UpdateShopcartShow();
|
|
|
}
|
|
|
|
|
|
void CDiandanPageUI::ClickDel()
|
|
|
@@ -1969,15 +1895,7 @@ void CDiandanPageUI::ClickDel()
|
|
|
|
|
|
bool is_del = m_cur_diandan_order.DelNum(nIndex);
|
|
|
|
|
|
- //如果是删掉了,那么就刷新显示
|
|
|
- if (is_del)
|
|
|
- {
|
|
|
- this->DelDiandanOrderItemShow(nIndex);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this->UpdateDiandanOrderItemShow(nIndex);
|
|
|
- }
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
if (m_cur_diandan_order.getItemNum() == 0)
|
|
|
{
|
|
|
@@ -1997,7 +1915,7 @@ void CDiandanPageUI::ClickRemove()
|
|
|
|
|
|
m_cur_diandan_order.Remove(nIndex);
|
|
|
|
|
|
- this->DelDiandanOrderItemShow(nIndex);
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
if (m_cur_diandan_order.getItemNum() == 0)
|
|
|
{
|
|
|
@@ -2046,8 +1964,7 @@ void CDiandanPageUI::ClickGuige()
|
|
|
m_is_show_modal_wnd = false;
|
|
|
delete pNatureFrame;
|
|
|
|
|
|
- //然后要刷新这个item的显示
|
|
|
- this->UpdateDiandanOrderItemShow(nIndex);
|
|
|
+ this->UpdateShopcartShow();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2086,8 +2003,7 @@ void CDiandanPageUI::ClickGuige()
|
|
|
|
|
|
delete pNatureFrame;
|
|
|
|
|
|
- //然后要刷新这个item的显示
|
|
|
- this->UpdateDiandanOrderItemShow(nIndex);
|
|
|
+ this->UpdateShopcartShow();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2110,15 +2026,14 @@ void CDiandanPageUI::ClickDabao()
|
|
|
|
|
|
m_cur_diandan_order.SetDabao(nIndex);
|
|
|
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(nIndex);
|
|
|
+ this->UpdateShopcartShow();
|
|
|
}
|
|
|
|
|
|
void CDiandanPageUI::ClickQingkong()
|
|
|
{
|
|
|
m_cur_diandan_order.Clear();
|
|
|
|
|
|
- this->ClearDiandanOrderItemShow();
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
ShowXuangouPage();
|
|
|
}
|
|
|
@@ -2186,10 +2101,7 @@ void CDiandanPageUI::ClickQudan()
|
|
|
RefreshGuadanNum();
|
|
|
|
|
|
//然后展示购物车
|
|
|
- for (int i = 0; i < m_cur_diandan_order.getItemNum(); i++)
|
|
|
- {
|
|
|
- this->AddDiandanOrderItemShow(i);
|
|
|
- }
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
m_is_show_modal_wnd = false;
|
|
|
delete pQudanDlg;
|
|
|
@@ -3309,16 +3221,7 @@ bool CDiandanPageUI::SaomiaoBarcode(std::string barcode)
|
|
|
|
|
|
int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
|
|
|
- if (is_add_new)
|
|
|
- {
|
|
|
- //说明是新增了一项,要刷新一下购物车展示
|
|
|
- this->AddDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -3587,16 +3490,7 @@ bool CDiandanPageUI::BiaoqianchengSaomaBarcode(std::string barcode)
|
|
|
|
|
|
int index = m_cur_diandan_order.AddItem(clickItem, is_add_new);
|
|
|
|
|
|
- if (is_add_new)
|
|
|
- {
|
|
|
- //说明是新增了一项,要刷新一下购物车展示
|
|
|
- this->AddDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //没有新增,而是修改了一项
|
|
|
- this->UpdateDiandanOrderItemShow(index);
|
|
|
- }
|
|
|
+ this->UpdateShopcartShow();
|
|
|
|
|
|
return true;
|
|
|
}
|