From 8d970ecff49fc7ea5a4ad1f47ee96c62391300ae Mon Sep 17 00:00:00 2001 From: zhangsan Date: Thu, 21 Oct 2021 17:19:25 +0800 Subject: [PATCH] =?UTF-8?q?2=E4=B8=AAapi=E6=B5=8B=E8=AF=95=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QCPShow.pro | 2 +- QCPShow.pro.user | 26 +++++++++++++------------- api.http | 47 +++++++++++++++++++++++++++++++++++++++++++++++ deviceservice.cpp | 4 ++-- httpservice.cpp | 14 +++++++++----- httpservice.h | 1 + main.cpp | 2 +- mainconfig.cpp | 2 +- mainwidget.cpp | 36 ++++++++++++++++++++++++------------ mainwidget.h | 4 ++++ resttest | 9 --------- 11 files changed, 103 insertions(+), 44 deletions(-) create mode 100644 api.http delete mode 100644 resttest diff --git a/QCPShow.pro b/QCPShow.pro index f4e5a96..cd4bef4 100644 --- a/QCPShow.pro +++ b/QCPShow.pro @@ -68,4 +68,4 @@ RESOURCES += \ DISTFILES += \ .gitignore \ ReadMe.md \ - resttest + api.http diff --git a/QCPShow.pro.user b/QCPShow.pro.user index d4f0342..9691761 100644 --- a/QCPShow.pro.user +++ b/QCPShow.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {0d351c1e-abb6-427c-8d0b-30ca23826ed5} + {fe03815e-74e2-457e-b60c-e66368cd4ce4} ProjectExplorer.Project.ActiveTarget @@ -66,7 +66,7 @@ 0 0 - D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug + E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug true @@ -90,7 +90,7 @@ 2 - 构建 + Build ProjectExplorer.BuildSteps.Build @@ -106,7 +106,7 @@ 1 - 清理 + Clean ProjectExplorer.BuildSteps.Clean @@ -144,7 +144,7 @@ 2 - 构建 + Build ProjectExplorer.BuildSteps.Build @@ -160,7 +160,7 @@ 1 - 清理 + Clean ProjectExplorer.BuildSteps.Clean @@ -198,7 +198,7 @@ 2 - 构建 + Build ProjectExplorer.BuildSteps.Build @@ -214,7 +214,7 @@ 1 - 清理 + Clean ProjectExplorer.BuildSteps.Clean @@ -231,7 +231,7 @@ 0 - 部署 + Deploy ProjectExplorer.BuildSteps.Deploy @@ -285,14 +285,14 @@ 2 QCPShow - QCPShow2 - Qt4ProjectManager.Qt4RunConfiguration:D:/Qt/QtSpace/qt_qcp_show/QCPShow.pro + + Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/QtSpace/QCPShow/QCPShow.pro true QCPShow.pro false - D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug + E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug 3768 false true diff --git a/api.http b/api.http new file mode 100644 index 0000000..3076526 --- /dev/null +++ b/api.http @@ -0,0 +1,47 @@ +GET https://example.com/comments/1 HTTP/1.1 + +### + +GET https://example.com/topics/1 HTTP/1.1 + +### +# @name signin +POST http://test.tall.wiki/gateway/tall3/v3.0/users/signin HTTP/1.1 +content-type: application/json + +{ + "client": 1, + "data": { + "credential": "123456", + "identifier": "shoufeichu" + }, + "scene": 0, + "type": 3 +} + +### + +POST https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern HTTP/1.1 +content-type: application/json +Authorization: Bearer {{signin.response.body.$.data.token}} + +{ + "param":{ + "idcard":"142733198703123919", + "name":"彭于晏", + "sex":"1", + "nation":"汉族" + } +} + +### + +POST https://test.tall.wiki/gateway/qcp/v3.0/button/buttonStart HTTP/1.1 +content-type: application/json +Authorization: Bearer {{signin.response.body.$.data.token}} + +{ + "param":{ + "idcard":"142733198703123919" + } +} \ No newline at end of file diff --git a/deviceservice.cpp b/deviceservice.cpp index 1e106de..3d9eb7f 100644 --- a/deviceservice.cpp +++ b/deviceservice.cpp @@ -70,8 +70,8 @@ quint8 DeviceService::keyReadOnce() #ifdef Q_OS_LINUX return digitalRead(WIRING_PIN_KEY); #else - qDebug() << "keyReadOnce()"; - return 0; + //qDebug() << "keyReadOnce()"; + return KEY_Up; #endif } diff --git a/httpservice.cpp b/httpservice.cpp index 40bddfe..c074970 100644 --- a/httpservice.cpp +++ b/httpservice.cpp @@ -103,6 +103,7 @@ QByteArray HttpService::postJson(QUrl url,const QByteArray &json, quint32 timeou result = reply->readAll(); } } + qDebug() << result; return result; } @@ -114,7 +115,6 @@ void HttpService::login(QString username, QString password) //发送请求 QByteArray result = postJson(MainConfig::loginUrl,json.toUtf8()); - qDebug() << result; //解析响应 QJsonParseError jerror; @@ -144,7 +144,6 @@ void HttpService::updateStatus(QString firstAidId, QString status) //发送请求 QByteArray result = postJson(MainConfig::serviceStatusChangedUrl,json.toUtf8()); - qDebug() << result; //解析响应 QJsonParseError jerror; @@ -173,7 +172,6 @@ void HttpService::sendIdcardInfo(QString idcard,QString name, QString sex, QStri //发送请求 QByteArray result = postJson(MainConfig::sendUserInfoUrl,json.toUtf8()); - qDebug() << result; //解析响应 QJsonParseError jerror; @@ -201,8 +199,7 @@ void HttpService::oneKeyStart(QString idcard) QString json = rawJson.arg(idcard); //发送请求 - QByteArray result = postJson(MainConfig::sendUserInfoUrl,json.toUtf8()); - qDebug() << result; + QByteArray result = postJson(MainConfig::oneKeyStartUrl,json.toUtf8()); //解析响应 QJsonParseError jerror; @@ -222,3 +219,10 @@ void HttpService::oneKeyStart(QString idcard) qDebug() << "oneKeyStart失败:" << resCode; } } + +void HttpService::onComplexOneKeyStart(QString idcard, QString name, QString sex, QString nation) +{ + qDebug() << "onComplexOneKeyStart" << idcard << name << sex << nation; + sendIdcardInfo(idcard,name,sex,nation); + oneKeyStart(idcard); +} diff --git a/httpservice.h b/httpservice.h index 6465e61..c49f725 100644 --- a/httpservice.h +++ b/httpservice.h @@ -21,6 +21,7 @@ public slots: void updateStatus(QString firstAidId,QString status); void sendIdcardInfo(QString idcard,QString name,QString sex,QString nation); void oneKeyStart(QString idcard); + void onComplexOneKeyStart(QString idcard,QString name,QString sex,QString nation); }; #endif // HTTPSERVICE_H diff --git a/main.cpp b/main.cpp index 12a257f..88eed3c 100644 --- a/main.cpp +++ b/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) &w,&MainWidget::onKeyClicked); QObject::connect(&w,&MainWidget::statusChanged,&httpService,&HttpService::updateStatus); - + QObject::connect(&w,&MainWidget::complexOneKeyStart,&httpService,&HttpService::onComplexOneKeyStart); w.show(); // w.showFullScreen(); diff --git a/mainconfig.cpp b/mainconfig.cpp index 01acabd..c09b674 100644 --- a/mainconfig.cpp +++ b/mainconfig.cpp @@ -5,7 +5,7 @@ #define D_CONFIG_FILE_PATH "./setting.ini" QString MainConfig::token = ""; -QString MainConfig::username = "shoufeichu"; +QString MainConfig::username = "fenzhentai"; QString MainConfig::password = "123456"; QString MainConfig::loginUrl = "http://test.tall.wiki/gateway/tall3/v3.0/users/signin"; QString MainConfig::sendUserInfoUrl = "https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern"; diff --git a/mainwidget.cpp b/mainwidget.cpp index 49067f5..bf3d57e 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -3,6 +3,8 @@ #include #include "mainconfig.h" +#define FIXEDIDCARD "" + MainWidget::MainWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MainWidget) @@ -48,9 +50,9 @@ MainWidget::MainWidget(QWidget *parent) : ui->textLabel->setStyleSheet("QLabel {color: rgb(255,0,0);}");//设置文本红色 ui->countdownLabel->setStyleSheet("QLabel {color: rgb(255,0,0);}");//设置文本红色 ui->statusLabel->setStyleSheet("QLabel {color: rgb(85,255,0);}");//设置文本绿色 -// ui->textLabel->setAlignment(Qt::AlignHCenter); -// ui->countdownLabel->setAlignment(Qt::AlignHCenter); -// ui->statusLabel->setAlignment(Qt::AlignRight); + // ui->textLabel->setAlignment(Qt::AlignHCenter); + // ui->countdownLabel->setAlignment(Qt::AlignHCenter); + // ui->statusLabel->setAlignment(Qt::AlignRight); m_curX = 0; connect(&m_lableScrollTimer,SIGNAL(timeout()),this,SLOT(lableScrollDisplay())); @@ -67,10 +69,10 @@ void MainWidget::updateUi() m_curX = 0;//内容超出显示区域时,更新患者信息显示从头开始滚动 //更新statusLabel -// ui->statusLabel->setText(QString("%1 | %2") -// .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接") -// .arg(m_patientEmergencyInfos.length()) -// ); + // ui->statusLabel->setText(QString("%1 | %2") + // .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接") + // .arg(m_patientEmergencyInfos.length()) + // ); if(m_wsConnectedStatus){ ui->LEDLabel->setStyleSheet("border-image: url(:/image/1LED_green.png);"); }else{ @@ -98,7 +100,7 @@ void MainWidget::updateUi() int hour,min,sec,nTotalSecs; nTotalSecs = pInfo->realCountDownInSeconds; sec = nTotalSecs % 60; -// min = nTotalSecs / 60 % 60; + // min = nTotalSecs / 60 % 60; min = nTotalSecs / 60 ; //min显示大于60 hour = nTotalSecs / 3600; QString str = QString("%1:%2").arg(min,2,10,QLatin1Char('0')).arg(sec,2,10,QLatin1Char('0')); @@ -110,7 +112,7 @@ void MainWidget::paintEvent(QPaintEvent *event) //设置背景图片 QPainter p(this); p.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/black_bg.jpg")); -// qDebug() << "MainWidget::paintEvent"; + // qDebug() << "MainWidget::paintEvent"; //重新调整label字体大小 //TODO @@ -121,7 +123,7 @@ void MainWidget::resizeEvent(QResizeEvent *event) QWidget::resizeEvent(event); //标题 -// ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2); + // ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2); ui->countdownLabel->setGeometry(0,(this->height()-30)/2,this->width(),(this->height()-30)/2); ui->LEDLabel->setGeometry(this->width()-120,this->height()-30,20,30); ui->statusLabel->setGeometry(this->width()-80,this->height()-30,20,30); @@ -137,7 +139,7 @@ void MainWidget::lableScrollDisplay() else{ m_curX ++; ui->textLabel->setGeometry(20-m_curX,0,m_width,(this->height()-30)/2); -// qDebug()<<"move" < (m_width - this->width())){ m_curX = 0; @@ -183,7 +185,7 @@ void MainWidget::onPatientMergencyStatusChanged(QString firstAidId,QString time, void MainWidget::onKeyClicked() { -// emit onKeyStart(); + emit complexOneKeyStart("142733198703123918","彭于晏","1","汉族"); qDebug() << "Key Clicked"; } @@ -212,3 +214,13 @@ void MainWidget::deletePatientFromList(QString firstAidId) } } } + +void MainWidget::mouseDoubleClickEvent(QMouseEvent *event) +{ + if(event->button()==Qt::LeftButton){ + //TODO + } + else if(event->button()==Qt::RightButton){ + onKeyClicked(); + } +} diff --git a/mainwidget.h b/mainwidget.h index b9e472b..9166d9b 100644 --- a/mainwidget.h +++ b/mainwidget.h @@ -19,6 +19,7 @@ public: ~MainWidget(); void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); private: Ui::MainWidget *ui; @@ -45,6 +46,9 @@ public slots: signals: void statusChanged(QString firstAidId,QString status); + void complexOneKeyStart(QString idcard,QString name,QString sex,QString nation); + void sendCardInfo(QString idcard,QString name,QString sex,QString nation); + void oneKeyStart(QString idcard); }; #endif // MAINWIDGET_H diff --git a/resttest b/resttest deleted file mode 100644 index b92ab71..0000000 --- a/resttest +++ /dev/null @@ -1,9 +0,0 @@ -https://example.com/comments/1 - -POST https://example.com/comments HTTP/1.1 -content-type: application/json - -{ - "name": "sample", - "time": "Wed, 21 Oct 2015 18:27:50 GMT" -}