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