Browse Source

继续做正餐

张洋 3 years ago
parent
commit
3af1e2d168

+ 4 - 2
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_page.xml

@@ -11,8 +11,10 @@
 					</HorizontalLayout>
 				</VerticalLayout>
 				
-				<VerticalLayout>
-				
+				<VerticalLayout name="zhengcan_tablelist_scrolllayout" vscrollbar="true">
+					<VerticalLayout name="zhengcan_tablelist" padding="0,0,0,0">
+					
+					</VerticalLayout>
 				</VerticalLayout>
 			</VerticalLayout>
 				

+ 14 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_tableitem.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Window>
+	<Font id="1" name="微软雅黑" size="14" />
+	
+	<ZhengcanTableItem name="zhengcan_tableitem" bkcolor="#FFFFFFFF" width="177" height="140">
+		<Label name="tablename" width="145" height="60" multiline="true" endellipsis="true" font="20"></Label>
+		<Label name="status" height="30" font="16" textcolor="#FFFF7F50" align="left"></Label>
+		
+		<HorizontalLayout height="32">
+			<Label name="renshu" visible="true" width="50" height="26" font="14" text="6人" float="true" pos="33,5,63,30" textcolor="#FFFFFFFF"  align="center"></Label>		
+			<Label name="shijian" visible="true" width="50" height="26" font="14" text="50分钟" float="true" pos="133,5,163,30" textcolor="#FFFFFFFF" align="center"></Label>	
+		</HorizontalLayout>
+	</ZhengcanTableItem>
+</Window>

+ 40 - 0
zhipuzi_pos_windows/control/CZhengcanTableItemUI.cpp

@@ -0,0 +1,40 @@
+#include "CZhengcanTableItemUI.h"
+
+#include "../pch/pch.h"
+
+CZhengcanTableItemUI::CZhengcanTableItemUI()
+{
+
+}
+
+
+CZhengcanTableItemUI::~CZhengcanTableItemUI()
+{
+}
+
+void CZhengcanTableItemUI::DoEvent(TEventUI& event)
+{
+	if (event.Type == UIEVENT_BUTTONUP)
+	{
+		m_pManager->SendNotify(this, DUI_MSGTYPE_CLICK);
+	}
+	else if (event.Type == UIEVENT_MOUSEENTER)
+	{
+		HCURSOR hcur = LoadCursor(NULL, IDC_HAND);  //加载系统自带鼠标样式
+		HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
+		SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
+	}
+	else if (event.Type == UIEVENT_MOUSELEAVE)
+	{
+		HCURSOR hcur = LoadCursor(NULL, IDC_ARROW);  //加载系统自带鼠标样式
+		HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
+		SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
+	}
+
+	CVerticalLayoutUI::DoEvent(event);
+}
+
+void CZhengcanTableItemUI::UpdateShow()
+{
+
+}

+ 22 - 0
zhipuzi_pos_windows/control/CZhengcanTableItemUI.h

@@ -0,0 +1,22 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+/**
+ * 桌位的ITEM,都用这个
+ */
+class CZhengcanTableItemUI : public CVerticalLayoutUI
+{
+public:
+	CZhengcanTableItemUI();
+	~CZhengcanTableItemUI();
+
+	void DoEvent(TEventUI& event);
+
+	//刷新显示
+	void UpdateShow();
+
+private:
+
+};
+

+ 5 - 0
zhipuzi_pos_windows/control/ControlEx.h

@@ -27,6 +27,7 @@
 #include "CDiandanNatureItemUI.h"
 #include "CShangpinFoodItemUI.h"
 #include "CTabletypeOptionUI.h"
+#include "CZhengcanTableItemUI.h"
 
 class CDialogBuilderCallbackEx : public IDialogBuilderCallback
 {
@@ -132,6 +133,10 @@ public:
 		{
 			return new CTabletypeOptionUI;
 		}
+		else if (_tcscmp(pstrClass, _T("ZhengcanTableItem")) == 0)
+		{
+			return new CZhengcanTableItemUI;
+		}
 
 		return NULL;
 	}

+ 137 - 2
zhipuzi_pos_windows/page/CZhengcanPageUI.cpp

@@ -19,7 +19,7 @@ void CZhengcanPageUI::InitShow()
 {
 	InitTabletypeShow();
 
-
+	InitTableShow();
 }
 
 //处理按钮点击类事件
@@ -54,7 +54,7 @@ void CZhengcanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
 
 			m_cur_type_id = id;
 
-			//this->InitFoodShow();
+			this->InitTableShow();
 
 			return;
 		}
@@ -86,6 +86,9 @@ void CZhengcanPageUI::SetPos(RECT rc, bool bNeedInvalidate)
 	//更新分类位置
 	UpdateTabletypePos();
 
+	//更新桌子位置
+	UpdateTablePos();
+
 	CContainerUI::SetPos(rc, bNeedInvalidate);
 }
 
@@ -255,4 +258,136 @@ void CZhengcanPageUI::UpdateTabletypePos()
 	size.cx = 0;
 	size.cy = 0;
 	pFenleiScrollLayout->SetScrollPos(size);
