Bläddra i källkod

开始做双屏

张洋 3 år sedan
förälder
incheckning
718fc068b2

+ 38 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/fuping_wnd.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Window>
+	<Font id="0" name="微软雅黑" size="22" />
+	<Font id="1" name="微软雅黑" size="32" />
+	
+	<VerticalLayout bkimage="shoukuan_bkg.png" >
+		<HorizontalLayout name="shoukuan_title_bkg" height="44" bkcolor="0xFF3CB371">
+			<Label name="memo_dlg_title" text="智铺子收银系统" height="44" align="left" valign="center" padding="0,0,0,0" textcolor="#FFFFFFFF" font="2"/>
+		</HorizontalLayout>		
+		
+		<HorizontalLayout>
+			<VerticalLayout width="500">
+				<HorizontalLayout height="80">
+					<Label text="欢迎光临" font="1" align="center"></Label>
+				</HorizontalLayout>
+				
+				<List name="list_diandan_cart" padding="0,10,0,0" itemlinecolor="#FF000000" vscrollbar="true">
+					<ListHeader inset="10,0,0,0"/>
+					<ListHeaderItem text="商品" width="220" align="left" />
+					<ListHeaderItem text="数量" width="80" align="center" />
+					<ListHeaderItem text="金额" width="80" align="center" />
+				</List>
+			</VerticalLayout>
+			
+			<Control width="1" bkcolor="#FFEBE8E8"></Control>
+			
+			<VerticalLayout>
+				<HorizontalLayout>
+				</HorizontalLayout>
+				
+				<Control height="1" bkcolor="#FFEBE8E8"></Control>
+				
+				<HorizontalLayout height="300">
+				</HorizontalLayout>
+			</VerticalLayout>
+		</HorizontalLayout>
+	</VerticalLayout>
+</Window>

+ 1 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/waimaiorder_info_page.xml

@@ -59,6 +59,7 @@
 						<Label text="订单信息" height="30" />
 						<Control height="1" bkcolor="#FFEAEAEA" />
 						<Label name="waimai_order_info_page_shopname" height="30" text="店铺名字:" />
+						<Label name="waimai_order_info_page_take_food_code" height="30" text="取餐号:" />
 						<Label name="waimai_order_info_page_status" height="30" text="订单状态:" />
 						<Label name="waimai_order_info_page_type" height="30" text="订单来源:" />
 						<Label name="waimai_order_info_page_pay_type" height="30" text="付款方式:" />

+ 5 - 0
zhipuzi_pos_windows/page/CBaobiaoPageUI.cpp

@@ -341,6 +341,11 @@ void CBaobiaoPageUI::SetPos(RECT rc, bool bNeedInvalidate)
 	//根据宽度计算每行显示的数量
 	int nMeihangNum = nWidth / 260;
 
+	if (nMeihangNum < 1)
+	{
+		nMeihangNum = 1;
+	}
+
 	int num = 0;
 
 	CHorizontalLayoutUI* pFenleiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("baobiao_page_yingye_items")));

+ 5 - 0
zhipuzi_pos_windows/page/CJiaobanPageUI.cpp

@@ -349,6 +349,11 @@ void CJiaobanPageUI::SetPos(RECT rc, bool bNeedInvalidate)
 	//根据宽度计算每行显示的数量
 	int nMeihangNum = nWidth / 260;
 
+	if (nMeihangNum < 1)
+	{
+		nMeihangNum = 1;
+	}
+
 	int num = 0;
 
 	CHorizontalLayoutUI* pFenleiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("jiaoban_page_yingye_items")));

+ 26 - 1
zhipuzi_pos_windows/page/CWaimaiOrderInfoPageUI.cpp

@@ -473,6 +473,31 @@ void CWaimaiOrderInfoPageUI::Refresh(CWaimaiOrder& order)
 	wstring wsShopname = _T("店铺名字:") + CLewaimaiString::UTF8ToUnicode(order.m_shop_name);
 	pShopname->SetText(wsShopname.c_str());
 
