123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626 |
- #include "wxAnswer.h"
- #include "ui_wxAnswer.h"
- #include "CAppInfo.h"
- #include "awMsgBox.h"
- #include "CQREncode.h"
- #include "awMsgBox.h"
- #include <QDesktopWidget>
- #include "CAudioPlayerProc.h"
- #include <QFile>
- #include <QFileInfo>
- #include <QSettings>
- wxAnswer::wxAnswer(QString sAnswerType, int nOrder, QWidget *parent) :
- CBaseWidget(parent),
- ui(new Ui::wxAnswer), m_nOrder(nOrder), m_sAnswerType(sAnswerType)
- {
- ui->setupUi(this);
- setStyleSheet(g_appInfoPtr->m_sQssStr);
- qRegisterMetaType<CGetWXQrCode>("CGetWXQrCode");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetWXQrCode, this, &wxAnswer::onGetWXQrCode);
- qRegisterMetaType<CSaveUploadedFileAcknowledgeStatus>("CSaveUploadedFileAcknowledgeStatus");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnSaveUploadedFileAcknowledgeStatus, this, &wxAnswer::onSaveUploadedFileAcknowledgeStatus);
- qRegisterMetaType<CDownLoadFileInfo>("CDownLoadFileInfo");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnDownLoadFile, this, &wxAnswer::onDownLoadFile);
- if (g_websocketPtr == nullptr)
- {
- g_websocketPtr = std::make_shared<CWebsocketProc>();
- }
- if(!g_websocketPtr->isConnected())
- {
- g_websocketPtr->open(QString("wss://%1:%2/api/ws/fileAnswer")
- .arg(g_appInfoPtr->m_sHttpServer).arg(g_appInfoPtr->m_sHttpPort),
- g_httpBllPtr->getToken(), g_httpBllPtr->getKey());
- }
- connect(g_websocketPtr.get(), &CWebsocketProc::mobileStatus, this, &wxAnswer::onMobileStatus);
- connect(g_websocketPtr.get(), &CWebsocketProc::fileAnswer, this, &wxAnswer::onFileAnswer);
- // if(m_picList == nullptr)
- // {
- // if(m_picList == nullptr)
- // {
- // m_picList = std::make_shared<wPictureList>(g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*10, ui->widget_wxa);
- // }
- // connect(m_picList.get(), &wPictureList::picChange, this, [&](){
- // int nHeight = m_picList->setUI(g_appInfoPtr->m_fRate*30, ui->label_wxa_qrcode->y() + ui->label_wxa_qrcode->height() + g_appInfoPtr->m_fRate*20,
- // ui->widget_wxa->width() - g_appInfoPtr->m_fRate*30*2);
- // ui->btn_wxa_comfirm->setGeometry((ui->widget_wxa->width() - g_appInfoPtr->m_fRate*120)/2, m_picList->y() + m_picList->height() + g_appInfoPtr->m_fRate*30,
- // g_appInfoPtr->m_fRate*120, g_appInfoPtr->m_fRate*40);
- // ui->widget_wxa->setGeometry((width() - g_appInfoPtr->m_fRate*760)/2, (height() - (ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate*30))/2,
- // g_appInfoPtr->m_fRate*760, ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate*30);
- // m_picList->show();
- // if(m_picList->itemCount() > 5)
- // {
- // ui->label_wxa_qrcode->setVisible(false);
- // }
- // else
- // {
- // ui->label_wxa_qrcode->setVisible(true);
- // }
- // });
- // }
- CHttpRequestPackage hrp;
- hrp.sUri = "/api/ecs_oe_student/examControl/getQrCode";
- hrp.nRequestType = RequestType::rtGetWXQrCode;
- Json::Value jBody = Json::Value::null;
- jBody["examRecordDataId"] = g_appInfoPtr->m_oExamInfo.nExamRecordDataId;
- jBody["order"] = nOrder;
- if(sAnswerType == "SINGLE_AUDIO")
- {
- jBody["transferFileType"] = "AUDIO";
- }
- else
- {
- jBody["transferFileType"] = "PIC";
- }
- jBody["testEnv"] = false;
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(jBody.toStyledString().c_str()));
- hrp.eParamType = HttpParamType::hptCustomBody;
- g_httpBllPtr->post(hrp);
- QFileInfo file("coe.cfgi");
- QString sFilePath = file.absoluteFilePath();
- QSettings set(sFilePath, QSettings::IniFormat);
- m_nPlayVol = set.value("config/playVol", 100).toInt();
- ui->hslider_etvt_volume->setValue(m_nPlayVol);
- if (g_audioPalyerPtr == nullptr)
- {
- g_audioPalyerPtr = std::make_shared<CAudioPlayerProc>();
- }
- m_pTimer = std::make_shared<QTimer>();
- m_pTimer->setInterval(1000);
- connect(m_pTimer.get(), &QTimer::timeout, this, [&]() {
- ui->hslider_etvt_voice->setValue(ui->hslider_etvt_voice->value() + 1);
- if (ui->hslider_etvt_voice->value() >= m_nAudioSecord)
- {
- m_pTimer->stop();
- g_audioPalyerPtr->stopPlay();
- }
- else
- {
- std::string sDeciceName = "";
- if (!g_audioPalyerPtr->getDeviceinfo(sDeciceName))
- {
- m_pTimer->stop();
- QString sErrorStr = g_audioPalyerPtr->getErrMsg();
- ShowMsg(sErrorStr, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- if (sDeciceName != m_sRecordDevice)
- {
- ShowMsg(QString::fromLocal8Bit("播放设备拔出,请检查设备!"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // myDebug()<<QString::fromLocal8Bit("播放设备拔出,请检查设备!");
- }
- }
- });
-
- }
- wxAnswer::~wxAnswer()
- {
- QFileInfo file("coe.cfgi");
- QString sFilePath = file.absoluteFilePath();
- QSettings set(sFilePath, QSettings::IniFormat);
-
- set.setValue("config/playVol", m_nPlayVol);
- delete ui;
- }
- int wxAnswer::setUI(const int nWidth)
- {
- if(m_sAnswerType == "SINGLE_AUDIO")
- {
- ui->label_wxa_title->setVisible(false);
- ui->btn_wxa_close->setVisible(false);
- ui->label_HLine->setVisible(false);
- ui->btn_wxa_comfirm->setVisible(false);
- setGeometry(0, 0, nWidth, g_appInfoPtr->m_fRate*340);
- ui->widget_bg->setGeometry(0, 0, width(), height());
- ui->widget_wxa->setGeometry(0, 0, width(), height());
- ui->label_wxa_qrcode->setGeometry(0, 0,
- g_appInfoPtr->m_fRate*180, g_appInfoPtr->m_fRate*180);
- ui->label_wxa_tips->setFixedWidth(g_appInfoPtr->m_fRate*490);
- ui->label_wxa_tips->setText(QString::fromLocal8Bit(R"(<html>
- <style>
- p{
- font-family: "Microsoft YaHei";
- font-size: %1px;
- font-weight: 400;
- color: #717171;
- }
- span
- {
- font-family: Microsoft YaHei;
- font-size: %2px;
- font-weight: 400;
- color: #13BA8C;
- }
- </style>
- <body>
- <p>
- 请使用<span>微信</span>扫描二维码后,在微信小程序上录音,并上传文件。
- </p>
- <p>
- 上传期间,请勿关闭二维码。
- </p>
- </body>
- </html>
- )").arg((int)(g_appInfoPtr->m_fRate*24)).arg((int)(g_appInfoPtr->m_fRate*24)));
- ui->label_wxa_tips->adjustSize();
- ui->label_wxa_tips->setGeometry(ui->label_wxa_qrcode->x() + ui->label_wxa_qrcode->width() + g_appInfoPtr->m_fRate*30,
- ui->label_wxa_qrcode->y(), g_appInfoPtr->m_fRate*490, ui->label_wxa_tips->height());
- ui->label_wxa_statusIcon->setGeometry(ui->label_wxa_tips->x(), ui->label_wxa_tips->y() + ui->label_wxa_tips->height() + g_appInfoPtr->m_fRate*30,
- g_appInfoPtr->m_fRate*28, g_appInfoPtr->m_fRate*28);
- ui->label_wxa_status->setFixedWidth(g_appInfoPtr->m_fRate*490);
- ui->label_wxa_status->adjustSize();
- ui->label_wxa_status->setGeometry(ui->label_wxa_statusIcon->x() + ui->label_wxa_statusIcon->width() + g_appInfoPtr->m_fRate*10,
- ui->label_wxa_statusIcon->y() + (ui->label_wxa_statusIcon->height() - ui->label_wxa_status->height())/2,
- ui->label_wxa_status->width(), ui->label_wxa_status->height());
- ui->label_wxa_answerTips->adjustSize();
- ui->label_wxa_answerTips->setGeometry(ui->label_wxa_qrcode->x(), ui->label_wxa_qrcode->y() + ui->label_wxa_qrcode->height() + g_appInfoPtr->m_fRate*20,
- ui->label_wxa_answerTips->width(), ui->label_wxa_answerTips->height());
- ui->widget_etvt_voice->setVisible(false);
- ui->widget_etvt_voice->setGeometry(ui->label_wxa_answerTips->x() + ui->label_wxa_answerTips->width() + g_appInfoPtr->m_fRate*10,
- ui->label_wxa_answerTips->y(),
- g_appInfoPtr->m_fRate*423, g_appInfoPtr->m_fRate*40);
- ui->btn_etvt_play->setGeometry(g_appInfoPtr->m_fRate*8, (ui->widget_etvt_voice->height() - g_appInfoPtr->m_fRate*24)/2,
- g_appInfoPtr->m_fRate*24, g_appInfoPtr->m_fRate*24);
- ui->hslider_etvt_voice->setGeometry(ui->btn_etvt_play->x() + ui->btn_etvt_play->width() + g_appInfoPtr->m_fRate*21,
- (ui->widget_etvt_voice->height() - g_appInfoPtr->m_fRate*16)/2,
- g_appInfoPtr->m_fRate*224, g_appInfoPtr->m_fRate*12);
- ui->btn_etvt_volume->setGeometry(ui->hslider_etvt_voice->x() + ui->hslider_etvt_voice->width() + g_appInfoPtr->m_fRate*20,
- ui->btn_etvt_play->y(), ui->btn_etvt_play->width(), ui->btn_etvt_play->height());
- ui->hslider_etvt_volume->setGeometry(ui->btn_etvt_volume->x() + ui->btn_etvt_volume->width() + g_appInfoPtr->m_fRate * 10, ui->hslider_etvt_voice->y(),
- g_appInfoPtr->m_fRate*50, ui->hslider_etvt_voice->height());
- }
- else
- {
- if(m_picList == nullptr)
- {
- if(m_picList == nullptr)
- {
- m_picList = std::make_shared<wPictureList>(g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*10, ui->widget_wxa);
- }
- connect(m_picList.get(), &wPictureList::picChange, this, [&](){
- int nHeight = m_picList->setUI(g_appInfoPtr->m_fRate*30, ui->label_wxa_qrcode->y() + ui->label_wxa_qrcode->height() + g_appInfoPtr->m_fRate*20,
- ui->widget_wxa->width() - g_appInfoPtr->m_fRate*30*2);
- ui->btn_wxa_comfirm->setGeometry((ui->widget_wxa->width() - g_appInfoPtr->m_fRate*120)/2, m_picList->y() + m_picList->height() + g_appInfoPtr->m_fRate*30,
- g_appInfoPtr->m_fRate*120, g_appInfoPtr->m_fRate*40);
- ui->widget_wxa->setGeometry((width() - g_appInfoPtr->m_fRate*760)/2, (height() - (ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate*30))/2,
- g_appInfoPtr->m_fRate*760, ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate*30);
- m_picList->show();
- if(m_picList->itemCount() > 5)
- {
- ui->label_wxa_qrcode->setVisible(false);
- }
- else
- {
- ui->label_wxa_qrcode->setVisible(true);
- }
- });
- }
- ui->widget_bg->setStyleSheet(QString(R"(QWidget#widget_bg
- {
- background:rgba(89,89,89,0.8);
- })"));
- ui->widget_wxa->setStyleSheet(QString(R"(QWidget#widget_wxa
- {
- border-radius:%1px;
- background:rgba(255,255,255,1);
- })").arg((int)(g_appInfoPtr->m_fRate*16)));
-
- ui->label_wxa_answerTips->setVisible(false);
- ui->widget_etvt_voice->setVisible(false);
- ui->btn_etvt_play->setVisible(false);
- ui->hslider_etvt_voice->setVisible(false);
- ui->btn_etvt_volume->setVisible(false);
- QDesktopWidget *dekwiget = QApplication::desktop();
- setGeometry(0, 0, dekwiget->width(), dekwiget->height());
- ui->widget_bg->setGeometry(0, 0, width(), height());
- ui->widget_wxa->setGeometry((width() - g_appInfoPtr->m_fRate*760)/2, (height() - g_appInfoPtr->m_fRate*395)/2, g_appInfoPtr->m_fRate*760, g_appInfoPtr->m_fRate*395);
- ui->label_wxa_title->adjustSize();
- ui->label_wxa_title->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*16,
- ui->label_wxa_title->width(), ui->label_wxa_title->height());
- ui->btn_wxa_close->setGeometry(ui->widget_wxa->width() - g_appInfoPtr->m_fRate*(20+16), g_appInfoPtr->m_fRate*19, g_appInfoPtr->m_fRate*16, g_appInfoPtr->m_fRate*16);
- ui->label_HLine->setGeometry(0, g_appInfoPtr->m_fRate*54, ui->widget_wxa->width(), g_appInfoPtr->m_fRate*1 < 1 ? 1 : g_appInfoPtr->m_fRate*1);
- ui->label_wxa_qrcode->setGeometry(g_appInfoPtr->m_fRate*30, ui->label_HLine->y() + ui->label_HLine->height() + g_appInfoPtr->m_fRate*30,
- g_appInfoPtr->m_fRate*180, g_appInfoPtr->m_fRate*180);
- ui->label_wxa_tips->setFixedWidth(g_appInfoPtr->m_fRate*490);
- ui->label_wxa_tips->setText(QString::fromLocal8Bit(R"(<html>
- <style>
- p{
- font-family: "Microsoft YaHei";
- font-size: %1px;
- font-weight: 400;
- color: #717171;
- }
- span
- {
- font-family: Microsoft YaHei;
- font-size: %2px;
- font-weight: 400;
- color: #13BA8C;
- }
- </style>
- <body>
- <p>
- 请使用<span>微信</span>扫描二维码后,在微信小程序上拍照,并上传文件。
- </p>
- <p>
- 上传期间,请勿关闭二维码(图片上传最多支持6张)。
- </p>
- </body>
- </html>
- )").arg((int)(g_appInfoPtr->m_fRate*24)).arg((int)(g_appInfoPtr->m_fRate*24)));
- ui->label_wxa_tips->adjustSize();
- ui->label_wxa_tips->setGeometry(ui->label_wxa_qrcode->x() + ui->label_wxa_qrcode->width() + g_appInfoPtr->m_fRate*30,
- ui->label_wxa_qrcode->y(), g_appInfoPtr->m_fRate*490, ui->label_wxa_tips->height());
- ui->label_wxa_statusIcon->setGeometry(ui->label_wxa_tips->x(), ui->label_wxa_tips->y() + ui->label_wxa_tips->height() + g_appInfoPtr->m_fRate*20,
- g_appInfoPtr->m_fRate*28, g_appInfoPtr->m_fRate*28);
- ui->label_wxa_status->setFixedWidth(g_appInfoPtr->m_fRate*490);
- ui->label_wxa_status->adjustSize();
- ui->label_wxa_status->setGeometry(ui->label_wxa_statusIcon->x() + ui->label_wxa_statusIcon->width() + g_appInfoPtr->m_fRate*10,
- ui->label_wxa_statusIcon->y() + (ui->label_wxa_statusIcon->height() - ui->label_wxa_status->height())/2,
- ui->label_wxa_status->width(), ui->label_wxa_status->height());
- ui->btn_wxa_comfirm->setGeometry((ui->widget_wxa->width() - g_appInfoPtr->m_fRate*120)/2, ui->widget_wxa->height() - g_appInfoPtr->m_fRate*(30 + 40),
- g_appInfoPtr->m_fRate*120, g_appInfoPtr->m_fRate*40);
- }
- ui->label_wxa_statusIcon->setVisible(false);
- ui->label_wxa_status->setVisible(false);
- return height();
- }
- void wxAnswer::onGetWXQrCode(CGetWXQrCode getWXQrCode)
- {
- if (getWXQrCode.nCode == 200)
- {
- ui->label_wxa_qrcode->setPixmap(CQREncode::GenerateQRcode(QString("%1%2")
- .arg(getWXQrCode.sUrl).arg(QByteArray(("&apiServer=" + g_httpBllPtr->getHttpUrl()).toLocal8Bit()).toPercentEncoding().data()), ui->label_wxa_qrcode->width()));
- }
- else
- {
- if(getWXQrCode.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("获取二维码失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- else
- {
- ShowMsg(getWXQrCode.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- }
- }
- QString wxAnswer::getFileUrl()
- {
- return m_sFileUrl;
- }
- void wxAnswer::setPics(QString sFileUrls)
- {
- if (sFileUrls.isEmpty())
- {
- return;
- }
- m_sFileUrl = sFileUrls;
- if(m_picList == nullptr)
- {
- m_picList = std::make_shared<wPictureList>(g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*10, ui->widget_wxa);
- }
- m_picList->clearPic();
- if (!sFileUrls.isEmpty())
- {
- QStringList fileList = sFileUrls.split(",");
- for (QString sFile : fileList)
- {
- m_picList->AddPic(sFile);
- }
- }
- int nHeight = m_picList->setUI(g_appInfoPtr->m_fRate * 30, ui->label_wxa_qrcode->y() + ui->label_wxa_qrcode->height() + g_appInfoPtr->m_fRate * 20,
- ui->widget_wxa->width() - g_appInfoPtr->m_fRate * 30 * 2);
- ui->btn_wxa_comfirm->setGeometry((ui->widget_wxa->width() - g_appInfoPtr->m_fRate * 120) / 2, m_picList->y() + m_picList->height() + g_appInfoPtr->m_fRate * 30,
- g_appInfoPtr->m_fRate * 120, g_appInfoPtr->m_fRate * 40);
- ui->widget_wxa->setGeometry((width() - g_appInfoPtr->m_fRate * 760) / 2, (height() - (ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate * 30)) / 2,
- g_appInfoPtr->m_fRate * 760, ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate * 30);
-
-
- m_picList->show();
- }
- void wxAnswer::onMobileStatus(__int64 nExamRecordDataId, int nOrder, QString sScanStatus)
- {
- if (sScanStatus == "SCANNED" && nOrder == m_nOrder)
- {
- ui->label_wxa_statusIcon->setVisible(true);
- ui->label_wxa_status->setVisible(true);
- ui->label_wxa_status->setText(QString::fromLocal8Bit("已扫码"));
- }
- }
- void wxAnswer::onFileAnswer(__int64 nExamRecordDataId, int nOrder, QString sFileType, QString sFileUrl)
- {
- if(nOrder == m_nOrder)
- {
-
- CHttpRequestPackage hrp;
- hrp.sUri = "/api/ecs_oe_student/examControl/saveUploadedFileAcknowledgeStatus";
- hrp.nRequestType = RequestType::rtSaveUploadedFileAcknowledgeStatus;
- Json::Value jBody = Json::Value::null;
- jBody["examRecordDataId"] = nExamRecordDataId;
- jBody["order"] = nOrder;
- jBody["filePath"] = sFileUrl.toStdString();
- jBody["acknowledgeStatus"] = "CONFIRMED";
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(jBody.toStyledString().c_str()));
- hrp.sCommonStr = sFileUrl;
- hrp.eParamType = HttpParamType::hptCustomBody;
- g_httpBllPtr->post(hrp);
- if(m_sAnswerType == "SINGLE_AUDIO")
- {
- m_sFileUrl = sFileUrl;
- {
- QString sFileName = sFileUrl.right(sFileUrl.length() - sFileUrl.lastIndexOf("/") - 1);
- sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
- CHttpRequestPackage hrp;
- hrp.sUri = sFileUrl;
- hrp.sCommonStr = sFileName;
- hrp.sCommonStr1 = __FILE__;
- hrp.nRequestType = RequestType::rtDownLoadFile;
- hrp.nRetryCount = 3;
- g_httpBllPtr->downLoad(hrp);
- }
- }
- else
- {
- if(m_picList == nullptr)
- {
- m_picList = std::make_shared<wPictureList>(g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*10, ui->widget_wxa);
- }
- QStringList fileList;
- if(!sFileUrl.isEmpty())
- {
- fileList = sFileUrl.split(",");
- for (QString sFile : fileList)
- {
- m_picList->AddPic(sFile);
- }
- }
- if(m_picList->itemCount() > 5)
- {
- ui->label_wxa_qrcode->setVisible(false);
- }
- int nHeight = m_picList->setUI(g_appInfoPtr->m_fRate*30, ui->label_wxa_qrcode->y() + ui->label_wxa_qrcode->height() + g_appInfoPtr->m_fRate*20,
- ui->widget_wxa->width() - g_appInfoPtr->m_fRate*30*2);
- ui->btn_wxa_comfirm->setGeometry((ui->widget_wxa->width() - g_appInfoPtr->m_fRate*120)/2, m_picList->y() + m_picList->height() + g_appInfoPtr->m_fRate*30,
- g_appInfoPtr->m_fRate*120, g_appInfoPtr->m_fRate*40);
- ui->widget_wxa->setGeometry((width() - g_appInfoPtr->m_fRate*760)/2, (height() - (ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate*30))/2,
- g_appInfoPtr->m_fRate*760, ui->btn_wxa_comfirm->y() + ui->btn_wxa_comfirm->height() + g_appInfoPtr->m_fRate*30);
-
- m_picList->show();
- }
- ui->label_wxa_status->setText(QString::fromLocal8Bit("已上传"));
- ShowMsg(QString::fromLocal8Bit("小程序作答已更新"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_information);
- }
- }
- void wxAnswer::onSaveUploadedFileAcknowledgeStatus(CSaveUploadedFileAcknowledgeStatus saveUploadedFileAcknowledgeStatus)
- {
- if (saveUploadedFileAcknowledgeStatus.nCode == 200)
- {
- if(m_sFileUrl == saveUploadedFileAcknowledgeStatus.sFileUrl)
- {
- if(m_sAnswerType == "SINGLE_AUDIO")
- {
- emit audioAnswered(m_sFileUrl);
- }
- /* else
- {
- emit picConfirm(m_sFileUrl);
- }*/
- }
- }
- else
- {
- if(saveUploadedFileAcknowledgeStatus.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("保存答案信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- else
- {
- ShowMsg(saveUploadedFileAcknowledgeStatus.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- }
- }
- void wxAnswer::setAnswer(QString sAnswer)
- {
- if (!sAnswer.isEmpty())
- {
- m_sFileUrl = sAnswer;
- QString sFileName = m_sFileUrl.right(m_sFileUrl.length() - m_sFileUrl.lastIndexOf("/") - 1);
- sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
- CHttpRequestPackage hrp;
- hrp.sUri = m_sFileUrl;
- hrp.sCommonStr = sFileName;
- hrp.sCommonStr1 = __FILE__;
- hrp.nRequestType = RequestType::rtDownLoadFile;
- hrp.nRetryCount = 3;
- g_httpBllPtr->downLoad(hrp);
- }
- }
- int wxAnswer::widgetType()
- {
- return wt_WXAnswer;
- }
- void wxAnswer::onDownLoadFile(CDownLoadFileInfo downLoadFileInfo)
- {
- QString sFileName = m_sFileUrl.right(m_sFileUrl.length() - m_sFileUrl.lastIndexOf("/") - 1);
- sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
- if (downLoadFileInfo.sFileName == sFileName &&
- downLoadFileInfo.sModuleName == __FILE__)
- {
- if (downLoadFileInfo.nCode == 200)
- {
- ui->label_wxa_answerTips->setText(QString::fromLocal8Bit("考生答案:"));
- ui->label_wxa_answerTips->adjustSize();
- ui->label_wxa_answerTips->setGeometry(ui->label_wxa_qrcode->x(), ui->label_wxa_qrcode->y() + ui->label_wxa_qrcode->height() + g_appInfoPtr->m_fRate*20,
- ui->label_wxa_answerTips->width(), ui->label_wxa_answerTips->height());
- ui->widget_etvt_voice->setVisible(true);
- ui->widget_etvt_voice->setGeometry(ui->label_wxa_answerTips->x() + ui->label_wxa_answerTips->width() + g_appInfoPtr->m_fRate*10,
- ui->label_wxa_answerTips->y(),
- g_appInfoPtr->m_fRate*423, g_appInfoPtr->m_fRate*40);
- }
- else
- {
- if(downLoadFileInfo.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("下载失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- else
- {
- ShowMsg(downLoadFileInfo.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- }
- }
- }
- void wxAnswer::on_btn_wxa_close_clicked()
- {
- emit exit();
- }
- void wxAnswer::on_btn_wxa_comfirm_clicked()
- {
- if (m_picList == nullptr)
- {
- emit exit();
- return;
- }
- m_sFileUrl = m_picList->getFileUrls();
- int nCount = m_sFileUrl.split(",").count();
- if(nCount > 6)
- {
- ShowMsg(QString::fromLocal8Bit("请删除多余的图片,图片总数不应该超过6张!"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- return;
- }
- emit picConfirm(m_sFileUrl);
- /* CHttpRequestPackage hrp;
- hrp.sUri = "/api/ecs_oe_student/examControl/saveUploadedFileAcknowledgeStatus";
- hrp.nRequestType = RequestType::rtSaveUploadedFileAcknowledgeStatus;
- Json::Value jBody = Json::Value::null;
- jBody["examRecordDataId"] = g_appInfoPtr->m_oExamInfo.nExamRecordDataId;
- jBody["order"] = m_nOrder;
- jBody["filePath"] = m_sFileUrl.toStdString();
- jBody["acknowledgeStatus"] = "CONFIRMED";
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(jBody.toStyledString().c_str()));
- hrp.sCommonStr = m_sFileUrl;
- hrp.eParamType = HttpParamType::hptCustomBody;
- g_httpBllPtr->post(hrp);*/
- }
- void wxAnswer::on_btn_etvt_play_clicked()
- {
- QString sFileName = m_sFileUrl.right(m_sFileUrl.length() - m_sFileUrl.lastIndexOf("/") - 1);
- sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
- if (QFile::exists(sFileName))
- {
- m_nAudioSecord = g_audioPalyerPtr->GetMediaDuration(sFileName);
- ui->hslider_etvt_voice->setMaximum(m_nAudioSecord);
- ui->hslider_etvt_voice->setValue(0);
- g_audioPalyerPtr->setVol(m_nPlayVol);
- if (!g_audioPalyerPtr->getDeviceinfo(m_sRecordDevice))
- {
- m_pTimer->stop();
- QString sErrorStr = g_audioPalyerPtr->getErrMsg();
- ShowMsg(sErrorStr, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- g_audioPalyerPtr->playAudio(sFileName);
- m_pTimer->start();
- }
- }
- void wxAnswer::on_hslider_etvt_volume_valueChanged(int value)
- {
- m_nPlayVol = value;
- if (m_pTimer && m_pTimer->isActive())
- {
- g_audioPalyerPtr->setVol(m_nPlayVol);
- }
- }
- void wxAnswer::on_btn_etvt_volume_clicked()
- {
- if(m_bMute)
- {
- ui->btn_etvt_volume->setStyleSheet("border-image:url(:/images/btn-etvt-volume.png);");
- ui->hslider_etvt_volume->setValue(m_nLastVol);
- }
- else
- {
- ui->btn_etvt_volume->setStyleSheet("border-image:url(:/images/btn-etvt-mute.png);");
- m_nLastVol = ui->hslider_etvt_volume->value();
- ui->hslider_etvt_volume->setValue(0);
- }
- m_bMute = !m_bMute;
- }
|