+}
+
+void CZhengcanPageUI::InitTableShow()
+{
+	m_tableLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist")));
+	m_tableLayout->RemoveAll();
+
+	std::map<string, string> params;
+
+	if (m_cur_type_id == "all")
+	{
+		params["type_id"] = "-2";
+	}
+	else
+	{
+		params["type_id"] = m_cur_type_id;
+	}
+
+	std::string response;
+
+	std::string url = "/dinnercash/gettableinfobytypeid";
+	bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
+	if (ret == false)
+	{
+
+		return;
+	}
+
+	rapidjson::Document document;
+	document.Parse(response.c_str());
+
+	if (document.HasParseError())
+	{
+		LOG_INFO("parse response error!");
+		return;
+	}
+
+	if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
+	{
+		LOG_INFO("json error!");
+
+		return;
+	}
+
+	rapidjson::Value& v_errcode = document["errcode"];
+	int errcode = v_errcode.GetInt();
+	if (errcode != 0)
+	{
+
+		return;
+	}
+
+	if (!document.HasMember("data"))
+	{
+
+		return;
+	}
+
+	rapidjson::Value& data = document["data"];
+	rapidjson::Value& table = data["table"];
+
+	m_table_num = 0;
+
+	for (rapidjson::SizeType i = 0; i < table.Size(); ++i)
+	{
+		rapidjson::Value& tableinfo = table[i];
+
+		CDialogBuilder builder;
+		CDialogBuilderCallbackEx cb;
+
+		CZhengcanTableItemUI* pItem = static_cast<CZhengcanTableItemUI*>(builder.Create(_T("zhengcan_tableitem.xml"), (UINT)0, &cb, m_pManager));
+
+		pItem->UpdateShow();
+
+		m_tableLayout->Add(pItem);
+
+		m_table_num++;
+	}
+
+	UpdateTablePos();
+}
+
+void CZhengcanPageUI::UpdateTablePos()
+{
+	int nTableNum = m_table_num;
+
+	//添加支付方式
+	int nWidth = m_nPageWidth;
+	if (nWidth == 0)
+	{
+		return;
+	}
+
+	//根据宽度计算每行显示的数量
+	int nMeihangNum = (nWidth - 20) / 135;
+
+	if (nMeihangNum < 1)
+	{
+		nMeihangNum = 1;
+	}
+
+	int num = 0;
+
+	CVerticalLayoutUI* pFenleiLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist")));
+	for (int i = 0; i < nTableNum; i++)
+	{
+		CButtonUI* curItem = static_cast<CButtonUI*>(pFenleiLayout->GetItemAt(i));
+
+		int curRow = num / nMeihangNum + 1;
+		int curCol = num % nMeihangNum + 1;
+
+		RECT rect;
+		rect.left = (curCol - 1) * 192 + 15;
+		rect.right = rect.left + 177;
+		rect.top = (curRow - 1) * 155 + 15;
+		rect.bottom = rect.top + 140;
+
+		curItem->SetFloat(true);
+		curItem->SetPos(rect);
+
+		num++;
+	}
+
+	//调整区域高度
+	int lastRow = (num - 1) / nMeihangNum + 1;
+	pFenleiLayout->SetFixedHeight(lastRow * 155 + 15);
+
+	SIZE size;
+	size.cx = 0;
+	size.cy = 0;
+	CVerticalLayoutUI* pFenleiLayoutScroll = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist_scrolllayout")));
+	pFenleiLayoutScroll->SetScrollPos(size);
 }

+ 9 - 0
zhipuzi_pos_windows/page/CZhengcanPageUI.h

@@ -49,15 +49,24 @@ public:
 
 	void UpdateTabletypePos();
 
+	//根据当前选择的桌子分类,刷新桌位展示
+	void InitTableShow();
+
+	void UpdateTablePos();
+
 private:
 	//当前控件的实际宽度
 	int m_nPageWidth;
 
 	CHorizontalLayoutUI* m_zhuozitypeLayout;
+	CVerticalLayoutUI* m_tableLayout;
 
 	//桌子分类的数量
 	int m_tabletype_num;
 
+	//桌子数量
+	int m_table_num;
+
 	//当前选中的桌子分类ID,为空表示没选中任何分类,为all表示选中全部分类,如果选中普通分类就是分类ID
 	std::string m_cur_type_id = "";
 	CControlUI* m_curZhuozitypeOption;

+ 2 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj

@@ -230,6 +230,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="control\CTabletypeOptionUI.h" />
+    <ClInclude Include="control\CZhengcanTableItemUI.h" />
     <ClInclude Include="wnd\CFupingWnd.h" />
     <ClInclude Include="tool\CShuangpingTool.h" />
     <ClInclude Include="wnd\CShangpinSaomaluruWnd.h" />
@@ -330,6 +331,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="control\CTabletypeOptionUI.cpp" />
+    <ClCompile Include="control\CZhengcanTableItemUI.cpp" />
     <ClCompile Include="wnd\CFupingWnd.cpp" />
     <ClCompile Include="tool\CShuangpingTool.cpp" />
     <ClCompile Include="wnd\CShangpinSaomaluruWnd.cpp" />

+ 6 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj.filters

@@ -309,6 +309,9 @@
     <ClInclude Include="control\CTabletypeOptionUI.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="control\CZhengcanTableItemUI.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -578,6 +581,9 @@
     <ClCompile Include="control\CTabletypeOptionUI.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="control\CZhengcanTableItemUI.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="resource\zhipuzi.ico">