|
@@ -2,6 +2,10 @@
|
|
#include "ui_blastopepage.h"
|
|
#include "ui_blastopepage.h"
|
|
#include "countdownwidget.h"
|
|
#include "countdownwidget.h"
|
|
#include <QFont>
|
|
#include <QFont>
|
|
|
|
+#include "logger.h"
|
|
|
|
+#include <QProcessEnvironment>
|
|
|
|
+#include "loadingwidget.h"
|
|
|
|
+#include "global.h"
|
|
|
|
|
|
|
|
|
|
BlastOpePage::BlastOpePage(QWidget *parent) :
|
|
BlastOpePage::BlastOpePage(QWidget *parent) :
|
|
@@ -9,11 +13,9 @@ BlastOpePage::BlastOpePage(QWidget *parent) :
|
|
ui(new Ui::BlastOpePage),
|
|
ui(new Ui::BlastOpePage),
|
|
dao(DatabaseManager::getInstance().getDatabase())
|
|
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){
|
|
void BlastOpePage::showDownWidget(QString uuid,const QString &topic,const QString &message){
|
|
@@ -29,7 +31,6 @@ void BlastOpePage::showDownWidget(QString uuid,const QString &topic,const QStrin
|
|
if (widget) {
|
|
if (widget) {
|
|
|
|
|
|
connect(countdownWidget, &CountdownWidget::countdownFinished, widget, [widget,topic,message,countdownWidget](){
|
|
connect(countdownWidget, &CountdownWidget::countdownFinished, widget, [widget,topic,message,countdownWidget](){
|
|
-
|
|
|
|
widget->onCountdownFinished(topic,message);
|
|
widget->onCountdownFinished(topic,message);
|
|
}, Qt::SingleShotConnection);
|
|
}, Qt::SingleShotConnection);
|
|
}
|
|
}
|
|
@@ -37,7 +38,8 @@ void BlastOpePage::showDownWidget(QString uuid,const QString &topic,const QStrin
|
|
|
|
|
|
void BlastOpePage::InitFace()
|
|
void BlastOpePage::InitFace()
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ Logger::getInstance().info("start init face verification");
|
|
|
|
+ LoadingWidget::showLoading(nullptr, "请求创建人脸识别...");
|
|
layout = new QVBoxLayout(this);
|
|
layout = new QVBoxLayout(this);
|
|
view = new QWebEngineView(this);
|
|
view = new QWebEngineView(this);
|
|
view->setAttribute(Qt::WA_OpaquePaintEvent);
|
|
view->setAttribute(Qt::WA_OpaquePaintEvent);
|
|
@@ -50,10 +52,13 @@ void BlastOpePage::InitFace()
|
|
handleFeaturePermission(page, securityOrigin, feature);
|
|
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(g_url.resolved(QUrl("h-face-verify/pc")));
|
|
QJsonObject response = sendPostRequest(postUrl, metaInfo);
|
|
QJsonObject response = sendPostRequest(postUrl, metaInfo);
|
|
QString certifyUrl;
|
|
QString certifyUrl;
|
|
if (response.contains("data") && response["data"].isObject()) {
|
|
if (response.contains("data") && response["data"].isObject()) {
|
|
|
|
+ LoadingWidget::showLoading(nullptr, "正在打开人脸识别界面...");
|
|
QJsonObject dataObject = response["data"].toObject();
|
|
QJsonObject dataObject = response["data"].toObject();
|
|
if (dataObject.contains("ResultObject") && dataObject["ResultObject"].isObject()) {
|
|
if (dataObject.contains("ResultObject") && dataObject["ResultObject"].isObject()) {
|
|
QJsonObject resultObject = dataObject["ResultObject"].toObject();
|
|
QJsonObject resultObject = dataObject["ResultObject"].toObject();
|
|
@@ -75,14 +80,16 @@ void BlastOpePage::InitFace()
|
|
|
|
|
|
QObject::connect(page, &QWebEnginePage::urlChanged, this, &BlastOpePage::onUrlChanged);
|
|
QObject::connect(page, &QWebEnginePage::urlChanged, this, &BlastOpePage::onUrlChanged);
|
|
} else {
|
|
} 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()
|
|
void BlastOpePage::closeWebViewAndRestoreUI()
|
|
{
|
|
{
|
|
- //TODO: crash
|
|
|
|
if (view) {
|
|
if (view) {
|
|
layout->removeWidget(view);
|
|
layout->removeWidget(view);
|
|
delete view;
|
|
delete view;
|
|
@@ -97,9 +104,10 @@ void BlastOpePage::closeWebViewAndRestoreUI()
|
|
// 槽函数:处理 URL 改变事件
|
|
// 槽函数:处理 URL 改变事件
|
|
void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
if (newUrl.scheme() == "https" && newUrl.host() == "www.baidu.com") {
|
|
if (newUrl.scheme() == "https" && newUrl.host() == "www.baidu.com") {
|
|
|
|
+ LoadingWidget::showLoading(nullptr, "跳转验证页...");
|
|
closeWebViewAndRestoreUI();
|
|
closeWebViewAndRestoreUI();
|
|
QNetworkAccessManager manager;
|
|
QNetworkAccessManager manager;
|
|
- QUrl requestUrl(QString("http://192.168.0.255:8000/api/v1/h-face-verify/certifyId/%1").arg(certifyId));
|
|
|
|
|
|
+ QUrl requestUrl(g_url.resolved(QUrl(QString("h-face-verify/certifyId/%1").arg(certifyId))));
|
|
QNetworkRequest request(requestUrl);
|
|
QNetworkRequest request(requestUrl);
|
|
QNetworkReply *reply = manager.get(request);
|
|
QNetworkReply *reply = manager.get(request);
|
|
QEventLoop loop;
|
|
QEventLoop loop;
|
|
@@ -115,6 +123,7 @@ void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
QString message = dataObj["Message"].toString();
|
|
QString message = dataObj["Message"].toString();
|
|
QJsonObject resultObj = dataObj["ResultObject"].toObject();
|
|
QJsonObject resultObj = dataObj["ResultObject"].toObject();
|
|
if (resultObj.isEmpty()) {
|
|
if (resultObj.isEmpty()) {
|
|
|
|
+ Logger::getInstance().error(QString( "获取认证初始化数据失败. message: %1.").arg(message));
|
|
int ret = QMessageBox::information(nullptr, "提示", message+" ,请重新认证!");
|
|
int ret = QMessageBox::information(nullptr, "提示", message+" ,请重新认证!");
|
|
if (ret == QMessageBox::Ok) {
|
|
if (ret == QMessageBox::Ok) {
|
|
InitFace();
|
|
InitFace();
|
|
@@ -122,10 +131,10 @@ void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
} else {
|
|
} else {
|
|
QString passed = resultObj["Passed"].toString();
|
|
QString passed = resultObj["Passed"].toString();
|
|
if (passed == "T") {
|
|
if (passed == "T") {
|
|
- QMessageBox::information(nullptr, "提示", "操作成功!");
|
|
|
|
ui->setupUi(this);
|
|
ui->setupUi(this);
|
|
initPagination();
|
|
initPagination();
|
|
-
|
|
|
|
|
|
+ Logger::getInstance().info(QString("进入认证界面"));
|
|
|
|
+ LoadingWidget::hideLoading();
|
|
} else if (passed == "F") {
|
|
} else if (passed == "F") {
|
|
int ret = QMessageBox::critical(nullptr, "提示", "操作失败,请重新认证!");
|
|
int ret = QMessageBox::critical(nullptr, "提示", "操作失败,请重新认证!");
|
|
if (ret == QMessageBox::Ok) {
|
|
if (ret == QMessageBox::Ok) {
|
|
@@ -136,12 +145,12 @@ void BlastOpePage::onUrlChanged(const QUrl &newUrl) {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
qDebug() << "Request failed:" << reply->errorString();
|
|
qDebug() << "Request failed:" << reply->errorString();
|
|
|
|
+ Logger::getInstance().error(QString("InitFaseVerification request failed. error message: %1").arg(reply->errorString()));
|
|
}
|
|
}
|
|
|
|
|
|
reply->deleteLater();
|
|
reply->deleteLater();
|
|
|
|
+ LoadingWidget::hideLoading();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -199,8 +208,14 @@ void BlastOpePage::handleFeaturePermission(QWebEnginePage *page, const QUrl &sec
|
|
|
|
|
|
QJsonObject BlastOpePage::getMetaInfo() {
|
|
QJsonObject BlastOpePage::getMetaInfo() {
|
|
QJsonObject metaInfo;
|
|
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;
|
|
return metaInfo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -331,16 +346,16 @@ void BlastOpePage::loadDataFromSource(int currentPage, int pageSize)
|
|
progressBar2->setRange(0, 100); // 设置范围为0到100
|
|
progressBar2->setRange(0, 100); // 设置范围为0到100
|
|
progressBar2->setValue(0);
|
|
progressBar2->setValue(0);
|
|
progressBar2->setAlignment(Qt::AlignCenter);
|
|
progressBar2->setAlignment(Qt::AlignCenter);
|
|
- progressBar2->setStyleSheet("QProgressBar { border: 1px solid grey; border-radius: 5px; background-color: #EEEEEE; height: 20px; }"
|
|
|
|
- "QProgressBar::chunk { background-color: #05B8CC; width: 20px; margin: 0.5px; border - radius: 10px; }");
|
|
|
|
|
|
+ progressBar2->setStyleSheet("QProgressBar { border: 1px solid grey; border-radius: 5px; background-color: #EEEEEE; height: 10px; }"
|
|
|
|
+ "QProgressBar::chunk { background-color: #05B8CC; width: 2px; margin: 0.5px; border - radius: 10px; }");
|
|
progressBar2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
progressBar2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
|
QProgressBar *progressBar3 = new QProgressBar(ui->tableView);
|
|
QProgressBar *progressBar3 = new QProgressBar(ui->tableView);
|
|
progressBar3->setRange(0, 100); // 设置范围为0到100
|
|
progressBar3->setRange(0, 100); // 设置范围为0到100
|
|
progressBar3->setValue(0);
|
|
progressBar3->setValue(0);
|
|
progressBar3->setAlignment(Qt::AlignCenter);
|
|
progressBar3->setAlignment(Qt::AlignCenter);
|
|
- progressBar3->setStyleSheet("QProgressBar { border: 1px solid grey; border-radius: 5px; background-color: #EEEEEE; height: 20px; }"
|
|
|
|
- "QProgressBar::chunk { background-color: #05B8CC; width: 20px; margin: 0.5px; border - radius: 10px; }");
|
|
|
|
|
|
+ progressBar3->setStyleSheet("QProgressBar { border: 1px solid grey; border-radius: 5px; background-color: #EEEEEE; height: 10px; }"
|
|
|
|
+ "QProgressBar::chunk { background-color: #05B8CC; width: 2px; margin: 0.5px; border - radius: 10px; }");
|
|
progressBar3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
progressBar3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
|
progressBars.append(ProgressBarTriple(progressBar1, progressBar2,progressBar3));
|
|
progressBars.append(ProgressBarTriple(progressBar1, progressBar2,progressBar3));
|