Переглянути джерело

副屏的代码逻辑写完了

张洋 3 роки тому
батько
коміт
d4a55afe58

+ 2 - 2
bin/Win32/Debug/zhipuzi_pos_windows/skin/diandan_page.xml

@@ -31,7 +31,7 @@
 						</List>
 						
 						<HorizontalLayout name="diandan_page_youhui_tishi_layout" height="40" bkcolor="#FFFBEEEE" visible="false">
-							<Label name="diandan_page_youhui_tishi" text="已优惠10元" textcolor="#FFFF3838" padding="25,0,0,0" width="270" hegiht="40"></Label>
+							<Label name="diandan_page_youhui_tishi" text="已优惠10元" textcolor="#FFFF3838" padding="15,0,0,0" width="270" hegiht="40"></Label>
 							<Button name="btn_diandan_chakanyouhui" text="查看优惠>" heiht="30" width="80" padding="5,0,25,0" textcolor="#FF3CB371" normalimage="" hotimage="" pushedimage="" bordersize="0" bkcolor="#00FFFFFF"></Button>
 						</HorizontalLayout>
 					</VerticalLayout>
@@ -61,7 +61,7 @@
 				
 				<VerticalLayout height="165" bkcolor="#FFFFFFFF">
 					<HorizontalLayout height="70">
-						<Label name="diandan_page_otherprice" text="" width="260" align="left" padding="15,10,0,0"></Label>
+						<Label name="diandan_page_otherprice" text="" width="260" align="left" padding="15,8,0,0"></Label>
 						<Label name="diandan_page_totalprice" text="总价:¥0.00" font="22" textcolor="#FFFF0000" width="200" align="right" padding="0,0,15,0"></Label>
 					</HorizontalLayout>
 					

+ 24 - 9
bin/Win32/Debug/zhipuzi_pos_windows/skin/fuping_wnd.xml

@@ -1,14 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Window>
 	<Font id="0" name="微软雅黑" size="22" />
-	<Font id="1" name="微软雅黑" size="32" />
+	<Font id="1" name="微软雅黑" size="36" />
+	<Font id="24" name="微软雅黑" size="24" />
 	
 	<VerticalLayout bkimage="shoukuan_bkg.png" >		
 		<HorizontalLayout>
-			<VerticalLayout width="400">
-				<HorizontalLayout height="80">
-					<Label text="欢迎光临" font="1" align="center"></Label>
-				</HorizontalLayout>				
+			<VerticalLayout width="380">
+				<HorizontalLayout height="50">
+					<Label text="欢迎光临" font="1" align="center" textcolor="#FFFF8910"></Label>
+				</HorizontalLayout>
+
+				<HorizontalLayout height="48">
+					<Label name="shopname" text="" font="0" align="center"></Label>
+				</HorizontalLayout>
+				
+				<Control height="1" bkcolor="#FFEBE8E8"></Control>
 				
 				<List name="list_diandan_cart" padding="0,10,0,0" itemlinecolor="#FF000000" vscrollbar="true">
 					<ListHeader inset="10,0,0,0"/>
@@ -17,10 +24,17 @@
 					<ListHeaderItem text="金额" width="80" align="center" />
 				</List>
 				
+				<HorizontalLayout name="diandan_page_youhui_tishi_layout" height="40" bkcolor="#FFFBEEEE" visible="false">
+					<Label name="diandan_page_youhui_tishi" text="已优惠10元" textcolor="#FFFF3838" padding="15,0,0,0" width="270" hegiht="40"></Label>
+				</HorizontalLayout>
+				
 				<Control height="1" bkcolor="#FFEBE8E8"></Control>
 				
-				<VerticalLayout height="200">
-					<Label text="应付:0元" font="0" align="right"></Label>
+				<VerticalLayout height="90">
+					<HorizontalLayout height="70">
+						<Label name="diandan_page_otherprice" text="" width="160" align="left" padding="15,0,0,0"></Label>
+						<Label name="diandan_page_totalprice" text="总价:¥0.00" font="24" textcolor="#FFFF0000" width="190" align="right" padding="0,0,15,0"></Label>
+					</HorizontalLayout>
 				</VerticalLayout>
 			</VerticalLayout>
 			
