|
@@ -2,6 +2,9 @@
|
|
|
#include "ui_blastopepage.h"
|
|
|
#include "countdownwidget.h"
|
|
|
#include <QFont>
|
|
|
+#include "logger.h"
|
|
|
+#include <QProcessEnvironment>
|
|
|
+#include "loadingwidget.h"
|
|
|
|
|
|
|
|
|
BlastOpePage::BlastOpePage(QWidget *parent) :
|
|
@@ -9,11 +12,9 @@ BlastOpePage::BlastOpePage(QWidget *parent) :
|
|
|
ui(new Ui::BlastOpePage),
|
|
|
dao(DatabaseManager::getInstance().getDatabase())
|
|
|
{
|
|
|
-
|
|
|
- ui->setupUi(this);
|
|
|
- initPagination();
|
|
|
- //InitFace();
|
|
|
-
|
|
|
+ InitFace();
|
|
|
+ //ui->setupUi(this);
|
|
|
+ //initPagination();
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::showDownWidget(QString uuid,const QString &topic,const QString &message){
|
|
@@ -29,7 +30,6 @@ void BlastOpePage::showDownWidget(QString uuid,const QString &topic,const QStrin
|
|
|
if (widget) {
|
|
|
|
|
|
connect(countdownWidget, &CountdownWidget::countdownFinished, widget, [widget,topic,message,countdownWidget](){
|
|
|
-
|
|
|
widget->onCountdownFinished(topic,message);
|
|
|
}, Qt::SingleShotConnection);
|
|
|
}
|
|
@@ -37,7 +37,8 @@ void BlastOpePage::showDownWidget(QString uuid,const QString &topic,const QStrin
|
|
|
|
|
|
void BlastOpePage::InitFace()
|
|
|
{
|
|
|
-
|
|
|
+ Logger::getInstance().info("start init face verification");
|
|
|
+ LoadingWidget::showLoading(nullptr, "请求创建人脸识别...");
|
|
|
layout = new QVBoxLayout(this);
|
|
|
view = new QWebEngineView(this);
|
|
|
view->setAttribute(Qt::WA_OpaquePaintEvent);
|
|
@@ -50,10 +51,13 @@ void BlastOpePage::InitFace()
|
|
|
handleFeaturePermission(page, securityOrigin, feature);
|
|
|
});
|
|
|
|
|
|
- QUrl postUrl("http://192.168.0.255:8000/api/v1/h-face-verify/pc");
|
|
|
+ Logger::getInstance().info("FaceVerification: connect");
|
|
|
+ // QUrl postUrl("http://192.168.1.234:8000/api/v1/h-face-verify/pc");
|
|
|
+ QUrl postUrl(QString("%1/%2").arg().arg("h-face-verify/pc") );
|
|
|
QJsonObject response = sendPostRequest(postUrl, metaInfo);
|
|
|
QString certifyUrl;
|
|
|
if (response.contains("data") && response["data"].isObject()) {
|
|
|
+ LoadingWidget::showLoading(nullptr, "正在打开人脸识别界面...");
|
|
|
QJsonObject dataObject = response["data"].toObject();
|
|
|
if (dataObject.contains("ResultObject") && dataObject["ResultObject"].isObject()) {
|
|
|
QJsonObject resultObject = dataObject["ResultObject"].toObject();
|
|
@@ -75,14 +79,16 @@ void BlastOpePage::InitFace()
|
|
|
|
|
|
QObject::connect(page, &QWebEnginePage::urlChanged, this, &BlastOpePage::onUrlChanged);
|
|
|
} else {
|
|
|
-
|
|
|
- qDebug() << "Failed to get certifyUrl.";
|
|
|
+ QMessageBox::information(nullptr, "提示", "人脸识别请求失败");
|
|
|
+ qDebug() << "Failed to get certifyUrl." << response;
|
|
|
+ Logger::getInstance().error("FaceVerificationInit: Failed to get certifyUrl");
|
|
|
}
|
|
|
+ Logger::getInstance().info("FaceVerificationInit: successfully");
|
|
|
+ LoadingWidget::hideLoading();
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::closeWebViewAndRestoreUI()
|
|
|
{
|
|
|
- //TODO: crash
|
|
|
if (view) {
|
|
|
layout->removeWidget(view);
|
|
|
delete view;
|
|
@@ -99,7 +105,8 @@ void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
|
if (newUrl.scheme() == "https" && newUrl.host() == "www.baidu.com") {
|
|
|
closeWebViewAndRestoreUI();
|
|
|
QNetworkAccessManager manager;
|
|
|
- QUrl requestUrl(QString("http://192.168.0.255:8000/api/v1/h-face-verify/certifyId/%1").arg(certifyId));
|
|
|
+ //QUrl requestUrl(QString("http://192.168.0.255:8000/api/v1/h-face-verify/certifyId/%1").arg(certifyId));
|
|
|
+ QUrl requestUrl(QString("http://192.168.1.234:8000/api/v1/h-face-verify/certifyId/%1").arg(certifyId));
|
|
|
QNetworkRequest request(requestUrl);
|
|
|
QNetworkReply *reply = manager.get(request);
|
|
|
QEventLoop loop;
|
|
@@ -136,12 +143,12 @@ void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
|
}
|
|
|
} else {
|
|
|
qDebug() << "Request failed:" << reply->errorString();
|
|
|
+ Logger::getInstance().error("InitFaseVerification request failed: ");
|
|
|
+ Logger::getInstance().error(reply->errorString());
|
|
|
}
|
|
|
|
|
|
reply->deleteLater();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -199,8 +206,14 @@ void BlastOpePage::handleFeaturePermission(QWebEnginePage *page, const QUrl &sec
|
|
|
|
|
|
QJsonObject BlastOpePage::getMetaInfo() {
|
|
|
QJsonObject metaInfo;
|
|
|
- metaInfo["certName"] = "wangyao";
|
|
|
- metaInfo["certNo"] = "";
|
|
|
+
|
|
|
+ // TODO: 获取登录用户信息
|
|
|
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); // 获取系统环境变量
|
|
|
+ QString certName = env.value("certName", ""); // 第二个参数为默认值
|
|
|
+ QString certNo = env.value("certNo", "");
|
|
|
+ metaInfo["certName"] = certName;
|
|
|
+ metaInfo["certNo"] = certNo;
|
|
|
+ qDebug() << certName << certNo << "<certInfo";
|
|
|
return metaInfo;
|
|
|
}
|
|
|
|