+	int nTakeFoodCodeHeight = 0;
+	CLabelUI *pTakeFoodCode = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_take_food_code")));
+	if (order.m_is_selftake == "1")
+	{
+		//自取订单,显示取餐号
+		if (CShopinfo::GetInstance()->m_version_type == "1")
+		{
+			wstring wsTakeFoodCode = _T("取餐号:") + CLewaimaiString::UTF8ToUnicode(order.m_take_food_code);
+			pTakeFoodCode->SetText(wsTakeFoodCode.c_str());
+		}
+		else
+		{
+			wstring wsTakeFoodCode = _T("取单号:") + CLewaimaiString::UTF8ToUnicode(order.m_take_food_code);
+			pTakeFoodCode->SetText(wsTakeFoodCode.c_str());
+		}
+
+		pTakeFoodCode->SetVisible(true);
+		nTakeFoodCodeHeight = 30;
+	}
+	else
+	{
+		pTakeFoodCode->SetVisible(false);
+		nTakeFoodCodeHeight = 0;
+	}
+
 	CLabelUI *pStatus = static_cast<CLabelUI *>(this->FindSubControl(_T("waimai_order_info_page_status")));
 	wstring wsStatus = _T("订单状态:") + CLewaimaiString::UTF8ToUnicode(order.m_order_status);
 
@@ -729,5 +754,5 @@ void CWaimaiOrderInfoPageUI::Refresh(CWaimaiOrder& order)
 		pConfigmemo->SetVisible(false);
 	}
 
-	this->FindSubControl(_T("waimai_order_info_page_layout_3"))->SetFixedHeight(order_filed_height + refundHeight + configMemoHeight + 211);
+	this->FindSubControl(_T("waimai_order_info_page_layout_3"))->SetFixedHeight(nTakeFoodCodeHeight + order_filed_height + refundHeight + configMemoHeight + 211);
 }

BIN
zhipuzi_pos_windows/resource/skin.zip


BIN
zhipuzi_pos_windows/resource/zhipuzi_pos_windows.aps


BIN
zhipuzi_pos_windows/resource/zhipuzi_pos_windows.rc


+ 101 - 0
zhipuzi_pos_windows/tool/CShuangpingTool.cpp

