Commit c39f8eab by xiaoqing.gu

1、分离获取档口信息的代码成单独的函数 2、修改主界面的样式表

parent 4f8ef409
...@@ -73,6 +73,32 @@ void StallsGetWork::workstart() ...@@ -73,6 +73,32 @@ void StallsGetWork::workstart()
while(!_stopflag) while(!_stopflag)
{ {
//获取档口信息 //获取档口信息
QJsonObject recvjson = getStallsInfo();
//判断recvjson,如果返回失败和没有商品列表,则不推送这个消息
QJsonObject tmpjson;
QJsonArray tmparray;
if(recvjson.contains(EVENT_KEY_RESULT) && recvjson[EVENT_KEY_RESULT].toObject().contains(EVENT_KEY_FILEPRODUCTLIST)) {
tmpjson = recvjson[EVENT_KEY_RESULT].toObject();
tmparray = tmpjson[EVENT_KEY_FILEPRODUCTLIST].toArray();
if(recvjson[JSON_KEY_CODE].toString() != "100" || tmparray.size() == 0) {
POSTEVENTTYPE(PosEvent::s_change_stalls, recvjson, QJsonObject);
}
}
//获取档口信息完成后检擦是否退出表示
if(_stopflag)
break;
QEventLoop loop;
connect(this, &StallsGetWork::quit, &loop, &QEventLoop::quit);
loop.exec();
}
_stoped = true;
}
QJsonObject StallsGetWork::getStallsInfo()
{
QJsonObject json, recvjson; QJsonObject json, recvjson;
QString realurl; QString realurl;
QString error; QString error;
...@@ -80,7 +106,7 @@ void StallsGetWork::workstart() ...@@ -80,7 +106,7 @@ void StallsGetWork::workstart()
if(!GetStallsDataProcess::getStallsOptRequest(json, _storeinfo[JSON_KEY_PARTNERID].toString())) if(!GetStallsDataProcess::getStallsOptRequest(json, _storeinfo[JSON_KEY_PARTNERID].toString()))
{ {
QLOG_ERROR() << "getStallsOptRequest failed"; QLOG_ERROR() << "getStallsOptRequest failed";
return; return QJsonObject();
} }
QLOG_INFO() << "getStallsOptRequest request json : " << json; QLOG_INFO() << "getStallsOptRequest request json : " << json;
...@@ -88,7 +114,7 @@ void StallsGetWork::workstart() ...@@ -88,7 +114,7 @@ void StallsGetWork::workstart()
if(!GetStallsDataProcess::getRealUrl(ADVANCEORDER, json, _url, realurl)) if(!GetStallsDataProcess::getRealUrl(ADVANCEORDER, json, _url, realurl))
{ {
QLOG_ERROR() << "getStallsOptRequest getRealUrl failed"; QLOG_ERROR() << "getStallsOptRequest getRealUrl failed";
return; return QJsonObject();
} }
QLOG_INFO() << "getStallsOptRequest request url :" << realurl; QLOG_INFO() << "getStallsOptRequest request url :" << realurl;
...@@ -96,30 +122,10 @@ void StallsGetWork::workstart() ...@@ -96,30 +122,10 @@ void StallsGetWork::workstart()
if(!this->S_Request(json, recvjson, realurl, error)) if(!this->S_Request(json, recvjson, realurl, error))
{ {
QLOG_ERROR() << "getStallsOptRequest failed : " << error; QLOG_ERROR() << "getStallsOptRequest failed : " << error;
return; return QJsonObject();
} }
QLOG_INFO() << "getStallsOptRequest return json : " << recvjson; QLOG_INFO() << "getStallsOptRequest return json : " << recvjson;
return recvjson;
//判断recvjson,如果返回失败和一种,则不推送这个消息
QJsonObject tmpjson;
QJsonArray tmparray;
if(recvjson.contains(EVENT_KEY_RESULT) && recvjson[EVENT_KEY_RESULT].toObject().contains(EVENT_KEY_FILEPRODUCTLIST)) {
tmpjson = recvjson[EVENT_KEY_RESULT].toObject();
tmparray = tmpjson[EVENT_KEY_FILEPRODUCTLIST].toArray();
if(recvjson[JSON_KEY_CODE].toString() != "100" || tmparray.size() == 0) {
POSTEVENTTYPE(PosEvent::s_change_stalls, recvjson, QJsonObject);
}
}
//获取档口信息完成后检擦是否退出表示
if(_stopflag)
break;
QEventLoop loop;
connect(this, &StallsGetWork::quit, &loop, &QEventLoop::quit);
loop.exec();
}
_stoped = true;
} }
...@@ -29,6 +29,8 @@ signals: ...@@ -29,6 +29,8 @@ signals:
public slots: public slots:
void workstart(); void workstart();
private: private:
QJsonObject getStallsInfo();
QVariantMap _storeinfo; QVariantMap _storeinfo;
QString _token; QString _token;
......
...@@ -1093,7 +1093,7 @@ void NewMainForm::onSetStalls(QJsonObject json) ...@@ -1093,7 +1093,7 @@ void NewMainForm::onSetStalls(QJsonObject json)
QJsonObject tmpjson = tmparray[i].toObject(); QJsonObject tmpjson = tmparray[i].toObject();
QString stallsStr; QString stallsStr;
stallsList.append(tmpjson[EVENT_KEY_FILENAME].toString()); stallsList.append(tmpjson[EVENT_KEY_FILENAME].toString());
stallsStr.append(tmpjson[EVENT_KEY_FILENAME].toString() + QString::fromLocal8Bit(":")); stallsStr.append(tmpjson[EVENT_KEY_FILENAME].toString() + QString::fromLocal8Bit(""));
if(tmpjson.contains(EVENT_KEY_PRODUCTLIST)) { if(tmpjson.contains(EVENT_KEY_PRODUCTLIST)) {
QJsonArray proarray = tmpjson[EVENT_KEY_PRODUCTLIST].toArray(); QJsonArray proarray = tmpjson[EVENT_KEY_PRODUCTLIST].toArray();
...@@ -1112,6 +1112,7 @@ void NewMainForm::onSetStalls(QJsonObject json) ...@@ -1112,6 +1112,7 @@ void NewMainForm::onSetStalls(QJsonObject json)
for(int k = 0; k < productList.size(); k++) { for(int k = 0; k < productList.size(); k++) {
ui->stallsTextBrowser->append(QString(productList.at(k))); ui->stallsTextBrowser->append(QString(productList.at(k)));
} }
ui->stallsTextBrowser->anchorAt(QPoint(0,0));
} }
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1647</width> <width>1644</width>
<height>733</height> <height>762</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
...@@ -246,10 +246,16 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -246,10 +246,16 @@ QTabWidget#newmaintbwgt QTabBar::tab
font: 16px &quot;微软雅黑&quot;; font: 16px &quot;微软雅黑&quot;;
color: rgb(51, 51, 51); color: rgb(51, 51, 51);
} }
#newlabel_11,#newlabel_12,#newmaincombx_del,#newmainvtn_ordersave,#newmainrdbtn_self,#newmainrdbtn_auto #newlabel_11,#newlabel_12,#newmaincombx_del,#newmainvtn_ordersave,#newmainrdbtn_self,#newmainrdbtn_auto,#newmaincmbox_stalls,#label_stalls
{ {
font: 16px &quot;微软雅黑&quot;; font: 16px &quot;微软雅黑&quot;;
color: rgb(51, 51, 51); color: rgb(51, 51, 51);
}
#stallsTextBrowser
{
font: 16px &quot;微软雅黑&quot;;
color: rgb(51, 51, 51);
background-color:rgb(255, 255, 203);
}</string> }</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,7"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,7">
...@@ -1140,7 +1146,7 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -1140,7 +1146,7 @@ QTabWidget#newmaintbwgt QTabBar::tab
<attribute name="title"> <attribute name="title">
<string>打印设置</string> <string>打印设置</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_8" stretch="0,7,0,2"> <layout class="QVBoxLayout" name="verticalLayout_8" stretch="0,7,2">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
...@@ -3676,19 +3682,6 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -3676,19 +3682,6 @@ QTabWidget#newmaintbwgt QTabBar::tab
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_22">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true"> <widget class="QWidget" name="widget_3" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
...@@ -3713,8 +3706,14 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -3713,8 +3706,14 @@ QTabWidget#newmaintbwgt QTabBar::tab
<widget class="QLabel" name="label_stalls"> <widget class="QLabel" name="label_stalls">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>65</width>
<height>30</height> <height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>65</width>
<height>16777215</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
...@@ -3730,9 +3729,12 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -3730,9 +3729,12 @@ QTabWidget#newmaintbwgt QTabBar::tab
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>80</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
...@@ -3742,8 +3744,14 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -3742,8 +3744,14 @@ QTabWidget#newmaintbwgt QTabBar::tab
<widget class="QComboBox" name="newmaincmbox_stalls"> <widget class="QComboBox" name="newmaincmbox_stalls">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>150</width> <width>180</width>
<height>30</height> <height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size> </size>
</property> </property>
</widget> </widget>
...@@ -3764,7 +3772,14 @@ QTabWidget#newmaintbwgt QTabBar::tab ...@@ -3764,7 +3772,14 @@ QTabWidget#newmaintbwgt QTabBar::tab
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QTextBrowser" name="stallsTextBrowser"/> <widget class="QTextBrowser" name="stallsTextBrowser">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment