Преглед на файлове

完成外卖订单列表的展示

zhangyang преди 6 години
родител
ревизия
2ee23fa08c

+ 8 - 3
bin/Win32/Debug/zhipuzi_pos_windows/skin/GameRes/desk.xml

@@ -1,10 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Window>
-	<Container width="1000" height="200" padding="10,10,10,10" bkcolor="#FFFFFFFF" childpadding="20">
+	<WaimaiOrderItem width="1000" height="200" padding="10,10,10,10" bkcolor="#FFFFFFFF" childpadding="20" mouse="false">
 		<Label float="true" name="waimai_order_list_name" text="姓名:" textcolor="#FF558CC4" pos="0,6,182,36" mouse="false" />
 		<Label float="true" name="waimai_order_list_phone" text="电话:" textcolor="#FF558CC4" pos="0,36,182,66" mouse="false" />
 		<Label float="true" name="waimai_order_list_address" text="地址:" textcolor="#FF558CC4" pos="0,66,182,96" mouse="false" />
+		<Label float="true" name="waimai_order_list_init_date" text="下单时间:" textcolor="#FF558CC4" pos="0,96,182,126" mouse="false" />
+		
 		<Label float="true" name="waimai_order_list_price" text="价格:" textcolor="#FF558CC4" pos="300,6,482,36" mouse="false" />
-		<Label float="true" name="waimai_order_list_order_no" text="订单编号:" textcolor="#FF558CC4" pos="300,36,482,66" mouse="false" />
-	</Container>
+		<Label float="true" name="waimai_order_list_order_no" text="订单编号:" textcolor="#FF558CC4" pos="300,36,600,66" mouse="false" />
+		
+		<Button name="waimai_order_list_info" float="true" pos="600,6,660,36" text="详情" textcolor="#FFFF0000" bkcolor="#FFFFFF00"/>
+		<Button name="waimai_order_list_info" float="true" pos="600,56,660,86" text="打印" textcolor="#FFFF0000" bkcolor="#FFFFFF00"/>
+	</WaimaiOrderItem>
 </Window>

BIN
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


+ 2 - 0
lewaimai_dispatch/lewaimai_dispatch_windows.vcxproj

@@ -193,6 +193,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="wnd\CWaimaiOrderItemUI.h" />
     <ClInclude Include="wnd\CGameFrameWnd.h" />
     <ClInclude Include="wnd\CLoginWnd.h" />
     <ClInclude Include="helper\MD5.h" />
@@ -212,6 +213,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClInclude Include="wnd\OrderListUI.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="wnd\CWaimaiOrderItemUI.cpp" />
     <ClCompile Include="wnd\CGameFrameWnd.cpp" />
     <ClCompile Include="wnd\CLoginWnd.cpp" />
     <ClCompile Include="helper\MD5.cpp" />

+ 6 - 0
lewaimai_dispatch/lewaimai_dispatch_windows.vcxproj.filters

@@ -66,6 +66,9 @@
     <ClInclude Include="wnd\OrderListUI.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="wnd\CWaimaiOrderItemUI.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="lewaimai_dispatch_windows.cpp">
@@ -113,6 +116,9 @@
     <ClCompile Include="wnd\OrderListUI.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="wnd\CWaimaiOrderItemUI.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="conf\dispatch.conf" />

+ 0 - 7
lewaimai_dispatch/network/CZhipuziHttpClient.cpp

@@ -1,13 +1,6 @@
 #include "../pch/pch.h"
 #include "CZhipuziHttpClient.h"
 
-#include "rapidjson/document.h"
-#include "rapidjson/prettywriter.h"  
-#include "rapidjson/writer.h"
-#include "rapidjson/stringbuffer.h"
-
-using namespace rapidjson;
-
 #include "../helper/MD5.h"
 
 CZhipuziHttpClient CZhipuziHttpClient::m_client;

+ 7 - 0
lewaimai_dispatch/pch/pch.h

@@ -74,5 +74,12 @@ using namespace DuiLib;
 #include <exdisp.h>
 #include <comdef.h>
 
+#include "rapidjson/document.h"
+#include "rapidjson/prettywriter.h"  
+#include "rapidjson/writer.h"
+#include "rapidjson/stringbuffer.h"
+
+using namespace rapidjson;
+
 #endif //PCH_H
 

+ 12 - 0
lewaimai_dispatch/wnd/CWaimaiOrderItemUI.cpp

@@ -0,0 +1,12 @@
+#include "../pch/pch.h"
+#include "CWaimaiOrderItemUI.h"
+
+
+CWaimaiOrderItemUI::CWaimaiOrderItemUI()
+{
+}
+
+
+CWaimaiOrderItemUI::~CWaimaiOrderItemUI()
+{
+}

+ 60 - 0
lewaimai_dispatch/wnd/CWaimaiOrderItemUI.h