@@ -0,0 +1,101 @@
+#include "../pch/pch.h"
+#include "CShuangpingTool.h"
+
+#include "../wnd/CFupingWnd.h"
+
+CShuangpingTool::CShuangpingTool()
+{
+}
+
+bool CShuangpingTool::IsShuangping()
+{
+	INT iNumber = GetSystemMetrics(SM_CMONITORS);
+
+	if (iNumber > 1)
+	{
+		return true;
+	}
+
+	return false;
+}
+
+RECT CShuangpingTool::GetFupingArea()
+{
+	RECT rect;
+	rect.left = 0;
+	rect.top = 0;
+	rect.right = 0;
+	rect.bottom = 0;
+
+	INT iNumber = GetSystemMetrics(SM_CMONITORS);
+
+	for (int i = 0; i < iNumber; i++)
+	{
+		//初始化
+		BOOL bFlag;
+
+		DISPLAY_DEVICE dd;
+		ZeroMemory(&dd, sizeof(dd));
+		dd.cb = sizeof(dd);
+
+		DEVMODE devMode;
+		ZeroMemory(&devMode, sizeof(devMode));
+		devMode.dmSize = sizeof(devMode);
+
+		bFlag = EnumDisplayDevices(NULL, i, &dd, 0);//如果有该显示器,再去获得它的设置
+		if (bFlag == FALSE)
+		{
+			continue;
+		}
+
+		bFlag = EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, &devMode);
+		if (bFlag == FALSE)
+		{
+			continue;
+		}
+
+		if (devMode.dmPosition.x == 0 && devMode.dmPosition.y == 0)
+		{
+			//主显示器
+			continue;
+		}
+		else
+		{
+			//副显示器
+			rect.left = devMode.dmPosition.x;
+			rect.top = devMode.dmPosition.y;
+
+			rect.right = rect.left + devMode.dmPelsWidth;
+			rect.bottom = rect.top + devMode.dmPelsHeight;
+
+			return rect;
+		}
+	}
+
+	return rect;
+}
+
+void CShuangpingTool::UpdateShow()
+{
+	if (IsShuangping() == false)
+	{
+		//如果不是双屏,直接不处理
+		return;
+	}
+
+	//副屏区域
+	RECT fupingRect = GetFupingArea();
+
+	CFupingWnd* pFuping = new CFupingWnd();
+	if (pFuping == NULL)
+	{
+		return;
+	}
+
+	pFuping->Create(NULL, _T("智铺子收银软件副屏"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
+	pFuping->SetIcon(IDI_ICON_DUILIB);
+
+	pFuping->ShowWindow(true);
+
+	::MoveWindow(pFuping->GetHWND(), fupingRect.left, fupingRect.top, fupingRect.right - fupingRect.left, fupingRect.bottom - fupingRect.top, true);
+}

+ 27 - 0
zhipuzi_pos_windows/tool/CShuangpingTool.h

@@ -0,0 +1,27 @@
+#pragma once
+
+class CShuangpingTool
+{
+public:
+	static CShuangpingTool* GetInstance()
+	{
+		static CShuangpingTool instance;
+
+		return &instance;
+	}
+
+	void UpdateShow();
+
+private:
+	CShuangpingTool();
+
+public:
+	//当前是否双屏模式(超过1个屏幕判定为双屏)
+	bool IsShuangping();
+
+	RECT GetFupingArea();
+
+private:
+	
+};
+

+ 9 - 1
zhipuzi_pos_windows/wnd/CDiandanNatureWnd.cpp

@@ -158,7 +158,15 @@ void CDiandanNatureWnd::Init()
 				FoodNatureValue newvalueItem;
 
 				newvalueItem.name = value[j]["name"].GetString();
-				newvalueItem.value = value[j]["value"].GetInt();
+
+				if (value[j]["value"].IsString())
+				{
+					newvalueItem.value = atoi(value[j]["value"].GetString());
+				}
+				else
+				{
+					newvalueItem.value = value[j]["value"].GetInt();
+				}				
 
 				pItem->addNatureValue(newvalueItem);
 			}

+ 140 - 0
zhipuzi_pos_windows/wnd/CFupingWnd.cpp

@@ -0,0 +1,140 @@
+#include "../pch/pch.h"
+#include "CFupingWnd.h"
+
+#include "../page/CDiandanPageUI.h"
+
+LRESULT CFupingWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+	POINT pt;
+	pt.x = GET_X_LPARAM(lParam);
+	pt.y = GET_Y_LPARAM(lParam);
+	::ScreenToClient(*this, &pt);
+
+	RECT rcClient;
+	::GetClientRect(*this, &rcClient);
+
+	RECT rcCaption = m_pm.GetCaptionRect();
+	if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
+		&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
+	{
+		CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
+		if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
+		{
+			return HTCAPTION;
+		}
+	}
+
+	return HTCLIENT;
+}
+
+LRESULT CFupingWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+	SIZE szRoundCorner = m_pm.GetRoundCorner();
+	if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
+	{
+		CDuiRect rcWnd;
+		::GetWindowRect(*this, &rcWnd);
+		rcWnd.Offset(-rcWnd.left, -rcWnd.top);
+		rcWnd.right++;
+		rcWnd.bottom++;
+		HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
+		::SetWindowRgn(*this, hRgn, TRUE);
+		::DeleteObject(hRgn);
+	}
+
+	bHandled = FALSE;
+	return 0;
+}
+
+LRESULT CFupingWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	LRESULT lRes = 0;
+	BOOL bHandled = TRUE;
+	switch (uMsg)
+	{
+	case WM_CREATE:
+		lRes = OnCreate(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCACTIVATE:
+		lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCCALCSIZE:
+		lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCPAINT:
+		lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_NCHITTEST:
+		lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
+		break;
+	case WM_SIZE:
+		lRes = OnSize(uMsg, wParam, lParam, bHandled);
+		break;
+	default:
+		bHandled = FALSE;
+	}
+	if (bHandled)
+	{
+		return lRes;
+	}
+	if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
+	{
+		return lRes;
+	}
+	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
+}
+
+LRESULT CFupingWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
+{
+	if (uMsg == WM_KEYDOWN)
+	{
+		if (wParam == VK_RETURN)
+		{
+			return true;
+		}
+		else if (wParam == VK_ESCAPE)
+		{
+			Close(IDCANCEL);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+LRESULT CFupingWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+	LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
+	styleValue &= ~WS_CAPTION;
+	::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
+
+	// 把自己的窗口句柄与窗口绘制管理器挂接在一起
+	m_pm.Init(m_hWnd);
+
+	m_pm.AddPreMessageFilter(this);
+
+	CDialogBuilder builder;
+
+	CControlUI* pRoot = builder.Create(_T("fuping_wnd.xml"), (UINT)0, NULL, &m_pm);
+	ASSERT(pRoot && "Failed to parse XML");
+
+	// 把这些控件绘制到本窗口上
+	m_pm.AttachDialog(pRoot);
+
+	// 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
+	m_pm.AddNotifier(this);
+
+	Init();
+
+	return 0;
+}
+
+void CFupingWnd::Notify(TNotifyUI& msg)
+{
+	
+}
+
+void CFupingWnd::Init()
+{
+
+}

+ 62 - 0
zhipuzi_pos_windows/wnd/CFupingWnd.h

@@ -0,0 +1,62 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CFupingWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
+{
+public:
+	LPCTSTR GetWindowClassName() const
+	{
+		return _T("UIMemoWndFrame");
+	};
+
+	UINT GetClassStyle() const
+	{
+		return UI_CLASSSTYLE_DIALOG;
+	};
+
+	void OnFinalMessage(HWND /*hWnd*/)
+	{
+		//WindowImplBase::OnFinalMessage(hWnd);
+		m_pm.RemovePreMessageFilter(this);
+
+		//delete this;
+	};
+
+	void Init();
+
+	void Notify(TNotifyUI& msg);
+
+	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		if (::IsIconic(*this))
+		{
+			bHandled = FALSE;
+		}
+		return (wParam == 0) ? TRUE : FALSE;
+	}
+
+	LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		return 0;
+	}
+
+	LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+	{
+		return 0;
+	}
+
+	LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+	LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
+
+public:
+	CPaintManagerUI m_pm;
+};
+

