|
|
@@ -21,7 +21,7 @@ void CZhengcanPageUI::InitShow()
|
|
|
{
|
|
|
InitTabletypeShow();
|
|
|
|
|
|
- InitTableShow();
|
|
|
+ RefreshTableShow();
|
|
|
}
|
|
|
|
|
|
//处理按钮点击类事件
|
|
|
@@ -64,7 +64,7 @@ void CZhengcanPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
|
|
|
m_cur_type_id = id;
|
|
|
|
|
|
- this->InitTableShow();
|
|
|
+ this->RefreshTableShow();
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
@@ -108,53 +108,10 @@ void CZhengcanPageUI::InitTabletypeShow()
|
|
|
m_zhuozitypeLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("zhengcan_zhuozi_type_layout")));
|
|
|
m_zhuozitypeLayout->RemoveAll();
|
|
|
|
|
|
- std::map<string, string> params;
|
|
|
-
|
|
|
- std::string response;
|
|
|
-
|
|
|
- std::string url = "/dinnercash/gettableinfo";
|
|
|
- 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& tabletype = data["type"];
|
|
|
+ std::vector<TableType> tableTypes = CShopinfo::GetInstance()->m_tabletypes;
|
|
|
|
|
|
//计算总的桌子分类数量
|
|
|
- m_tabletype_num = tabletype.Size() + 1;
|
|
|
+ m_tabletype_num = tableTypes.size() + 1;
|
|
|
|
|
|
m_cur_type_id = "all";
|
|
|
|
|
|
@@ -178,17 +135,15 @@ void CZhengcanPageUI::InitTabletypeShow()
|
|
|
}
|
|
|
|
|
|
//接下来开始处理商品分类
|
|
|
- for (rapidjson::SizeType i = 0; i < tabletype.Size(); ++i)
|
|
|
+ for (std::vector<TableType>::iterator it = tableTypes.begin(); it != tableTypes.end(); it++)
|
|
|
{
|
|
|
- rapidjson::Value& typeinfo = tabletype[i];
|
|
|
-
|
|
|
CDialogBuilder builder;
|
|
|
CDialogBuilderCallbackEx cb;
|
|
|
|
|
|
CFoodtypeOptionUI* pItem = static_cast<CFoodtypeOptionUI*>(builder.Create(_T("tabletype_option.xml"), (UINT)0, &cb, m_pManager));
|
|
|
|
|
|
- pItem->SetName(CLewaimaiString::UTF8ToUnicode(CLewaimaiJson::ToString(typeinfo["name"])));
|
|
|
- pItem->SetTypeId(CLewaimaiJson::ToString(typeinfo["id"]));
|
|
|
+ pItem->SetName(CLewaimaiString::UTF8ToUnicode(it->name));
|
|
|
+ pItem->SetTypeId(it->id);
|
|
|
pItem->SetGroup(L"zhengcan_tabletype");
|
|
|
|
|
|
m_zhuozitypeLayout->Add(pItem);
|
|
|
@@ -270,8 +225,24 @@ void CZhengcanPageUI::UpdateTabletypePos()
|
|
|
pFenleiScrollLayout->SetScrollPos(size);
|
|
|
}
|
|
|
|
|
|
-void CZhengcanPageUI::InitTableShow()
|
|
|
+void CZhengcanPageUI::RefreshTableShow()
|
|
|
+{
|
|
|
+ //开始转菊花
|
|
|
+ CVerticalLayoutUI* pTableLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist")));
|
|
|
+ pTableLayout->SetVisible(false);
|
|
|
+
|
|
|
+ this->FindSubControl(_T("loading"))->SetVisible(true);
|
|
|
+
|
|
|
+ //启动一个线程,进行网络请求操作
|
|
|
+
|
|
|
+ std::thread t(&CZhengcanPageUI::DoRefreshTable, this);
|
|
|
+ t.detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CZhengcanPageUI::DoRefreshTable()
|
|
|
{
|
|
|
+ m_is_refresh_table = true;
|
|
|
+
|
|
|
m_tableLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist")));
|
|
|
m_tableLayout->RemoveAll();
|
|
|
|
|
|
@@ -292,7 +263,7 @@ void CZhengcanPageUI::InitTableShow()
|
|
|
bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
|
|
|
if (ret == false)
|
|
|
{
|
|
|
-
|
|
|
+ m_is_refresh_table = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -302,13 +273,14 @@ void CZhengcanPageUI::InitTableShow()
|
|
|
if (document.HasParseError())
|
|
|
{
|
|
|
LOG_INFO("parse response error!");
|
|
|
+ m_is_refresh_table = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
|
|
|
{
|
|
|
LOG_INFO("json error!");
|
|
|
-
|
|
|
+ m_is_refresh_table = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -316,13 +288,13 @@ void CZhengcanPageUI::InitTableShow()
|
|
|
int errcode = v_errcode.GetInt();
|
|
|
if (errcode != 0)
|
|
|
{
|
|
|
-
|
|
|
+ m_is_refresh_table = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!document.HasMember("data"))
|
|
|
{
|
|
|
-
|
|
|
+ m_is_refresh_table = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -349,11 +321,23 @@ void CZhengcanPageUI::InitTableShow()
|
|
|
m_table_num++;
|
|
|
}
|
|
|
|
|
|
+ CVerticalLayoutUI* pTableLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist")));
|
|
|
+ pTableLayout->SetVisible(true);
|
|
|
+
|
|
|
+ this->FindSubControl(_T("loading"))->SetVisible(false);
|
|
|
+
|
|
|
+ m_is_refresh_table = false;
|
|
|
+
|
|
|
UpdateTablePos();
|
|
|
}
|
|
|
|
|
|
void CZhengcanPageUI::UpdateTablePos()
|
|
|
{
|
|
|
+ if (m_is_refresh_table == true)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
int nTableNum = m_table_num;
|
|
|
|
|
|
//添加支付方式
|