courseList.cpp 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  1. #include "courseList.h"
  2. #include "ui_courseList.h"
  3. #include "awMsgBox.h"
  4. #include <QDesktopWidget>
  5. #include <QMouseEvent>
  6. #include "CAppInfo.h"
  7. #include "CSqlite3DBProc.h"
  8. courseList::courseList(QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::courseList)
  11. {
  12. ui->setupUi(this);
  13. setWindowFlags(Qt::FramelessWindowHint);
  14. setStyleSheet(g_appInfoPtr->m_sQssStr);
  15. ui->btn_minisize->setVisible(!g_appInfoPtr->m_bFullScreenTop);
  16. qRegisterMetaType<CGetStudentInfoBySession>("CGetStudentInfoBySession");
  17. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetStudentInfoBySession, this, &courseList::onGetStudentInfoBySession);
  18. qRegisterMetaType<CSpecialtyNameList>("CSpecialtyNameList");
  19. connect(g_httpBllPtr.get(), &CHttpBll::sgnSpecialtyNameList, this, &courseList::onSpecialtyNameList);
  20. qRegisterMetaType<CCheckExamInProgress>("CCheckExamInProgress");
  21. connect(g_httpBllPtr.get(), &CHttpBll::sgnCheckExamInProgress, this, &courseList::onCheckExamInProgress);
  22. qRegisterMetaType<CGetStudentClientMenu>("CGetStudentClientMenu");
  23. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetStudentClientMenu, this, &courseList::onGetStudentClientMenu);
  24. qRegisterMetaType<CGetUserNoticeList>("CGetUserNoticeList");
  25. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetUserNoticeList, this, &courseList::onGetUserNoticeList);
  26. qRegisterMetaType<CDownLoadFileInfo>("CDownLoadFileInfo");
  27. connect(g_httpBllPtr.get(), &CHttpBll::sgnDownLoadFile, this, &courseList::onDownLoadFile);
  28. qRegisterMetaType<CAppDownLoadUrl>("CAppDownLoadUrl");
  29. connect(g_httpBllPtr.get(), &CHttpBll::sgnAppDownLoadUrl, this, &courseList::onAppDownLoadUrl);
  30. qRegisterMetaType<CStartExamLimit>("CStartExamLimit");
  31. connect(g_httpBllPtr.get(), &CHttpBll::sgnStartExamLimit, this, &courseList::onStartExamLimit);
  32. qRegisterMetaType<CIpLimit>("CIpLimit");
  33. connect(g_httpBllPtr.get(), &CHttpBll::sgnIpLimit, this, &courseList::onIpLimit);
  34. qRegisterMetaType<CGetExamProperty>("CGetExamProperty");
  35. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamProperty, this, &courseList::onGetExamProperty);
  36. qRegisterMetaType<CFaceCheckEnabled>("CFaceCheckEnabled");
  37. connect(g_httpBllPtr.get(), &CHttpBll::sgnFaceCheckEnabled, this, &courseList::onFaceCheckEnabled);
  38. qRegisterMetaType<CLivenessEnabled>("CLivenessEnabled");
  39. connect(g_httpBllPtr.get(), &CHttpBll::sgnLivenessEnabled, this, &courseList::onLivenessEnabled);
  40. qRegisterMetaType<CEndExam>("CEndExam");
  41. connect(g_httpBllPtr.get(), &CHttpBll::sgnEndExam, this, &courseList::onEndExam);
  42. qRegisterMetaType<CGetOrgPropertiesByGroupWithoutCache>("CGetOrgPropertiesByGroupWithoutCache");
  43. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetOrgPropertiesByGroupWithoutCache, this, &courseList::onGetOrgPropertiesByGroupWithoutCache);
  44. qRegisterMetaType<CSkipFaceCheckParam>("CSkipFaceCheckParam");
  45. connect(g_httpBllPtr.get(), &CHttpBll::sgnSkipFaceCheckParam, this, &courseList::onSkipFaceCheckParam);
  46. sqlite3_stmt *stmt;
  47. QString sSql = QString("select agreement from t_agreement where student_id=%1")
  48. .arg(g_appInfoPtr->m_nStudentId);
  49. if (!g_sysDBProcPtr->QuerySql(sSql.toStdString(), &stmt))
  50. {
  51. ShowMsg(QString::fromLocal8Bit("加载隐私协议信息失败!"), this, MSG_ICON_TYPE::mit_error);
  52. }
  53. bool bAgreement = false;
  54. int nField = 0;
  55. g_sysDBProcPtr->BeginGetFields(stmt);
  56. if (!g_sysDBProcPtr->Eof())
  57. {
  58. if (g_sysDBProcPtr->GetFields(0, nField, stmt) == 1)
  59. {
  60. bAgreement = true;
  61. }
  62. }
  63. g_sysDBProcPtr->EndGetFields(stmt);
  64. if (!bAgreement)
  65. {
  66. if (m_pPrivacyWidget == nullptr)
  67. {
  68. m_pPrivacyWidget = std::make_shared<privacyWidget>(this);
  69. connect(m_pPrivacyWidget.get(), &privacyWidget::agreement, this, [&]() {
  70. m_pPrivacyWidget.reset();
  71. getStudentInfoBySession();
  72. });
  73. connect(m_pPrivacyWidget.get(), &privacyWidget::disAgreement, this, [&]() {
  74. on_btn_exit_clicked();
  75. });
  76. }
  77. m_pPrivacyWidget->show();
  78. }
  79. else
  80. {
  81. getStudentInfoBySession();
  82. }
  83. initUI();
  84. m_pMobileLogin = nullptr;
  85. m_pStudentInfo = nullptr;
  86. m_pMobileLoginBtnTimer = std::make_shared<QTimer>();
  87. m_pMobileLoginBtnTimer->setInterval(500);
  88. connect(m_pMobileLoginBtnTimer.get(), &QTimer::timeout, this, &courseList::hideMobileLoginBtn);
  89. m_pStudentInfoBtnTimer = std::make_shared<QTimer>();
  90. m_pStudentInfoBtnTimer->setInterval(500);
  91. connect(m_pStudentInfoBtnTimer.get(), &QTimer::timeout, this, &courseList::hideStudentInfoBtn);
  92. m_pServerTime = std::make_shared<QTimer>();
  93. m_pServerTime->setInterval(1000);
  94. connect(m_pServerTime.get(), &QTimer::timeout, this, [&]() {
  95. ui->label_serverTime->adjustSize();
  96. ui->label_serverTime->setText(QString::fromLocal8Bit("服务器时间:%1")
  97. .arg(QDateTime::fromMSecsSinceEpoch(g_appInfoPtr->serverMTime()).toString("yyyy-MM-dd hh:mm:ss")));
  98. });
  99. m_pServerTime->start();
  100. m_pRefreshMenuTimer = std::make_shared<QTimer>();
  101. m_pRefreshMenuTimer->setInterval(1000 * 60 * 3);
  102. connect(m_pRefreshMenuTimer.get(), &QTimer::timeout, this, []() {
  103. CHttpRequestPackage hrp;
  104. hrp.sUri = "/api/ecs_core/rolePrivilege/getStudentClientMenu";
  105. hrp.nRequestType = RequestType::rtGetStudentClientMenu;
  106. hrp.sParamList.push_back(QString::fromLocal8Bit("rootOrgId,%1").arg(g_appInfoPtr->m_sRootOrgId));
  107. g_httpBllPtr->get(hrp);
  108. });
  109. m_pOnlineTimer = std::make_shared<QTimer>();
  110. m_pOnlineTimer->setInterval(1000*60*3);
  111. connect(m_pOnlineTimer.get(), &QTimer::timeout, this, []() {
  112. CHttpRequestPackage hrp1;
  113. hrp1.sUri = "/api/ecs_core/student/online_signal/" + QString::number(g_appInfoPtr->m_nStudentId);
  114. hrp1.nRequestType = RequestType::rtOnlineSignal;
  115. g_httpBllPtr->get(hrp1);
  116. });
  117. ui->btn_mobileLogin->installEventFilter(this);
  118. ui->btn_studentInfo->installEventFilter(this);
  119. m_pOnlineTimer->start();
  120. m_pRefreshMenuTimer->start();
  121. if (!g_appInfoPtr->m_sMenuLogoUrl.isEmpty())
  122. {
  123. QString sFileName = g_appInfoPtr->m_sMenuLogoUrl.right(g_appInfoPtr->m_sMenuLogoUrl.length() - g_appInfoPtr->m_sMenuLogoUrl.lastIndexOf("/") - 1);
  124. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  125. CHttpRequestPackage hrp;
  126. hrp.sUri = g_appInfoPtr->m_sMenuLogoUrl;
  127. hrp.sCommonStr = sFileName;
  128. hrp.sCommonStr1 = __FILE__;
  129. hrp.sAdditionStr = "MenuLogoUrl";
  130. hrp.nRequestType = RequestType::rtDownLoadFile;
  131. hrp.nRetryCount = 3;
  132. g_httpBllPtr->downLoad(hrp);
  133. }
  134. else
  135. {
  136. ui->label_cl_org_icon->setPixmap(QPixmap(":/images/qm-logo.png").scaled(ui->label_cl_org_icon->width(), ui->label_cl_org_icon->height(),
  137. Qt::KeepAspectRatio, Qt::SmoothTransformation));
  138. }
  139. }
  140. courseList::~courseList()
  141. {
  142. awMsgBox::clear(this);
  143. delete ui;
  144. }
  145. void courseList::initUI()
  146. {
  147. QDesktopWidget *dekwiget = QApplication::desktop();
  148. setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  149. ui->label_cl_company->setVisible(false);
  150. ui->widget_cl_BG->setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  151. ui->widget_menu->setGeometry(0, 0, g_appInfoPtr->m_fRate*96, height());
  152. ui->widget_top->setGeometry(ui->widget_menu->width(), 0, width() - ui->widget_menu->width(), g_appInfoPtr->m_fRate*56);
  153. ui->widget_bottom->setGeometry(ui->widget_top->x(), height() - g_appInfoPtr->m_fRate*38, ui->widget_top->width(), g_appInfoPtr->m_fRate*38);
  154. ui->stw_courseList->setGeometry(ui->widget_top->x(), ui->widget_top->y() + ui->widget_top->height(),
  155. ui->widget_top->width(), height() - ui->widget_top->height() - ui->widget_bottom->height());
  156. /*
  157. clOnlineExam *cloe = new clOnlineExam;
  158. cloe->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  159. ui->stw_courseList->addWidget(cloe);
  160. clOnlineHomework *clow = new clOnlineHomework;
  161. clow->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  162. ui->stw_courseList->addWidget(clow);
  163. clOnlinePractice *clop = new clOnlinePractice;
  164. clop->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  165. ui->stw_courseList->addWidget(clop);
  166. clOfflineExam *cloffe = new clOfflineExam;
  167. cloffe->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  168. ui->stw_courseList->addWidget(cloffe);
  169. clNoticeList *clnl = new clNoticeList;
  170. clnl->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  171. ui->stw_courseList->addWidget(clnl);
  172. clEditPassword *clep = new clEditPassword;
  173. clep->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  174. ui->stw_courseList->addWidget(clep);
  175. ui->stw_courseList->setCurrentIndex(0);
  176. */
  177. ui->label_cl_org_icon->setGeometry(g_appInfoPtr->m_fRate*15, g_appInfoPtr->m_fRate*15, g_appInfoPtr->m_fRate*66, g_appInfoPtr->m_fRate*66);
  178. ui->btn_onlineExam->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*103, g_appInfoPtr->m_fRate*56, g_appInfoPtr->m_fRate*66);
  179. ui->btn_onlineHomework->setGeometry(ui->btn_onlineExam->x(), ui->btn_onlineExam->y() + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate*17,
  180. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  181. ui->btn_onlinePractice->setGeometry(ui->btn_onlineExam->x(), ui->btn_onlineHomework->y() + ui->btn_onlineHomework->height() + g_appInfoPtr->m_fRate*17,
  182. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  183. ui->btn_offlineExam->setGeometry(ui->btn_onlineExam->x(), ui->btn_onlinePractice->y() + ui->btn_onlinePractice->height() + g_appInfoPtr->m_fRate*17,
  184. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  185. ui->btn_notice->setGeometry(ui->btn_onlineExam->x(), ui->btn_offlineExam->y() + ui->btn_offlineExam->height() + g_appInfoPtr->m_fRate*17,
  186. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  187. ui->btn_noticeNum->setGeometry(ui->btn_notice->x() + ui->btn_notice->width() - g_appInfoPtr->m_fRate*16, ui->btn_notice->y(),
  188. g_appInfoPtr->m_fRate*16, g_appInfoPtr->m_fRate*16);
  189. ui->btn_noticeNum->setVisible(false);
  190. ui->btn_editPassword->setGeometry(ui->btn_onlineExam->x(), ui->btn_notice->y() + ui->btn_notice->height() + g_appInfoPtr->m_fRate*17,
  191. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  192. ui->label_currentPlaceIcon->setGeometry(g_appInfoPtr->m_fRate*30, (ui->widget_top->height() - g_appInfoPtr->m_fRate*10)/2,
  193. g_appInfoPtr->m_fRate*10, g_appInfoPtr->m_fRate*10);
  194. ui->label_currrentPlace->adjustSize();
  195. ui->label_currrentPlace->setGeometry(ui->label_currentPlaceIcon->x() + ui->label_currentPlaceIcon->width() + g_appInfoPtr->m_fRate*10,
  196. (ui->widget_top->height() - ui->label_currrentPlace->height())/2, g_appInfoPtr->m_fRate*400, ui->label_currrentPlace->height());
  197. ui->btn_cl_close->setGeometry(ui->widget_top->width() - g_appInfoPtr->m_fRate*10 - g_appInfoPtr->m_fRate*24, g_appInfoPtr->m_fRate*16,
  198. g_appInfoPtr->m_fRate*24, g_appInfoPtr->m_fRate*24);
  199. ui->btn_minisize->setGeometry(ui->btn_cl_close->x() - g_appInfoPtr->m_fRate*6 - ui->btn_cl_close->width(), ui->btn_cl_close->y(),
  200. ui->btn_cl_close->width(), ui->btn_cl_close->height());
  201. ui->label_VLine->setGeometry(ui->btn_minisize->x() - g_appInfoPtr->m_fRate*21, ui->btn_cl_close->y(),
  202. g_appInfoPtr->m_fRate*1 < 1 ? 1 : g_appInfoPtr->m_fRate*1, g_appInfoPtr->m_fRate*24);
  203. ui->btn_exit->setGeometry(ui->label_VLine->x() - g_appInfoPtr->m_fRate*(20+24), ui->btn_cl_close->y(),
  204. ui->btn_cl_close->width(), ui->btn_cl_close->height());
  205. ui->btn_studentInfo->setGeometry(ui->btn_exit->x() - g_appInfoPtr->m_fRate*(10+90), ui->btn_cl_close->y(),
  206. g_appInfoPtr->m_fRate*90, g_appInfoPtr->m_fRate*24);
  207. ui->btn_studentInfo->setIconSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  208. ui->btn_studentInfo->setIcon(QIcon(":/images/icon-student-info.png"));
  209. ui->label_arrow->setGeometry(ui->btn_studentInfo->x() + (ui->btn_studentInfo->width() - g_appInfoPtr->m_fRate*12)/2,
  210. ui->btn_studentInfo->y() + ui->btn_studentInfo->height(),
  211. g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*3);
  212. ui->label_arrow->setVisible(false);
  213. ui->btn_mobileLogin->setGeometry(ui->btn_studentInfo->x() - g_appInfoPtr->m_fRate*(10+167), ui->btn_cl_close->y(),
  214. g_appInfoPtr->m_fRate*167, g_appInfoPtr->m_fRate*24);
  215. ui->btn_mobileLogin->setIconSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  216. ui->btn_mobileLogin->setIcon(QIcon(":/images/icon-mobile-login.png"));
  217. ui->label_cl_company->adjustSize();
  218. ui->label_cl_company->setGeometry(g_appInfoPtr->m_fRate*30, (ui->widget_bottom->height() - ui->label_cl_company->height())/2,
  219. ui->label_cl_company->width(), ui->label_cl_company->height());
  220. ui->label_cl_version->adjustSize();
  221. ui->label_cl_version->setGeometry(ui->widget_bottom->width() - g_appInfoPtr->m_fRate*30 - ui->label_cl_version->width(),
  222. ui->label_cl_company->y(), ui->label_cl_version->width(), ui->label_cl_version->height());
  223. ui->label_serverTime->setText(QString::fromLocal8Bit("服务器时间:%1")
  224. .arg(QDateTime::fromMSecsSinceEpoch(g_appInfoPtr->serverMTime()).toString("yyyy-MM-dd hh:mm:ss")));
  225. ui->label_serverTime->adjustSize();
  226. ui->label_serverTime->setGeometry(ui->label_cl_version->x() - g_appInfoPtr->m_fRate*20 - ui->label_serverTime->width(), ui->label_cl_company->y(),
  227. ui->label_serverTime->width(), ui->label_serverTime->height());
  228. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_exam);
  229. }
  230. void courseList::menuBtnRePosistion()
  231. {
  232. int nTop = g_appInfoPtr->m_fRate * 103;
  233. if(ui->btn_onlineExam->isVisible())
  234. {
  235. ui->btn_onlineExam->setGeometry(g_appInfoPtr->m_fRate * 20, nTop, g_appInfoPtr->m_fRate * 56, g_appInfoPtr->m_fRate * 66);
  236. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  237. }
  238. if(ui->btn_onlineHomework->isVisible())
  239. {
  240. ui->btn_onlineHomework->setGeometry(ui->btn_onlineExam->x(), nTop,
  241. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  242. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  243. }
  244. if (ui->btn_onlinePractice->isVisible())
  245. {
  246. ui->btn_onlinePractice->setGeometry(ui->btn_onlineExam->x(), nTop,
  247. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  248. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  249. }
  250. if (ui->btn_offlineExam->isVisible())
  251. {
  252. ui->btn_offlineExam->setGeometry(ui->btn_onlineExam->x(), nTop,
  253. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  254. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  255. }
  256. if (ui->btn_notice->isVisible())
  257. {
  258. ui->btn_notice->setGeometry(ui->btn_onlineExam->x(), nTop,
  259. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  260. ui->btn_noticeNum->setGeometry(ui->btn_notice->x() + ui->btn_notice->width() - g_appInfoPtr->m_fRate * 16, ui->btn_notice->y(),
  261. g_appInfoPtr->m_fRate * 16, g_appInfoPtr->m_fRate * 16);
  262. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  263. }
  264. if (ui->btn_editPassword->isVisible())
  265. {
  266. ui->btn_editPassword->setGeometry(ui->btn_onlineExam->x(), ui->btn_notice->y() + ui->btn_notice->height() + g_appInfoPtr->m_fRate * 17,
  267. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  268. }
  269. }
  270. void courseList::on_btn_minisize_clicked()
  271. {
  272. emit minisize();
  273. }
  274. void courseList::on_btn_cl_close_clicked()
  275. {
  276. // logout();
  277. // close();
  278. // QCoreApplication::quit();
  279. qApp->exit();
  280. }
  281. void courseList::setCheck(COURSE_MENU_BTN_TYPE cmbt)
  282. {
  283. QString sNormalSheet = QString(R"(outline:none;
  284. font-size:%1px;
  285. font-family:"Microsoft YaHei";
  286. font-weight:400;
  287. color:rgba(255,255,255,0.4);
  288. background:rgba(255,255,255,0);
  289. border-radius:%2;)").arg((int)(g_appInfoPtr->m_fRate*12)).arg(g_appInfoPtr->m_fRate*12);
  290. QString sCheckSheet = QString(R"(QPushButton
  291. {
  292. outline:none;
  293. font-size:%1px;
  294. font-family:"Microsoft YaHei";
  295. font-weight:400;
  296. color:rgba(255,255,255,1);
  297. border-radius:%2px;
  298. background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(16, 195, 182, 1), stop:1 rgba(39, 217, 146, 1));
  299. })").arg((int)(g_appInfoPtr->m_fRate*12)).arg(g_appInfoPtr->m_fRate*12);
  300. ui->btn_onlineExam->setStyleSheet(sNormalSheet);
  301. ui->btn_onlineHomework->setStyleSheet(sNormalSheet);
  302. ui->btn_onlinePractice->setStyleSheet(sNormalSheet);
  303. ui->btn_offlineExam->setStyleSheet(sNormalSheet);
  304. ui->btn_notice->setStyleSheet(sNormalSheet);
  305. ui->btn_editPassword->setStyleSheet(sNormalSheet);
  306. if (m_pOnlineExam != nullptr)
  307. {
  308. m_pOnlineExam->hide();
  309. }
  310. if (m_pOnlineHomework != nullptr)
  311. {
  312. m_pOnlineHomework->hide();
  313. }
  314. if (m_pOnlinePractice != nullptr)
  315. {
  316. m_pOnlinePractice->hide();
  317. m_pOnlinePractice->releaseClopResult();
  318. }
  319. if (m_pClopReport != nullptr)
  320. {
  321. m_pClopReport->hide();
  322. }
  323. if (m_pOfflineExam != nullptr)
  324. {
  325. m_pOfflineExam->hide();
  326. }
  327. if (m_pNoticeList != nullptr)
  328. {
  329. m_pNoticeList->hide();
  330. }
  331. if (m_pEditPassword != nullptr)
  332. {
  333. m_pEditPassword->hide();
  334. }
  335. QString sCurrentPlace = "";
  336. if (cmbt == COURSE_MENU_BTN_TYPE::cmbt_online_exam)
  337. {
  338. if (m_pOnlineExam == nullptr)
  339. {
  340. m_pOnlineExam = std::make_shared<clOnlineExam>(ui->stw_courseList);
  341. m_pOnlineExam->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  342. connect(m_pOnlineExam.get(), &clOnlineExam::enterExam, this, &courseList::onEnterExam);
  343. }
  344. m_pOnlineExam->show();
  345. ui->btn_onlineExam->setStyleSheet(sCheckSheet);
  346. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:在线考试");
  347. }
  348. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_online_homework)
  349. {
  350. if (m_pOnlineHomework == nullptr)
  351. {
  352. m_pOnlineHomework = std::make_shared<clOnlineHomework>(ui->stw_courseList);
  353. m_pOnlineHomework->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  354. connect(m_pOnlineHomework.get(), &clOnlineHomework::enterExam, this, &courseList::onEnterExam);
  355. }
  356. m_pOnlineHomework->show();
  357. ui->btn_onlineHomework->setStyleSheet(sCheckSheet);
  358. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:在线作业");
  359. }
  360. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_online_practice)
  361. {
  362. if (m_pOnlinePractice == nullptr)
  363. {
  364. m_pOnlinePractice = std::make_shared<clOnlinePractice>(ui->stw_courseList);
  365. m_pOnlinePractice->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  366. connect(m_pOnlinePractice.get(), &clOnlinePractice::enterExam, this, &courseList::onEnterExam);
  367. }
  368. m_pOnlinePractice->show();
  369. ui->btn_onlinePractice->setStyleSheet(sCheckSheet);
  370. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:在线练习");
  371. }
  372. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_offline_exam)
  373. {
  374. if (m_pOfflineExam == nullptr)
  375. {
  376. m_pOfflineExam = std::make_shared<clOfflineExam>(ui->stw_courseList);
  377. m_pOfflineExam->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  378. }
  379. m_pOfflineExam->show();
  380. ui->btn_offlineExam->setStyleSheet(sCheckSheet);
  381. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:离线考试");
  382. }
  383. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_notice)
  384. {
  385. if (m_pNoticeList == nullptr)
  386. {
  387. m_pNoticeList = std::make_shared<clNoticeList>(ui->stw_courseList);
  388. m_pNoticeList->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  389. }
  390. m_pNoticeList->show();
  391. ui->btn_notice->setStyleSheet(sCheckSheet);
  392. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:公告通知");
  393. }
  394. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_edit_password)
  395. {
  396. if (m_pEditPassword == nullptr)
  397. {
  398. m_pEditPassword = std::make_shared<clEditPassword>(ui->stw_courseList);
  399. m_pEditPassword->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  400. }
  401. m_pEditPassword->show();
  402. ui->btn_editPassword->setStyleSheet(sCheckSheet);
  403. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:修改密码");
  404. }
  405. ui->label_currrentPlace->setText(sCurrentPlace);
  406. }
  407. void courseList::onEnterExam(CL_OPERATION_TYPE cot, __int64 nExamId, __int64 nExamStudentId, QString sCourseCode, QString sCourseName)
  408. {
  409. if(cot == CL_OPERATION_TYPE::cot_online_exam)
  410. {
  411. g_appInfoPtr->m_oExamInfo.sExamType = EXAM_TYPES::ONLINE;
  412. }
  413. g_appInfoPtr->m_oExamInfo.nExamId = nExamId;
  414. g_appInfoPtr->m_oExamInfo.nExamStudentId = nExamStudentId;
  415. g_appInfoPtr->m_oExamInfo.sCourseCode = sCourseCode;
  416. g_appInfoPtr->m_oExamInfo.sCourseName = sCourseName;
  417. //开考限流
  418. m_nRetryCount = 0;
  419. CHttpRequestPackage hrp;
  420. hrp.sUri = QString("https://tcc.qmth.com.cn/rate_limit/prod/startExam/%1").arg(100);
  421. hrp.nRequestType = RequestType::rtStartExamLimit;
  422. g_httpBllPtr->getUrl(hrp);
  423. }
  424. void courseList::onStartExamLimit(CStartExamLimit startExamLimit)
  425. {
  426. if (startExamLimit.nCode == 200)
  427. {
  428. ++m_nRetryCount;
  429. if (startExamLimit.bPass)
  430. {
  431. CHttpRequestPackage hrp;
  432. hrp.sUri = QString("/api/ecs_exam_work/exam/ipLimit/%1").arg(g_appInfoPtr->m_oExamInfo.nExamId);
  433. hrp.nRequestType = RequestType::rtIpLimit;
  434. g_httpBllPtr->get(hrp);
  435. }
  436. else
  437. {
  438. //重试
  439. if(m_nRetryCount >= 3)
  440. {
  441. ShowMsg(QString::fromLocal8Bit("系统繁忙,请稍后重试"), this, MSG_ICON_TYPE::mit_error);
  442. }
  443. else
  444. {
  445. QTimer::singleShot(3*1000, this, [](){
  446. CHttpRequestPackage hrp;
  447. hrp.sUri = QString("https://tcc.qmth.com.cn/rate_limit/prod/startExam/%1").arg(100);
  448. hrp.nRequestType = RequestType::rtStartExamLimit;
  449. g_httpBllPtr->getUrl(hrp);
  450. });
  451. }
  452. }
  453. }
  454. else
  455. {
  456. ShowMsg(QString::fromLocal8Bit("开考失败"), this, MSG_ICON_TYPE::mit_error);
  457. }
  458. }
  459. void courseList::onIpLimit(CIpLimit ipLimit)
  460. {
  461. if (ipLimit.nCode == 200)
  462. {
  463. if (!ipLimit.bLimited)
  464. {
  465. //断点
  466. CHttpRequestPackage hrp;
  467. hrp.sUri = "/api/ecs_oe_student/client/exam/process/checkExamInProgress";
  468. hrp.nRequestType = RequestType::rtCheckExamInProgress;
  469. hrp.sCommonStr = EXAM_INPROGRESS_ENTER_TYPE::EIET_ENTER_EXAM;
  470. g_httpBllPtr->post(hrp);
  471. }
  472. else
  473. {
  474. ShowMsg(QString::fromLocal8Bit("当前ip限制参加考试"), this, MSG_ICON_TYPE::mit_error);
  475. }
  476. }
  477. else
  478. {
  479. ShowMsg(QString::fromLocal8Bit("开考失败"), this, MSG_ICON_TYPE::mit_error);
  480. }
  481. }
  482. void courseList::onGetExamProperty(CGetExamProperty getExamProperty)
  483. {
  484. if (getExamProperty.nCode == 200)
  485. {
  486. if (getExamProperty.sType == "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE,FACE_VERIFY_FORCE_EXIT")
  487. {
  488. g_appInfoPtr->m_oExamInfo.bIsFaceCheck = getExamProperty.bIsFaceCheck;
  489. // g_appInfoPtr->m_oExamInfo.nFaceThreshold = getExamProperty.nFaceThreshold;
  490. g_appInfoPtr->m_oExamInfo.nSnapshotInterval = getExamProperty.nSnapshotInterval;
  491. g_appInfoPtr->m_oExamInfo.nFaceVerifyStartMinute = getExamProperty.nFaceVerifyStartMinute;
  492. g_appInfoPtr->m_oExamInfo.nFaceVerifyEndMinute = getExamProperty.nFaceVerifyEndMinute;
  493. g_appInfoPtr->m_oExamInfo.bIsStrangerEnable = getExamProperty.bIsStrangerEnable;
  494. g_appInfoPtr->m_oExamInfo.bIsLivenessBefore = getExamProperty.bIsLivenessBefore;
  495. g_appInfoPtr->m_bInprogressFaceLivenessFailedForceExit = getExamProperty.bFaceVerifyForceExit;
  496. if (getExamProperty.bCheckEnvironment && !g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  497. {
  498. if(m_pWhetherEnvTest == nullptr)
  499. {
  500. m_pWhetherEnvTest = std::make_shared<etWhetherEnvTest>(this);
  501. connect(m_pWhetherEnvTest.get(), &etWhetherEnvTest::envTest, this, [&](){
  502. m_pWhetherEnvTest.reset();
  503. //环境检测
  504. if (m_pEnvironmentalTest == nullptr)
  505. {
  506. m_pEnvironmentalTest = std::make_shared<environmentalTest>(this);
  507. connect(m_pEnvironmentalTest.get(), &environmentalTest::enterExam, this, [&](){
  508. m_pEnvironmentalTest.reset();
  509. //人脸识别
  510. CHttpRequestPackage hrp;
  511. hrp.sUri = QString("/api/ecs_exam_work/exam/faceCheckEnabled/%1")
  512. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  513. hrp.nRequestType = RequestType::rtFaceCheckEnabled;
  514. g_httpBllPtr->get(hrp);
  515. });
  516. }
  517. m_pEnvironmentalTest->show();
  518. });
  519. connect(m_pWhetherEnvTest.get(), &etWhetherEnvTest::skipEnvTest, this, [&](){
  520. m_pWhetherEnvTest.reset();
  521. //人脸识别
  522. CHttpRequestPackage hrp;
  523. hrp.sUri = QString("/api/ecs_exam_work/exam/faceCheckEnabled/%1")
  524. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  525. hrp.nRequestType = RequestType::rtFaceCheckEnabled;
  526. g_httpBllPtr->get(hrp);
  527. });
  528. }
  529. m_pWhetherEnvTest->show();
  530. }
  531. else
  532. {
  533. //人脸识别
  534. CHttpRequestPackage hrp;
  535. hrp.sUri = QString("/api/ecs_exam_work/exam/faceCheckEnabled/%1")
  536. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  537. hrp.nRequestType = RequestType::rtFaceCheckEnabled;
  538. g_httpBllPtr->get(hrp);
  539. }
  540. }
  541. }
  542. else
  543. {
  544. if(getExamProperty.sMessage.isEmpty())
  545. {
  546. ShowMsg(QString::fromLocal8Bit("获取考试信息失败"), this, MSG_ICON_TYPE::mit_error);
  547. }
  548. else
  549. {
  550. ShowMsg(getExamProperty.sMessage, this);
  551. }
  552. }
  553. }
  554. void courseList::onFaceCheckEnabled(CFaceCheckEnabled faceCheckEnabled)
  555. {
  556. if (faceCheckEnabled.nCode == 200)
  557. {
  558. //人脸检测
  559. g_appInfoPtr->m_oExamInfo.bFaceCheck = faceCheckEnabled.bEnabled;
  560. // if (faceCheckEnabled.bEnabled && !g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  561. // {
  562. // if (g_appInfoPtr->m_sStudentPhotoPath.isEmpty())
  563. // {
  564. // ShowMsg(QString::fromLocal8Bit("本场考试需要进行人脸检测,但是您没有上传底照,请联系老师"), this, MSG_ICON_TYPE::mit_error);
  565. // return;
  566. // }
  567. // if (m_pFaceCompare == nullptr)
  568. // {
  569. // m_pFaceCompare = std::make_shared<faceCompare>(this);
  570. // connect(m_pFaceCompare.get(), &faceCompare::exitFaceCompare, this, [&]() {
  571. // m_pFaceCompare.reset();
  572. // });
  573. // connect(m_pFaceCompare.get(), &faceCompare::faceComparePass, this, [&]() {
  574. // m_pFaceCompare.reset();
  575. // //活体检测
  576. // CHttpRequestPackage hrp;
  577. // hrp.sUri = QString("/api/ecs_exam_work/exam/identificationOfLivingEnabled/%1")
  578. // .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  579. // hrp.nRequestType = RequestType::rtLivenessEnabled;
  580. // g_httpBllPtr->get(hrp);
  581. // });
  582. // }
  583. // m_pFaceCompare->show();
  584. // }
  585. // else
  586. {
  587. //活体检测
  588. CHttpRequestPackage hrp;
  589. hrp.sUri = QString("/api/ecs_exam_work/exam/identificationOfLivingEnabled/%1")
  590. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  591. hrp.nRequestType = RequestType::rtLivenessEnabled;
  592. g_httpBllPtr->get(hrp);
  593. }
  594. }
  595. else
  596. {
  597. if(faceCheckEnabled.sMessage.isEmpty())
  598. {
  599. ShowMsg(QString::fromLocal8Bit("获取人脸识别信息失败"), this, MSG_ICON_TYPE::mit_error);
  600. }
  601. else
  602. {
  603. ShowMsg(faceCheckEnabled.sMessage, this, MSG_ICON_TYPE::mit_error);
  604. }
  605. }
  606. }
  607. void courseList::doFaceCompare()
  608. {
  609. if (g_appInfoPtr->m_sStudentPhotoPath.isEmpty())
  610. {
  611. ShowMsg(QString::fromLocal8Bit("本场考试需要进行人脸检测,但是您没有上传底照,请联系老师"), this, MSG_ICON_TYPE::mit_error);
  612. return;
  613. }
  614. if (m_pFaceCompare == nullptr)
  615. {
  616. m_pFaceCompare = std::make_shared<faceCompare>(this);
  617. connect(m_pFaceCompare.get(), &faceCompare::exitFaceCompare, this, [&]() {
  618. m_pFaceCompare.reset();
  619. });
  620. connect(m_pFaceCompare.get(), &faceCompare::faceComparePass, this, [&]() {
  621. m_pFaceCompare.reset();
  622. //进入待考
  623. enterWaitExam();
  624. });
  625. }
  626. m_pFaceCompare->show();
  627. }
  628. void courseList::onLivenessEnabled(CLivenessEnabled livenessEnabled)
  629. {
  630. if (livenessEnabled.nCode == 200)
  631. {
  632. g_appInfoPtr->m_oExamInfo.bLivenessCheck = livenessEnabled.bEnabled;
  633. GetOrgPropertiesByGroupWithoutCache();
  634. //进入待考
  635. // enterWaitExam();
  636. }
  637. else
  638. {
  639. if(livenessEnabled.sMessage.isEmpty())
  640. {
  641. ShowMsg(QString::fromLocal8Bit("获取活体信息失败"), this, MSG_ICON_TYPE::mit_error);
  642. }
  643. else
  644. {
  645. ShowMsg(livenessEnabled.sMessage, this, MSG_ICON_TYPE::mit_error);
  646. }
  647. }
  648. }
  649. void courseList::doLiveness()
  650. {
  651. //活体检测
  652. if(m_pFaceLiveness == nullptr)
  653. {
  654. m_pFaceLiveness = std::make_shared<faceLiveness>(FACE_LIVENESS_TYPE::flt_entry_exam, this);
  655. connect(m_pFaceLiveness.get(), &faceLiveness::faceLivenessFaild, this, [&](){
  656. g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = 0;
  657. m_pFaceLiveness.reset();
  658. });
  659. connect(m_pFaceLiveness.get(), &faceLiveness::faceLivenessSucceed, this, [&](){
  660. g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = 0;
  661. m_pFaceLiveness.reset();
  662. //进入待考
  663. enterWaitExam();
  664. });
  665. m_pFaceLiveness->show();
  666. }
  667. }
  668. void courseList::GetOrgPropertiesByGroupWithoutCache()
  669. {
  670. CHttpRequestPackage hrp;
  671. hrp.sUri = QString("/api/ecs_core/org/getOrgPropertiesByGroupWithoutCache/%1/config4Edit1")
  672. .arg(g_appInfoPtr->m_sRootOrgId);
  673. hrp.nRequestType = RequestType::rtGetOrgPropertiesByGroupWithoutCache;
  674. g_httpBllPtr->get(hrp);
  675. }
  676. void courseList::onGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache orgProperties)
  677. {
  678. if(orgProperties.nCode == 200)
  679. {
  680. m_nRetryCount = 0;
  681. g_appInfoPtr->m_oExamInfo.nActionNum = orgProperties.nActionNum;
  682. g_appInfoPtr->m_oExamInfo.sActionOptions = orgProperties.sActionOptions;
  683. g_appInfoPtr->m_oExamInfo.sActionOrder = orgProperties.sActionOrder;
  684. g_appInfoPtr->m_oExamInfo.nActionDuration = orgProperties.nActionDuration;
  685. g_appInfoPtr->m_oExamInfo.nActionAlert = orgProperties.nActionAlert;
  686. g_appInfoPtr->m_oExamInfo.nAllActionDuration = orgProperties.nAllActionDuration;
  687. g_appInfoPtr->m_oExamInfo.nFaceThreshold = orgProperties.nFaceThreshold;
  688. if(!g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  689. {
  690. if((g_appInfoPtr->m_oExamInfo.bIsLivenessBefore && g_appInfoPtr->m_oExamInfo.bIsFaceCheck) ||
  691. g_appInfoPtr->m_oExamInfo.bFaceCheck)
  692. {
  693. //获取是否跳过人脸识别参数
  694. getSkipFaceCheckParam();
  695. }
  696. else
  697. {
  698. enterWaitExam();
  699. }
  700. }
  701. else
  702. {
  703. enterWaitExam();
  704. }
  705. }
  706. else
  707. {
  708. if(orgProperties.sMessage.isEmpty())
  709. {
  710. ShowMsg(QString::fromLocal8Bit("获取活体信息失败"), this, MSG_ICON_TYPE::mit_error);
  711. }
  712. else
  713. {
  714. ShowMsg(orgProperties.sMessage, this, MSG_ICON_TYPE::mit_error);
  715. }
  716. }
  717. }
  718. void courseList::onSkipFaceCheckParam(CSkipFaceCheckParam skipFaceCheckParam)
  719. {
  720. if(skipFaceCheckParam.nCode == 200)
  721. {
  722. g_appInfoPtr->m_bSkipFaceCheck = skipFaceCheckParam.bSkipFaceCheck;
  723. if(g_appInfoPtr->m_oExamInfo.bIsLivenessBefore && g_appInfoPtr->m_oExamInfo.bIsFaceCheck && !g_appInfoPtr->m_bSkipFaceCheck)
  724. {
  725. doLiveness();
  726. }
  727. else
  728. {
  729. doFaceCompare();
  730. }
  731. }
  732. else
  733. {
  734. if(skipFaceCheckParam.sMessage.isEmpty())
  735. {
  736. ShowMsg(QString::fromLocal8Bit("获取人脸参数失败"), this, MSG_ICON_TYPE::mit_error);
  737. }
  738. else
  739. {
  740. ShowMsg(skipFaceCheckParam.sMessage, this, MSG_ICON_TYPE::mit_error);
  741. }
  742. }
  743. }
  744. void courseList::getSkipFaceCheckParam()
  745. {
  746. CHttpRequestPackage hrp;
  747. hrp.sUri = QString("/api/ecs_exam_work/exam/skip/face/check") ;
  748. hrp.sParamList.push_back(QString("examId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamId));
  749. hrp.sParamList.push_back(QString("examStudentId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamStudentId));
  750. hrp.nRequestType = RequestType::rtSkipFaceCheckParam;
  751. hrp.eParamType = HttpParamType::hptUrl;
  752. g_httpBllPtr->post(hrp);
  753. }
  754. void courseList::enterWaitExam()
  755. {
  756. //进入待考
  757. if (m_pBackground == nullptr)
  758. {
  759. if (g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  760. {
  761. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_answerWidget, this);
  762. m_pResumeExam.reset();
  763. }
  764. else
  765. {
  766. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_waitExam, this);
  767. }
  768. connect(m_pBackground.get(), &awBackground::minisize, this, &courseList::minisize);
  769. connect(m_pBackground.get(), &awBackground::closeWidget, this, [&](){
  770. m_pBackground.reset();
  771. m_pRefreshMenuTimer->start();
  772. if(m_pOnlineExam)
  773. {
  774. m_pOnlineExam->refreshExam();
  775. }
  776. if(m_pOnlineHomework)
  777. {
  778. m_pOnlineHomework->refreshExam();
  779. }
  780. });
  781. connect(m_pBackground.get(), &awBackground::gobackLogin, this, [&](){
  782. m_pBackground.reset();
  783. logout();
  784. close();
  785. });
  786. connect(m_pBackground.get(), &awBackground::showPracticeInfo, this, [&](){
  787. m_pBackground.reset();
  788. CPracticeRecord pr;
  789. pr.nId = g_appInfoPtr->m_oExamInfo.nExamRecordDataId;
  790. pr.sCourseCode = g_appInfoPtr->m_oExamInfo.sCourseCode;
  791. pr.sCourseName = g_appInfoPtr->m_oExamInfo.sCourseName;
  792. if(m_pClopReport == nullptr)
  793. {
  794. m_pClopReport = std::make_shared<clopReport>(pr, true, ui->stw_courseList);
  795. connect(m_pClopReport.get(), &clopReport::goback, this, [&](){
  796. m_pClopReport.reset();
  797. if(m_pOnlinePractice)
  798. {
  799. m_pOnlinePractice->refreshExamInfo();
  800. }
  801. });
  802. m_pClopReport->setUI(0, 0, ui->stw_courseList->width(), ui->stw_courseList->height());
  803. }
  804. m_pClopReport->show();
  805. m_pRefreshMenuTimer->start();
  806. });
  807. }
  808. m_pBackground->show();
  809. m_pRefreshMenuTimer->stop();
  810. }
  811. void courseList::on_btn_onlineExam_clicked()
  812. {
  813. ui->stw_courseList->setCurrentIndex(0);
  814. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_exam);
  815. }
  816. void courseList::on_btn_onlineHomework_clicked()
  817. {
  818. ui->stw_courseList->setCurrentIndex(1);
  819. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_homework);
  820. }
  821. void courseList::on_btn_onlinePractice_clicked()
  822. {
  823. ui->stw_courseList->setCurrentIndex(2);
  824. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_practice);
  825. }
  826. void courseList::on_btn_offlineExam_clicked()
  827. {
  828. ui->stw_courseList->setCurrentIndex(3);
  829. setCheck(COURSE_MENU_BTN_TYPE::cmbt_offline_exam);
  830. }
  831. void courseList::on_btn_notice_clicked()
  832. {
  833. ui->stw_courseList->setCurrentIndex(4);
  834. setCheck(COURSE_MENU_BTN_TYPE::cmbt_notice);
  835. }
  836. void courseList::on_btn_editPassword_clicked()
  837. {
  838. ui->stw_courseList->setCurrentIndex(5);
  839. setCheck(COURSE_MENU_BTN_TYPE::cmbt_edit_password);
  840. }
  841. void courseList::on_btn_exit_clicked()
  842. {
  843. logout();
  844. close();
  845. }
  846. void courseList::logout()
  847. {
  848. CHttpRequestPackage hrp;
  849. hrp.sUri = "/api/ecs_core/auth/logout";
  850. hrp.nRequestType = RequestType::rtLogout;
  851. g_httpBllPtr->get(hrp);
  852. }
  853. bool courseList::eventFilter(QObject *obj, QEvent *ev)
  854. {
  855. if(ev->type() == QEvent::Enter)
  856. {
  857. if(obj == ui->btn_mobileLogin)
  858. {
  859. m_pMobileLoginBtnTimer->stop();
  860. if(m_pStudentInfo != nullptr)
  861. {
  862. m_pStudentInfo.reset();
  863. m_pStudentInfo = nullptr;
  864. }
  865. if(m_pMobileLogin == nullptr)
  866. {
  867. m_pMobileLogin = std::make_shared<clMobileLogin>(this);
  868. m_pMobileLogin->setUI(g_appInfoPtr->m_fRate*838, g_appInfoPtr->m_fRate*53, g_appInfoPtr->m_fRate*240, g_appInfoPtr->m_fRate*290);
  869. m_pMobileLogin->show();
  870. m_pMobileLogin->installEventFilter(this);
  871. }
  872. ui->btn_mobileLogin->setIcon(QIcon(":/images/icon-mobile-login-hover.png"));
  873. }
  874. else if(obj == ui->btn_studentInfo)
  875. {
  876. m_pStudentInfoBtnTimer->stop();
  877. if(m_pMobileLogin != nullptr)
  878. {
  879. m_pMobileLogin.reset();
  880. m_pMobileLogin = nullptr;
  881. }
  882. if(m_pStudentInfo == nullptr)
  883. {
  884. m_pStudentInfo = std::make_shared<clStudentInfo>(this);
  885. connect(m_pStudentInfo.get(), &clStudentInfo::sgnStudentLogout, this, [&]() {
  886. on_btn_exit_clicked();
  887. });
  888. connect(m_pStudentInfo.get(), &clStudentInfo::sgnStudentEditPassword, this, [&]() {
  889. if (m_pStudentInfo != nullptr)
  890. {
  891. m_pStudentInfo.reset();
  892. }
  893. on_btn_editPassword_clicked();
  894. });
  895. m_pStudentInfo->setUI(g_appInfoPtr->m_fRate*838, g_appInfoPtr->m_fRate*53, g_appInfoPtr->m_fRate*330, g_appInfoPtr->m_fRate*240);
  896. m_pStudentInfo->show();
  897. m_pStudentInfo->installEventFilter(this);
  898. }
  899. ui->btn_studentInfo->setIcon(QIcon(":/images/icon-student-info-hover.png"));
  900. }
  901. else if(obj == m_pMobileLogin.get())
  902. {
  903. m_pMobileLoginBtnTimer->stop();
  904. }
  905. else if(obj == m_pStudentInfo.get())
  906. {
  907. m_pStudentInfoBtnTimer->stop();
  908. }
  909. }
  910. else if(ev->type() == QEvent::Leave)
  911. {
  912. if(obj == ui->btn_mobileLogin || obj == m_pMobileLogin.get())
  913. {
  914. ui->btn_mobileLogin->setIcon(QIcon(":/images/icon-mobile-login.png"));
  915. m_pMobileLoginBtnTimer->start();
  916. }
  917. if(obj == ui->btn_studentInfo || obj == m_pStudentInfo.get())
  918. {
  919. ui->btn_studentInfo->setIcon(QIcon(":/images/icon-student-info.png"));
  920. m_pStudentInfoBtnTimer->start();
  921. }
  922. }
  923. return QWidget::eventFilter(obj, ev);
  924. }
  925. void courseList::hideStudentInfoBtn()
  926. {
  927. if(m_pStudentInfo != nullptr)
  928. {
  929. m_pStudentInfo.reset();
  930. }
  931. }
  932. void courseList::hideMobileLoginBtn()
  933. {
  934. if(m_pMobileLogin != nullptr)
  935. {
  936. m_pMobileLogin.reset();
  937. }
  938. }
  939. void courseList::getStudentInfoBySession()
  940. {
  941. CHttpRequestPackage hrp;
  942. hrp.sUri = "/api/ecs_core/student/getStudentInfoBySession";
  943. hrp.nRequestType = RequestType::rtGetStudentInfoBySession;
  944. hrp.nRetryCount = 3;
  945. g_httpBllPtr->get(hrp);
  946. }
  947. void courseList::onGetStudentInfoBySession(CGetStudentInfoBySession getStudentInfoBySession)
  948. {
  949. if (getStudentInfoBySession.nCode == 200)
  950. {
  951. g_appInfoPtr->m_nStudentId = getStudentInfoBySession.nId;
  952. g_appInfoPtr->m_sStudentName = getStudentInfoBySession.sName;
  953. g_appInfoPtr->m_nOrgId = getStudentInfoBySession.nOrgId;
  954. g_appInfoPtr->m_sOrgCode = getStudentInfoBySession.sOrgCode;
  955. g_appInfoPtr->m_sOrgName = getStudentInfoBySession.sOrgName;
  956. g_appInfoPtr->m_sStudentCode = getStudentInfoBySession.sStudentCode;
  957. g_appInfoPtr->m_sStudentIdentityNumber = getStudentInfoBySession.sIdentityNumber;
  958. g_appInfoPtr->m_sStudentPhotoPath = getStudentInfoBySession.sPhotoPath;
  959. g_appInfoPtr->m_bStudentEnable = getStudentInfoBySession.bEnable;
  960. ui->btn_studentInfo->setText(g_appInfoPtr->m_sStudentName);
  961. ui->btn_studentInfo->setVisible(g_appInfoPtr->m_bStudentEnable);
  962. ui->btn_mobileLogin->setVisible(g_appInfoPtr->m_bShowStudentClientAppQrcode);
  963. CHttpRequestPackage hrp;
  964. hrp.sUri = "/api/ecs_exam_work/exam_student/specialtyNameList";
  965. hrp.nRequestType = RequestType::rtSpecialtyNameList;
  966. g_httpBllPtr->get(hrp);
  967. if (!g_appInfoPtr->m_sStudentPhotoPath.isEmpty())
  968. {
  969. QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  970. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  971. CHttpRequestPackage hrp;
  972. hrp.sUri = g_appInfoPtr->m_sStudentPhotoPath;
  973. hrp.sCommonStr = sFileName;
  974. hrp.sCommonStr1 = __FILE__;
  975. hrp.sAdditionStr = "StudentPhotoPath";
  976. hrp.nRequestType = RequestType::rtDownLoadFile;
  977. hrp.nRetryCount = 3;
  978. g_httpBllPtr->downLoad(hrp);
  979. }
  980. if (g_appInfoPtr->m_bShowStudentClientAppQrcode)
  981. {
  982. CHttpRequestPackage hrp;
  983. hrp.sUri = "/api/ecs_core/systemProperty/APP_DOWNLOAD_URL";
  984. hrp.nRequestType = RequestType::rtAppDownLoadUrl;
  985. g_httpBllPtr->get(hrp);
  986. }
  987. }
  988. else
  989. {
  990. if(getStudentInfoBySession.sMessage.isEmpty())
  991. {
  992. ShowMsg(QString::fromLocal8Bit("获取考生信息失败"), this, MSG_ICON_TYPE::mit_error);
  993. }
  994. else
  995. {
  996. ShowMsg(getStudentInfoBySession.sMessage, this, MSG_ICON_TYPE::mit_error);
  997. }
  998. courseList::getStudentInfoBySession();
  999. }
  1000. }
  1001. void courseList::onAppDownLoadUrl(CAppDownLoadUrl appDownLoadUrl)
  1002. {
  1003. if (appDownLoadUrl.nCode == 200)
  1004. {
  1005. g_appInfoPtr->m_sAppDownLoadUrl = appDownLoadUrl.sUrl;
  1006. }
  1007. else
  1008. {
  1009. if(appDownLoadUrl.sMessage.isEmpty())
  1010. {
  1011. ShowMsg(QString::fromLocal8Bit("获取APP下载地址失败"), this, MSG_ICON_TYPE::mit_error);
  1012. }
  1013. else
  1014. {
  1015. ShowMsg(appDownLoadUrl.sMessage, this, MSG_ICON_TYPE::mit_error);
  1016. }
  1017. }
  1018. }
  1019. void courseList::onDownLoadFile(CDownLoadFileInfo downLoadFileInfo)
  1020. {
  1021. if(downLoadFileInfo.sModuleName == __FILE__)
  1022. {
  1023. if (downLoadFileInfo.nCode == 200)
  1024. {
  1025. // QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  1026. // sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  1027. if (downLoadFileInfo.sAdditionStr == "MenuLogoUrl")
  1028. {
  1029. QString sFileName = g_appInfoPtr->m_sMenuLogoUrl.right(g_appInfoPtr->m_sMenuLogoUrl.length() - g_appInfoPtr->m_sMenuLogoUrl.lastIndexOf("/") - 1);
  1030. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  1031. ui->label_cl_org_icon->setPixmap(QPixmap(sFileName).scaled(ui->label_cl_org_icon->width(), ui->label_cl_org_icon->height(),
  1032. Qt::KeepAspectRatio, Qt::SmoothTransformation));
  1033. }
  1034. }
  1035. else
  1036. {
  1037. if(downLoadFileInfo.sMessage.isEmpty())
  1038. {
  1039. ShowMsg(QString::fromLocal8Bit("下载失败"), this, MSG_ICON_TYPE::mit_error);
  1040. }
  1041. else
  1042. {
  1043. ShowMsg(downLoadFileInfo.sMessage, this, MSG_ICON_TYPE::mit_error);
  1044. }
  1045. }
  1046. }
  1047. }
  1048. void courseList::onSpecialtyNameList(CSpecialtyNameList specialtyNameList)
  1049. {
  1050. if (specialtyNameList.nCode == 200)
  1051. {
  1052. g_appInfoPtr->m_sSpecialtyName = specialtyNameList.sSpecialtyName;
  1053. CHttpRequestPackage hrp;
  1054. hrp.sUri = "/api/ecs_oe_student/client/exam/process/checkExamInProgress";
  1055. hrp.nRequestType = RequestType::rtCheckExamInProgress;
  1056. hrp.sCommonStr = EXAM_INPROGRESS_ENTER_TYPE::EIET_COURSE_LIST;
  1057. g_httpBllPtr->post(hrp);
  1058. }
  1059. else
  1060. {
  1061. if(specialtyNameList.sMessage.isEmpty())
  1062. {
  1063. ShowMsg(QString::fromLocal8Bit("获取专业信息失败"), this, MSG_ICON_TYPE::mit_error);
  1064. }
  1065. else
  1066. {
  1067. ShowMsg(specialtyNameList.sMessage, this, MSG_ICON_TYPE::mit_error);
  1068. }
  1069. }
  1070. }
  1071. void courseList::onCheckExamInProgress(CCheckExamInProgress checkExamInProgress)
  1072. {
  1073. if (checkExamInProgress.nCode == 200)
  1074. {
  1075. if (checkExamInProgress.bHasExamInProgress)
  1076. {
  1077. if (checkExamInProgress.bIsExceed)
  1078. {
  1079. //超过断点时长交卷
  1080. g_appInfoPtr->m_oExamInfo.nExamRecordDataId = checkExamInProgress.nExamRecordDataId;
  1081. g_appInfoPtr->m_oExamInfo.nExamId = checkExamInProgress.nExamId;
  1082. CHttpRequestPackage hrp;
  1083. hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
  1084. hrp.sCommonStr = __FILE__;
  1085. hrp.nRequestType = RequestType::rtEndExam;
  1086. g_httpBllPtr->post(hrp);
  1087. }
  1088. else
  1089. {
  1090. //进入断点
  1091. g_appInfoPtr->m_oExamInfo.nExamId = checkExamInProgress.nExamId;
  1092. g_appInfoPtr->m_oExamInfo.nExamRecordDataId = checkExamInProgress.nExamRecordDataId;
  1093. g_appInfoPtr->m_oExamInfo.sExamType = checkExamInProgress.sExamType;
  1094. g_appInfoPtr->m_oExamInfo.bIsExamInProgress = true;
  1095. if (m_pResumeExam == nullptr)
  1096. {
  1097. m_pResumeExam = std::make_shared<awResumeExam>(this);
  1098. }
  1099. m_pResumeExam->show();
  1100. //环境监测
  1101. getExamProperty();
  1102. }
  1103. }
  1104. else
  1105. {
  1106. g_appInfoPtr->m_oExamInfo.bIsExamInProgress = false;
  1107. if (checkExamInProgress.sEnterType == EXAM_INPROGRESS_ENTER_TYPE::EIET_COURSE_LIST)
  1108. {
  1109. CHttpRequestPackage hrp;
  1110. hrp.sUri = "/api/ecs_core/rolePrivilege/getStudentClientMenu";
  1111. hrp.nRequestType = RequestType::rtGetStudentClientMenu;
  1112. hrp.sParamList.push_back(QString::fromLocal8Bit("rootOrgId,%1").arg(g_appInfoPtr->m_sRootOrgId));
  1113. g_httpBllPtr->get(hrp);
  1114. if (m_pWelcomeWidget == nullptr)
  1115. {
  1116. m_pWelcomeWidget = std::make_shared<welcomeWidget>(g_appInfoPtr->m_sStudentName, g_appInfoPtr->m_sStudentCode, g_appInfoPtr->m_sSpecialtyName, this);
  1117. connect(m_pWelcomeWidget.get(), &welcomeWidget::exitWelcomeWidget, this, [&]() {
  1118. m_pWelcomeWidget.reset();
  1119. });
  1120. }
  1121. m_pWelcomeWidget->show();
  1122. }
  1123. else
  1124. {
  1125. //环境监测
  1126. getExamProperty();
  1127. }
  1128. }
  1129. }
  1130. else
  1131. {
  1132. if(checkExamInProgress.sMessage.isEmpty())
  1133. {
  1134. ShowMsg(QString::fromLocal8Bit("获取断点信息失败"), this, MSG_ICON_TYPE::mit_error);
  1135. }
  1136. else
  1137. {
  1138. ShowMsg(checkExamInProgress.sMessage, this, MSG_ICON_TYPE::mit_error);
  1139. }
  1140. }
  1141. }
  1142. void courseList::getExamProperty()
  1143. {
  1144. CHttpRequestPackage hrp;
  1145. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  1146. .arg(g_appInfoPtr->m_oExamInfo.nExamId).arg("CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE,FACE_VERIFY_FORCE_EXIT");
  1147. hrp.nRequestType = RequestType::rtGetExamProperty;
  1148. hrp.sCommonStr = "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE,FACE_VERIFY_FORCE_EXIT";
  1149. g_httpBllPtr->get(hrp);
  1150. }
  1151. void courseList::onEndExam(CEndExam endExam)
  1152. {
  1153. if(endExam.sModuleName == __FILE__)
  1154. {
  1155. if (endExam.nCode == 200)
  1156. {
  1157. m_pRefreshMenuTimer->stop();
  1158. if(m_pBackground != nullptr)
  1159. {
  1160. m_pBackground.reset();
  1161. }
  1162. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_examScore, this);
  1163. connect(m_pBackground.get(), &awBackground::minisize, this, &courseList::minisize);
  1164. connect(m_pBackground.get(), &awBackground::closeWidget, this, [&](){
  1165. m_pBackground.reset();
  1166. m_pRefreshMenuTimer->start();
  1167. if(m_pOnlineExam)
  1168. {
  1169. m_pOnlineExam->refreshExam();
  1170. }
  1171. if(m_pOnlineHomework)
  1172. {
  1173. m_pOnlineHomework->refreshExam();
  1174. }
  1175. });
  1176. m_pBackground->show();
  1177. }
  1178. else
  1179. {
  1180. if(endExam.sMessage.isEmpty())
  1181. {
  1182. ShowMsg(QString::fromLocal8Bit("交卷失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  1183. }
  1184. else
  1185. {
  1186. ShowMsg(endExam.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  1187. }
  1188. }
  1189. }
  1190. }
  1191. void courseList::onGetStudentClientMenu(CGetStudentClientMenu getStudentClientMenu)
  1192. {
  1193. if (getStudentClientMenu.nCode == 200)
  1194. {
  1195. ui->btn_onlineExam->setVisible(false);
  1196. ui->btn_onlineHomework->setVisible(false);
  1197. ui->btn_onlinePractice->setVisible(false);
  1198. ui->btn_offlineExam->setVisible(false);
  1199. ui->btn_notice->setVisible(false);
  1200. ui->btn_editPassword->setVisible(false);
  1201. for (CStudentClientMenu scm : getStudentClientMenu.vMenus)
  1202. {
  1203. QString sMenuName = scm.sName;
  1204. sMenuName.insert(sMenuName.length()/2, '\n');
  1205. QString sMenuCode = scm.sCode.left(scm.sCode.lastIndexOf("_"));
  1206. if (sMenuCode == "stu_online_exam")
  1207. {
  1208. ui->btn_onlineExam->setVisible(true);
  1209. ui->btn_onlineExam->setText(sMenuName);
  1210. }
  1211. else if (sMenuCode == "stu_online_homework")
  1212. {
  1213. ui->btn_onlineHomework->setVisible(true);
  1214. ui->btn_onlineHomework->setText(sMenuName);
  1215. }
  1216. else if (sMenuCode == "stu_online_practice")
  1217. {
  1218. ui->btn_onlinePractice->setVisible(true);
  1219. ui->btn_onlinePractice->setText(sMenuName);
  1220. }
  1221. else if (sMenuCode == "stu_offline_exam")
  1222. {
  1223. ui->btn_offlineExam->setVisible(true);
  1224. ui->btn_offlineExam->setText(sMenuName);
  1225. }
  1226. else if (sMenuCode == "stu_notice")
  1227. {
  1228. ui->btn_notice->setVisible(true);
  1229. ui->btn_notice->setText(sMenuName);
  1230. CHttpRequestPackage hrp;
  1231. hrp.sUri = "/api/ecs_exam_work/notice/getUserNoticeList";
  1232. hrp.nRequestType = RequestType::rtGetUserNoticeList;
  1233. g_httpBllPtr->get(hrp);
  1234. }
  1235. else if (sMenuCode == "stu_modify_pwd")
  1236. {
  1237. ui->btn_editPassword->setVisible(true);
  1238. ui->btn_editPassword->setText(sMenuName);
  1239. }
  1240. }
  1241. menuBtnRePosistion();
  1242. }
  1243. else
  1244. {
  1245. if(getStudentClientMenu.sMessage.isEmpty())
  1246. {
  1247. ShowMsg(QString::fromLocal8Bit("获取菜单失败"), this, MSG_ICON_TYPE::mit_error);
  1248. }
  1249. else
  1250. {
  1251. ShowMsg(getStudentClientMenu.sMessage, this, MSG_ICON_TYPE::mit_error);
  1252. }
  1253. }
  1254. }
  1255. void courseList::onGetUserNoticeList(CGetUserNoticeList getUserNoticeList)
  1256. {
  1257. if (getUserNoticeList.nCode == 200)
  1258. {
  1259. if (m_pNoticeList == nullptr)
  1260. {
  1261. m_pNoticeList = std::make_shared<clNoticeList>(ui->stw_courseList);
  1262. m_pNoticeList->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  1263. connect(m_pNoticeList.get(), &clNoticeList::unReadNoticeCount, this, [&](int nCount) {
  1264. ui->btn_noticeNum->setText(QString::number(nCount));
  1265. ui->btn_noticeNum->setVisible(nCount > 0);
  1266. });
  1267. connect(m_pNoticeList.get(), &clNoticeList::readNotice, this, [&](__int64 nId) {
  1268. m_pNoticePopWidget->setNoticeRead(nId);
  1269. });
  1270. }
  1271. m_pNoticeList->setNotice(getUserNoticeList.vNoticeList);
  1272. if (m_pNoticePopWidget == nullptr)
  1273. {
  1274. m_pNoticePopWidget = std::make_shared<clNoticePopWidget>(this);
  1275. m_pNoticePopWidget->setUI(g_appInfoPtr->m_fRate * 960, g_appInfoPtr->m_fRate * 558, g_appInfoPtr->m_fRate * 310, g_appInfoPtr->m_fRate * 200);
  1276. connect(m_pNoticePopWidget.get(), &clNoticePopWidget::showNoticeDetail, this, [&](__int64 nId){
  1277. setCheck(COURSE_MENU_BTN_TYPE::cmbt_notice);
  1278. m_pNoticeList->viewNotice(nId);
  1279. });
  1280. }
  1281. int nUnReadCount = 0;
  1282. for (CNoticeInfo ni : getUserNoticeList.vNoticeList)
  1283. {
  1284. if (!ni.bHasRead)
  1285. {
  1286. m_pNoticePopWidget->addNotice(ni);
  1287. ++nUnReadCount;
  1288. }
  1289. }
  1290. ui->btn_noticeNum->setText(QString::number(nUnReadCount));
  1291. ui->btn_noticeNum->setVisible(nUnReadCount > 0);
  1292. if(m_pNoticePopWidget->noticeCount() > 0)
  1293. {
  1294. m_pNoticePopWidget->show();
  1295. }
  1296. }
  1297. else
  1298. {
  1299. if(getUserNoticeList.sMessage.isEmpty())
  1300. {
  1301. ShowMsg(QString::fromLocal8Bit("获取通知信息失败"), this, MSG_ICON_TYPE::mit_error);
  1302. }
  1303. else
  1304. {
  1305. ShowMsg(getUserNoticeList.sMessage, this, MSG_ICON_TYPE::mit_error);
  1306. }
  1307. }
  1308. }