+ 17 - 14
zhipuzi_pos_windows/wnd/CHuiyuanShoukuanWnd.cpp

@@ -820,27 +820,30 @@ void CHuiyuanShoukuanWnd::StartShoukuan()
 	//先判断收款码的格式是否正确
 	CEditUI* pShoujihaoEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("shoujihao_edit")));
 	std::wstring ws_Shoujihao = pShoujihaoEdit->GetText();
-	if (ws_Shoujihao.length() == 0)
-	{
-		pLabel->SetText(L"手机号不能为空");
-		pLabel->SetVisible(true);
-
-		return;
-	}
-
 	m_shoujihao = CLewaimaiString::UnicodeToUTF8(ws_Shoujihao);
 
 	CEditUI* pPasswordEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("password_edit")));
 	std::wstring ws_Password = pPasswordEdit->GetText();
-	if (ws_Password.length() == 0)
+	m_password = CLewaimaiString::UnicodeToUTF8(ws_Password);
+
+	if (m_shoukuanModel == 2)
 	{
-		pLabel->SetText(L"密码不能为空");
-		pLabel->SetVisible(true);
+		if (ws_Shoujihao.length() == 0)
+		{
+			pLabel->SetText(L"手机号不能为空");
+			pLabel->SetVisible(true);
 
-		return;
-	}
+			return;
+		}
 
-	m_password = CLewaimaiString::UnicodeToUTF8(ws_Password);
+		if (ws_Password.length() == 0)
+		{
+			pLabel->SetText(L"密码不能为空");
+			pLabel->SetVisible(true);
+
+			return;
+		}
+	}
 
 	//全部验证通过,就可以开始修改状态了
 	m_shoukuan_status = 1;

+ 4 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.cpp

@@ -1,6 +1,7 @@
 #include "pch/pch.h"
 
 #include "wnd/CLoginWnd.h"
+#include "tool/CShuangpingTool.h"
 
 #include <curl/curl.h>
 
@@ -88,6 +89,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
 
 	pLogin->ShowWindow(true);
 
+	//初始化副屏
+	CShuangpingTool::GetInstance()->UpdateShow();
+
     CPaintManagerUI::MessageLoop();
 
     ::CoUninitialize();

+ 4 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj

@@ -229,6 +229,8 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="wnd\CFupingWnd.h" />
+    <ClInclude Include="tool\CShuangpingTool.h" />
     <ClInclude Include="wnd\CShangpinSaomaluruWnd.h" />
     <ClInclude Include="wnd\CShangpinNewTypeWnd.h" />
     <ClInclude Include="page\CShangpinUpdatePageUI.h" />
@@ -326,6 +328,8 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClInclude Include="helper\CSystem.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="wnd\CFupingWnd.cpp" />
+    <ClCompile Include="tool\CShuangpingTool.cpp" />
     <ClCompile Include="wnd\CShangpinSaomaluruWnd.cpp" />
     <ClCompile Include="wnd\CShangpinNewTypeWnd.cpp" />
     <ClCompile Include="page\CShangpinUpdatePageUI.cpp" />

+ 12 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj.filters

@@ -300,6 +300,12 @@
     <ClInclude Include="wnd\CShangpinSaomaluruWnd.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="tool\CShuangpingTool.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="wnd\CFupingWnd.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -560,6 +566,12 @@
     <ClCompile Include="wnd\CShangpinSaomaluruWnd.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="tool\CShuangpingTool.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="wnd\CFupingWnd.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="resource\zhipuzi.ico">