@@ -0,0 +1,60 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CWaimaiOrderItemUI : public CContainerUI
+{
+public:
+	CWaimaiOrderItemUI();
+	~CWaimaiOrderItemUI();
+
+	void SetData(rapidjson::Value& orderinfo)
+	{
+		m_name = orderinfo["customer_name"].GetString();
+		m_address = orderinfo["address"].GetString();
+		m_phone = orderinfo["customer_phone"].GetString();
+		m_price = orderinfo["price"].GetString();
+		m_order_no = orderinfo["order_no"].GetString();
+		m_init_date = orderinfo["init_date"].GetString();
+
+		m_orderid = orderinfo["id"].GetString();
+
+		std::wstring name_show = L"姓名:" + CLewaimaiString::string2wstring(m_name);
+		this->FindSubControl(L"waimai_order_list_name")->SetText(name_show.c_str());
+
+		std::wstring address_show = L"地址:" + CLewaimaiString::string2wstring(m_address);
+		this->FindSubControl(L"waimai_order_list_address")->SetText(address_show.c_str());
+
+		std::wstring phone_show = L"电话:" + CLewaimaiString::string2wstring(m_phone);
+		this->FindSubControl(L"waimai_order_list_phone")->SetText(phone_show.c_str());
+
+		std::wstring price_show = L"价格:" + CLewaimaiString::string2wstring(m_price);
+		this->FindSubControl(L"waimai_order_list_price")->SetText(price_show.c_str());
+
+		std::wstring order_no_show = L"订单号:" + CLewaimaiString::string2wstring(m_order_no);
+		this->FindSubControl(L"waimai_order_list_order_no")->SetText(order_no_show.c_str());
+
+		std::wstring init_date_show = L"下单时间:" + CLewaimaiString::string2wstring(m_init_date);
+		this->FindSubControl(L"waimai_order_list_init_date")->SetText(init_date_show.c_str());
+	}
+
+	void DoEvent(TEventUI& event)
+	{
+		if (event.Type == UIEVENT_TIMER)
+		{
+			
+		}
+		CContainerUI::DoEvent(event);
+	}
+
+private:
+	std::string m_name;
+	std::string m_address;
+	std::string m_phone;
+	std::string m_price;
+	std::string m_order_no;
+	std::string m_init_date;
+
+	std::string m_orderid;
+};
+

+ 5 - 0
lewaimai_dispatch/wnd/ControlEx.h

@@ -2,6 +2,7 @@
 
 #include "../pch/pch.h"
 
+#include "CWaimaiOrderItemUI.h"
 #include "OrderListUI.h"
 
 class CDialogBuilderCallbackEx : public IDialogBuilderCallback
@@ -13,6 +14,10 @@ public:
 		{
 			return new OrderListUI;
 		}
+		else if (_tcscmp(pstrClass, _T("WaimaiOrderItem")) == 0)
+		{
+			return new CWaimaiOrderItemUI;
+		}
 
 		return NULL;
 	}

+ 56 - 12
lewaimai_dispatch/wnd/OrderListUI.cpp

@@ -1,6 +1,10 @@
 #include "../pch/pch.h"
 #include "OrderListUI.h"
 
+#include "CWaimaiOrderItemUI.h"
+
+#include "ControlEx.h"
+
 void OrderListUI::Refresh()
 {
 	COptionUI* waimai_open_op = static_cast<COptionUI*>(m_pManager->FindControl(L"waimai_open_switch"));
@@ -12,23 +16,63 @@ void OrderListUI::Refresh()
 		std::string response;
 
 		CZhipuziHttpClient::RequestOld("/waimaiorder/getopenlist", params, response);
-	}
 
-	CDialogBuilder builder;
-	CContainerUI* pDesk = static_cast<CContainerUI*>(builder.Create(_T("desk.xml"), (UINT)0));
-	if (pDesk != NULL) {
-		for (int i = 0; i < 20; ++i)
+		rapidjson::Document document;
+		document.Parse(response.c_str());
+
+		if (document.HasParseError())
 		{
-			if (pDesk == NULL) pDesk = static_cast<CContainerUI*>(builder.Create());
-			if (pDesk != NULL) {
-				this->Add(pDesk);
+			LOG_INFO("parse response error!");
+		}
+		else
+		{
+			if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+			{
+				LOG_INFO("json error!");
+			}
 
-				pDesk = NULL;
+			rapidjson::Value& v_errcode = document["errcode"];
+			int errcode = v_errcode.GetInt();
+			if (errcode != 0)
+			{
+				LOG_INFO("response failed! message:" << document["errmsg"].GetString());
 			}
-			else {
-				this->RemoveAll();
-				return;
+			{
+				//获得数据成功
+				rapidjson::Value& data = document["data"];
+
+				rapidjson::Value& v_count = data["count"];
+				string count = v_count.GetString();
+
+				rapidjson::Value& v_rows = data["rows"];
+
+				for (rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
+				{
+					rapidjson::Value& v_row_i = v_rows[i];
+
+					//创建一个对象
+					CDialogBuilder builder;
+					CDialogBuilderCallbackEx cb;
+
+					CWaimaiOrderItemUI* pDesk = static_cast<CWaimaiOrderItemUI*>(builder.Create(_T("desk.xml"), (UINT)0, &cb, m_pManager));							
+					if (pDesk != NULL)
+					{
+						//初始化该对应的数据
+						pDesk->SetData(v_row_i);
+
+						this->Add(pDesk);
+
+						pDesk = NULL;
+					}
+					else 
+					{
+						return;
+					}
+				}
 			}
 		}
 	}
+
+	
+	
 }

+ 0 - 3
lewaimai_dispatch/wnd/OrderListUI.h

@@ -112,7 +112,4 @@ private:
 	DWORD m_dwDelayLeft;
 
 	int m_status = 1; //1:未处理 2:已确认 3:配送中 4:成功 5:失败 6:退款中
-
-public:
-	CPaintManagerUI m_pm;
 };