|
|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|