@@ -33,9 +47,10 @@
 			</VerticalLayout>
 		</HorizontalLayout>
 		
-		<HorizontalLayout name="shoukuan_title_bkg" height="52" bkcolor="0xFF3CB371">
+		<HorizontalLayout name="shoukuan_title_bkg" height="36" bkcolor="0xFF3CB371">
 			<Control></Control>
-			<Control bkimage="main_logo.png" width="179" height="46" padding="0,3,0,3"></Control>
+			<Control bkimage="logo_small.png" width="38" height="23" padding="0,6,15,6"></Control>
+			<Label text="智铺子收银系统 www.zhipuzi.com" width="280" textcolor="#FFFFFFFF"></Label>
 			<Control></Control>
 		</HorizontalLayout>	
 	</VerticalLayout>

BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/logo_small.png


+ 19 - 19
zhipuzi_pos_windows/page/CDiandanPageUI.cpp

@@ -1148,7 +1148,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 	//这个是临时变量,表示每次优惠过后的实时价格
 	double cur_price = jichu_price;
 
-	double totol_youhui = 0;
+	double total_youhui = 0;
 
 	//判断是否有商品券,如果有的话把金额抵扣掉
 	m_shangpinquan_youhui = 0;
@@ -1157,7 +1157,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 		//判断当前购物车商品,是否有满足对应商品券使用要求的
 		bool ret = m_cur_diandan_order.UseShangpinquan(m_shangpinquan_foodid, m_shangpinquan_youhui);
 
-		totol_youhui += m_shangpinquan_youhui;
+		total_youhui += m_shangpinquan_youhui;
 	}
 
 	//判断次卡
@@ -1190,7 +1190,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 			}
 		}
 
-		totol_youhui += m_cika_youhui;
+		total_youhui += m_cika_youhui;
 	}
 
 	//判断会员商品优惠
@@ -1200,9 +1200,9 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 	{
 		m_total_member_youhui = m_cur_diandan_order.getTotalMemberYouhui(m_member_level);
 	}
-	totol_youhui += m_total_member_youhui;
+	total_youhui += m_total_member_youhui;
 
-	cur_price = jichu_price - totol_youhui;
+	cur_price = jichu_price - total_youhui;
 
 	//再判断整单折扣
 	CEditUI* pZhekouEdit = static_cast<CEditUI*>(this->FindSubControl(_T("diandan_jiesuan_zhekou_value")));
@@ -1218,7 +1218,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 	else
 	{
 		m_zhekou_youhui = (100 - zhekouValue) * cur_price / 100.00;
-		totol_youhui += m_zhekou_youhui;
+		total_youhui += m_zhekou_youhui;
 
 		cur_price = cur_price - m_zhekou_youhui;
 	}
@@ -1246,7 +1246,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 				else
 				{
 					m_member_zhekou_youhui = (10 - member_discount) * cur_price / 10.00;
-					totol_youhui += m_member_zhekou_youhui;
+					total_youhui += m_member_zhekou_youhui;
 
 					cur_price -= m_member_zhekou_youhui;
 				}				
@@ -1269,7 +1269,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 		else
 		{
 			m_quanyika_youhui = (10 - quanyika_zhekou) * cur_price / 10.00;
-			totol_youhui += m_quanyika_youhui;
+			total_youhui += m_quanyika_youhui;
 
 			cur_price -= m_quanyika_youhui;
 		}
@@ -1289,7 +1289,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 			else
 			{
 				m_cika_youhui = (10 - cika_zhekou) * cur_price / 10.00;
-				totol_youhui += m_cika_youhui;
+				total_youhui += m_cika_youhui;
 
 				cur_price -= m_cika_youhui;
 			}
