Commit c73ece29 by 朱博

修改网络错误提示

parent fe831517
fmtakeout.pro.user fmtakeout.pro.user
build-takeout-Desktop_Qt_5_5_1_MSVC2010_32bit-Debug/
build-takeout-Desktop_Qt_5_5_1_MSVC2010_32bit-Release/
*.user
#include "configstoremanage.h"
configStoreManage::configStoreManage()
{
}
#ifndef CONFIGSTOREMANAGE_H
#define CONFIGSTOREMANAGE_H
#include <QSettings>
class configStoreManage
{
public:
configStoreManage();
};
#endif // CONFIGSTOREMANAGE_H
...@@ -279,6 +279,8 @@ bool OrderGetWork::PullOrder(unsigned int timeout, QString &error) ...@@ -279,6 +279,8 @@ bool OrderGetWork::PullOrder(unsigned int timeout, QString &error)
if(!BillSocket::S_Request(json, recvjson, realurl, error)) if(!BillSocket::S_Request(json, recvjson, realurl, error))
{ {
error = QString::fromLocal8Bit("拉单失败,网络错误:").append(error); error = QString::fromLocal8Bit("拉单失败,网络错误:").append(error);
//QVariantMap value;
//POSTEVENTTYPE(PosEvent::s_network_outtime,value,QVariantMap);
QLOG_ERROR() << "pullorder failed : " << error; QLOG_ERROR() << "pullorder failed : " << error;
return false; return false;
} }
......
...@@ -23,6 +23,7 @@ OrderPushWork::OrderPushWork(QObject *parent) : QObject(parent) ...@@ -23,6 +23,7 @@ OrderPushWork::OrderPushWork(QObject *parent) : QObject(parent)
_token = QString(""); _token = QString("");
_serurl.clear(); _serurl.clear();
_istimeout = true; _istimeout = true;
_networkstatic_index=1;
FMApplication::subscibeEvent(this, PosEvent::s_token_change); FMApplication::subscibeEvent(this, PosEvent::s_token_change);
FMApplication::subscibeEvent(this, PosEvent::s_login_storeinfo); FMApplication::subscibeEvent(this, PosEvent::s_login_storeinfo);
...@@ -251,6 +252,25 @@ bool OrderPushWork::loginTcpServer() ...@@ -251,6 +252,25 @@ bool OrderPushWork::loginTcpServer()
return false; return false;
} }
void OrderPushWork::networkouttime(bool networkstatus)
{
if(networkstatus)
{
_networkstatic_index=0;
QVariantMap map;
map.insert(EVENT_KEY_NETWORKSTATUS, networkstatus);
POSTEVENTTYPE(PosEvent::s_network_outtime,map,QVariantMap);
}else if(!networkstatus && _networkstatic_index == 0){
_networkstatic_index++;
QVariantMap map;
map.insert(EVENT_KEY_NETWORKSTATUS, networkstatus);
POSTEVENTTYPE(PosEvent::s_network_outtime,map,QVariantMap);
QLOG_INFO() << "static: s_network_outtime ...";
}
}
void OrderPushWork::heartBeatTcpService() void OrderPushWork::heartBeatTcpService()
{ {
while(_stopflag && !_needlogin) while(_stopflag && !_needlogin)
...@@ -498,8 +518,13 @@ void OrderPushWork::workStart() ...@@ -498,8 +518,13 @@ void OrderPushWork::workStart()
{ {
if(!connectTcpServer()) if(!connectTcpServer())
{ {
//QVariantMap value;
//POSTEVENTTYPE(PosEvent::s_network_outtime,value,QVariantMap);
networkouttime(false);
QLOG_ERROR() << "connectTcpServer failed"; QLOG_ERROR() << "connectTcpServer failed";
break; break;
}else{
networkouttime(true);
} }
if(!loginTcpServer()) if(!loginTcpServer())
......
...@@ -145,7 +145,7 @@ public: ...@@ -145,7 +145,7 @@ public:
private: private:
bool GetServiceList(); bool GetServiceList();
void networkouttime(bool networkstatus);
public slots: public slots:
//推模式入口 //推模式入口
void workStart(); void workStart();
...@@ -181,6 +181,8 @@ private: ...@@ -181,6 +181,8 @@ private:
QMutex _token_lock; QMutex _token_lock;
//获取服务器列表地址 //获取服务器列表地址
QString _serurl; QString _serurl;
//网络失败提示的个数
int _networkstatic_index;
}; };
......
...@@ -20,6 +20,7 @@ QEvent::Type PosEvent::s_show_float = static_cast<QEvent::Type>(QEvent::register ...@@ -20,6 +20,7 @@ QEvent::Type PosEvent::s_show_float = static_cast<QEvent::Type>(QEvent::register
QEvent::Type PosEvent::s_show_mainform = static_cast<QEvent::Type>(QEvent::registerEventType()); QEvent::Type PosEvent::s_show_mainform = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_show_prtform = static_cast<QEvent::Type>(QEvent::registerEventType()); QEvent::Type PosEvent::s_show_prtform = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_show_login = static_cast<QEvent::Type>(QEvent::registerEventType()); QEvent::Type PosEvent::s_show_login = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_network_outtime = static_cast<QEvent::Type>(QEvent::registerEventType());
PosEvent::PosEvent(Type e):QEvent(e) PosEvent::PosEvent(Type e):QEvent(e)
{ {
......
...@@ -96,7 +96,8 @@ public: ...@@ -96,7 +96,8 @@ public:
static Type s_show_prtform; static Type s_show_prtform;
//登录界面显示 //登录界面显示
static Type s_show_login; static Type s_show_login;
//网络超时
static Type s_network_outtime;
private: private:
//事件携带的信息,该内存你应当在堆中分配 //事件携带的信息,该内存你应当在堆中分配
void *_info; void *_info;
......
...@@ -189,6 +189,8 @@ ...@@ -189,6 +189,8 @@
#define EVENT_KEY_SEASION "reason" #define EVENT_KEY_SEASION "reason"
#define EVENT_KEY_ORDERSTATUS "orderstatus" #define EVENT_KEY_ORDERSTATUS "orderstatus"
#define EVENT_KEY_NETWORKSTATUS "networkstatus"
#define TCPJSON_KEY_STOREID "storeId" #define TCPJSON_KEY_STOREID "storeId"
#define TCPJSON_KEY_TOKEN "token" #define TCPJSON_KEY_TOKEN "token"
......
...@@ -50,6 +50,8 @@ LoginForm::LoginForm(QWidget *parent) : ...@@ -50,6 +50,8 @@ LoginForm::LoginForm(QWidget *parent) :
m_alertForm = new AlertForm(this); m_alertForm = new AlertForm(this);
FMApplication::subscibeEvent(this, PosEvent::s_login_status); FMApplication::subscibeEvent(this, PosEvent::s_login_status);
FMApplication::subscibeEvent(this, PosEvent::s_opt_status); FMApplication::subscibeEvent(this, PosEvent::s_opt_status);
FMApplication::subscibeEvent(this, PosEvent::s_show_login); FMApplication::subscibeEvent(this, PosEvent::s_show_login);
......
...@@ -46,6 +46,7 @@ MainForm::MainForm(QWidget *parent) : ...@@ -46,6 +46,7 @@ MainForm::MainForm(QWidget *parent) :
FMApplication::subscibeEvent(this, PosEvent::s_delete_order); FMApplication::subscibeEvent(this, PosEvent::s_delete_order);
FMApplication::subscibeEvent(this, PosEvent::s_login_storeinfo); FMApplication::subscibeEvent(this, PosEvent::s_login_storeinfo);
FMApplication::subscibeEvent(this, PosEvent::s_show_mainform); FMApplication::subscibeEvent(this, PosEvent::s_show_mainform);
FMApplication::subscibeEvent(this, PosEvent::s_network_outtime);
// 初始化界面 // 初始化界面
...@@ -77,6 +78,7 @@ void MainForm::MyShow() ...@@ -77,6 +78,7 @@ void MainForm::MyShow()
m_detailForm = new DetailForm(this); m_detailForm = new DetailForm(this);
connect(m_detailForm, &DetailForm::showAlert, this, &MainForm::onShowAlert); connect(m_detailForm, &DetailForm::showAlert, this, &MainForm::onShowAlert);
m_padForm = new PadForm(this); m_padForm = new PadForm(this);
m_padForm->move(pos().x()+width()-300, pos().y()+height()-438); m_padForm->move(pos().x()+width()-300, pos().y()+height()-438);
m_padForm->hide(); m_padForm->hide();
...@@ -186,6 +188,21 @@ bool MainForm::event(QEvent *e) ...@@ -186,6 +188,21 @@ bool MainForm::event(QEvent *e)
} }
return true; return true;
} }
if(e->type() == PosEvent::s_network_outtime)
{
QVariantMap value;
GETEVENTINFO(value,e,QVariantMap);
if(value.contains(EVENT_KEY_NETWORKSTATUS) && value[EVENT_KEY_NETWORKSTATUS].toBool() == true)
{
onSetNetStatus(QString::fromLocal8Bit("网络正常"));
}else{
QLOG_INFO() << "STATIC: EVENT_KEY_NETWORKSTATUS:false";
onSetNetStatus(QString::fromLocal8Bit("网络异常"));
onShowAlert(AlertForm::ERROR, QString::fromLocal8Bit("网络异常,请检查网络链接!"));
}
return true;
}
return QWidget::event(e); return QWidget::event(e);
} }
......
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