@@ -1313,7 +1313,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 			{
 				m_manjian_youhui = cur.discount;
 
-				totol_youhui += m_manjian_youhui;
+				total_youhui += m_manjian_youhui;
 
 				cur_price -= m_manjian_youhui;
 
@@ -1337,7 +1337,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 			{
 				m_cika_youhui = value;
 
-				totol_youhui += m_cika_youhui;
+				total_youhui += m_cika_youhui;
 
 				cur_price -= m_cika_youhui;
 			}
@@ -1357,7 +1357,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 			{
 				m_youhuiquan_youhui = atof(m_coupon_value.c_str());
 
-				totol_youhui += m_youhuiquan_youhui;
+				total_youhui += m_youhuiquan_youhui;
 
 				cur_price -= m_youhuiquan_youhui;
 			}
@@ -1379,7 +1379,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 	wstring ws_rengong_youhui = pYouhuiEdit->GetText();
 	m_rengong_youhui = atof(CLewaimaiString::UnicodeToUTF8(ws_rengong_youhui).c_str());
 
-	totol_youhui += m_rengong_youhui;
+	total_youhui += m_rengong_youhui;
 
 	cur_price -= m_rengong_youhui;
 
@@ -1406,7 +1406,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 		double new_price = (int)(cur_price * 10) / 10.0;
 
 		m_moling_youhui = cur_price - new_price;
-		totol_youhui += m_moling_youhui;
+		total_youhui += m_moling_youhui;
 
 		cur_price = new_price;
 	}
@@ -1415,7 +1415,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 		double new_price = (int)(cur_price);
 
 		m_moling_youhui = cur_price - new_price;
-		totol_youhui += m_moling_youhui;
+		total_youhui += m_moling_youhui;
 
 		cur_price = new_price;
 	}
@@ -1427,7 +1427,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 
 	m_cur_total_price = cur_price;
 
-	m_total_youhui = totol_youhui;
+	m_total_youhui = total_youhui;
 
 	//至此优惠全部处理完了,开始刷新各个地方的展示
 
@@ -1435,9 +1435,9 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 	CHorizontalLayoutUI* pYouhuiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("diandan_page_youhui_tishi_layout")));
 	CLabelUI* pYouhuiLabel = static_cast<CLabelUI*>(this->FindSubControl(_T("diandan_page_youhui_tishi")));
 
-	if (totol_youhui > 0)
+	if (total_youhui > 0)
 	{
-		wstring youhuilabel = L"已优惠 " + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(totol_youhui, 2)) + L" 元";
+		wstring youhuilabel = L"已优惠 " + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(total_youhui, 2)) + L" 元";
 		pYouhuiLabel->SetText(youhuilabel.c_str());
 
 		pYouhuiLayout->SetVisible(true);
@@ -1686,7 +1686,7 @@ void CDiandanPageUI::UpdateJiesuanInfo()
 	pYingshou->SetText((L"应收金额:" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(cur_price, 2)) + L"元").c_str());
 
 	//同步更新副屏的显示内容
-	CShuangpingTool::GetInstance()->UpdateShow(m_cur_diandan_order);
+	CShuangpingTool::GetInstance()->UpdateShow(m_cur_diandan_order, total_youhui, cur_price, m_dabao);
 }
 
 void CDiandanPageUI::ClickFoodAction()

+ 2 - 2
zhipuzi_pos_windows/tool/CShuangpingTool.cpp

@@ -90,7 +90,7 @@ void CShuangpingTool::Init()
 	m_pFuping->ShowWindow(true);
 }
 
-void CShuangpingTool::UpdateShow(CDiandanOrder& order)
+void CShuangpingTool::UpdateShow(CDiandanOrder& order, double total_youhui, double total_price, double dabao_money)
 {
 	if (m_is_shuangping == false)
 	{
@@ -98,5 +98,5 @@ void CShuangpingTool::UpdateShow(CDiandanOrder& order)
 		return;
 	}
 
-	
+	m_pFuping->UpdateShow(order, total_youhui, total_price, dabao_money);
 }

+ 2 - 2
zhipuzi_pos_windows/tool/CShuangpingTool.h

@@ -16,8 +16,8 @@ public:
 	//初始化副屏,对副屏情况进行判断(程序刚启动马上就执行)
 	void Init();
 
-	//刷新副屏显示
-	void UpdateShow(CDiandanOrder& order);
+	//刷新副屏显示,在点单页面的商品或价格发生变化时调用,重新计算渲染副屏显示数据
+	void UpdateShow(CDiandanOrder& order, double total_youhui, double total_price, double dabao_money);
 
 private:
 	CShuangpingTool();

+ 114 - 13
zhipuzi_pos_windows/wnd/CFupingWnd.cpp

@@ -1,4 +1,4 @@
-#include "../pch/pch.h"
+#include "../pch/pch.h"
 #include "CFupingWnd.h"
 
 #include "../page/CDiandanPageUI.h"
@@ -108,7 +108,7 @@ LRESULT CFupingWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
 	styleValue &= ~WS_CAPTION;
 	::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
 
-	// 把自己的窗口句柄与窗口绘制管理器挂接在一起
+	// 把自己的窗口句柄与窗口绘制管理器挂接在一起
 	m_pm.Init(m_hWnd);
 
 	m_pm.AddPreMessageFilter(this);
@@ -118,10 +118,10 @@ LRESULT CFupingWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
 	CControlUI* pRoot = builder.Create(_T("fuping_wnd.xml"), (UINT)0, NULL, &m_pm);
 	ASSERT(pRoot && "Failed to parse XML");
 
-	// 把这些控件绘制到本窗口上
+	// 鎶婅繖浜涙帶浠剁粯鍒跺埌鏈�獥鍙d笂
 	m_pm.AttachDialog(pRoot);
 
-	// 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
+	// 鎶婅嚜宸卞姞鍏ュ埌CPaintManagerUI鐨刴_aNotifiers鏁扮粍涓�紝鐢ㄤ簬澶勭悊Notify鍑芥暟
 	m_pm.AddNotifier(this);
 
 	Init();
@@ -134,10 +134,10 @@ void CFupingWnd::Notify(TNotifyUI& msg)
 	
 }
 
-//刚启动程序初始化副屏窗口的时候执行,app生命周期只执行一次
+//刚启动程序初始化副屏窗口的时候执行,app生命周期只执行一次
 void CFupingWnd::Init()
 {
-	//启动轮播图展示任务
+	//启动轮播图展示任务
 	std::thread(&CFupingWnd::HandleFupingImage, this).detach();
 }
 
@@ -149,12 +149,19 @@ void CFupingWnd::HandleFupingImage()
 
 		if (lunbo_img_paths.size() == 0)
 		{
-			//有可能后台没设置轮播图,有可能还没请求到后台最新数据,等待
+			//鏈夊彲鑳藉悗鍙版病璁剧疆杞�挱鍥撅紝鏈夊彲鑳借繕娌¤�姹傚埌鍚庡彴鏈€鏂版暟鎹�紝绛夊緟
 			CSystem::my_sleep(2);
 
 			continue;
 		}
 
+		//璧板埌杩欓噷锛岃疆鎾�浘鏁版嵁鎷垮埌浜嗭紝搴楅摵鍚嶅瓧鏁版嵁鑲�畾涔熸嬁鍒颁簡
+		CLabelUI* nameControl = static_cast<CLabelUI*>(m_pm.FindControl(L"shopname"));
+
+		std::wstring shopname = CLewaimaiString::UTF8ToUnicode(CShopinfo::GetInstance()->m_shop_name);
+		nameControl->SetText(shopname.c_str());
+
+		//鐒跺悗寮€濮嬪�鐞嗚疆鎾�浘
 		if (m_curImageNum > lunbo_img_paths.size() - 1)
 		{
 			m_curImageNum = 0;
@@ -162,28 +169,122 @@ void CFupingWnd::HandleFupingImage()
 
 		std::wstring image_path = lunbo_img_paths[m_curImageNum];
 
-		//判断图片是否存在
+		//鍒ゆ柇鍥剧墖鏄�惁瀛樺湪
 		if (!CSystem::IsFileExist(image_path))
 		{
-			//轮播图的图片还未下载好
+			//轮播图的图片还未下载好
 			CSystem::my_sleep(3);
 
-			//2秒后还没下载好,处理下一张
+			//2秒后还没下载好,处理下一张
 			m_curImageNum++;
 
 			continue;
 		}
 
-		//轮播图的图片已经下载好了,那么就直接渲染
+		//杞�挱鍥剧殑鍥剧墖宸茬粡涓嬭浇濂戒簡锛岄偅涔堝氨鐩存帴娓叉煋
 		CControlUI* imageControl = static_cast<CControlUI*>(m_pm.FindControl(L"lunbo_image"));
 		imageControl->SetBkImage(image_path.c_str());
 
-		//等待2秒钟,换下一张
+		//等待2秒钟,换下一张
 		CSystem::my_sleep(3);
 
-		//2秒后还没下载好,处理下一张
+		//2秒后还没下载好,处理下一张
 		m_curImageNum++;
 
 		continue;
 	}
 }
+
+//鍒锋柊鍓�睆鏄剧ず
+void CFupingWnd::UpdateShow(CDiandanOrder& order, double total_youhui, double total_price, double dabao_money)
+{
+	//鍏堟竻绌哄綋鍓嶇殑鏄剧ず
+	CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("list_diandan_cart")));
+	pList->RemoveAll();
+
+	//鐒跺悗渚濇�娓叉煋鎵€鏈夌殑
+	int nItemNum = order.getItemNum();
+	for (int i = 0; i < nItemNum; i++)
+	{
+		CDiandanOrderItem item = order.getDiandanOrderItem(i);
+
+		CDialogBuilder builder;
+		CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("diandan_cart_item.xml"), (UINT)0, NULL, &m_pm));
+
+		pList->Add(pEle);
+
+		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());
+		}
+		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)
+			{
+				pEle->SetFixedHeight(84);
+				pNature->SetVisible(true);
+				pNature->SetText(CLewaimaiString::UTF8ToUnicode(item.getNatureShow()).c_str());
+			}
+			else
+			{
+				pEle->SetFixedHeight(42);
+				pNature->SetVisible(false);
+			}
+		}
+	}
+
+	//鍒锋柊浼樻儬灞曠ず
+	CHorizontalLayoutUI* pYouhuiLayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("diandan_page_youhui_tishi_layout")));
+	CLabelUI* pYouhuiLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("diandan_page_youhui_tishi")));
+
+	if (total_youhui > 0)
+	{
+		wstring youhuilabel = L"已优惠 " + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(total_youhui, 2)) + L" 元";
+		pYouhuiLabel->SetText(youhuilabel.c_str());
+
+		pYouhuiLayout->SetVisible(true);
+	}
+	else
+	{
+		pYouhuiLayout->SetVisible(false);
+	}
+
+	//鍐嶅埛鏂版墦鍖呰垂灞曠ず
+	CLabelUI* pOtherPriceLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("diandan_page_otherprice")));
+	if (dabao_money > 0)
+	{
+		std::wstring ws_dabaofei = L"打包费 " + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(dabao_money, 2)) + L" 元";
+		pOtherPriceLabel->SetText(ws_dabaofei.c_str());
+	}
+	else
+	{
+		pOtherPriceLabel->SetText(L"");
+	}
+
+	//鍐嶅埛鏂版€讳环灞曠ず
+	CLabelUI* pTotalPrice = static_cast<CLabelUI*>(this->m_pm.FindControl(_T("diandan_page_totalprice")));
+	pTotalPrice->SetText((L"总价:¥" + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::DoubleToString(total_price, 2))).c_str());
+}

+ 6 - 0
zhipuzi_pos_windows/wnd/CFupingWnd.h

@@ -2,6 +2,8 @@
 
 #include "../pch/pch.h"
 
+#include "../zhipuzi/CDiandanOrder.h"
+
 class CFupingWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
 {
 public:
@@ -56,8 +58,12 @@ public:
 
 	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
 
+	//窗口初始化的时候调用一次,用来处理副屏轮播图展示
 	void HandleFupingImage();
 
+	//刷新副屏显示
+	void UpdateShow(CDiandanOrder& order, double total_youhui, double total_price, double dabao_money);
+
 public:
 	CPaintManagerUI m_pm;