clMobileLogin.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #include "clMobileLogin.h"
  2. #include "ui_clMobileLogin.h"
  3. #include "CAppInfo.h"
  4. #include "CQREncode.h"
  5. #include <QGraphicsDropShadowEffect>
  6. clMobileLogin::clMobileLogin(QWidget *parent) :
  7. QWidget(parent),
  8. ui(new Ui::clMobileLogin)
  9. {
  10. ui->setupUi(this);
  11. setStyleSheet(g_appInfoPtr->m_sQssStr);
  12. }
  13. clMobileLogin::~clMobileLogin()
  14. {
  15. delete ui;
  16. }
  17. void clMobileLogin::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  18. {
  19. setGeometry(nLeft, nTop, nWidth, nHeight);
  20. ui->widget_npw_BG->setGeometry(g_appInfoPtr->m_fRate*5, g_appInfoPtr->m_fRate*5, width()-g_appInfoPtr->m_fRate*10, height()-g_appInfoPtr->m_fRate*10);
  21. ui->btn_downloadApp->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*20,
  22. g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*32);
  23. ui->btn_bindUser->setGeometry(ui->btn_downloadApp->x() + ui->btn_downloadApp->width(),
  24. ui->btn_downloadApp->y(), ui->btn_downloadApp->width(), ui->btn_downloadApp->height());
  25. ui->label_qrcode->setGeometry((ui->widget_npw_BG->width() - g_appInfoPtr->m_fRate*164)/2, ui->btn_downloadApp->y() + ui->btn_downloadApp->height() + g_appInfoPtr->m_fRate*20,
  26. g_appInfoPtr->m_fRate*164, g_appInfoPtr->m_fRate*164);
  27. ui->label_useAppScan->adjustSize();
  28. ui->label_useAppScan->setGeometry((ui->widget_npw_BG->width() - ui->label_useAppScan->width())/2,
  29. ui->label_qrcode->y() + ui->label_qrcode->height() + g_appInfoPtr->m_fRate*10,
  30. ui->label_useAppScan->width(), ui->label_useAppScan->height());
  31. QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
  32. effect->setOffset(g_appInfoPtr->m_fRate*4,g_appInfoPtr->m_fRate*4);
  33. effect->setColor(QColor(0,0,0,30));
  34. effect->setBlurRadius(g_appInfoPtr->m_fRate*16);
  35. ui->widget_npw_BG->setGraphicsEffect(effect);
  36. on_btn_downloadApp_clicked();
  37. }
  38. void clMobileLogin::setBtnDown(ML_BTN_TYPE type)
  39. {
  40. QString sDownLoadAppStyle = QString(R"(QPushButton
  41. {
  42. outline:none;
  43. background:rgba(%1,1);
  44. font-size:%2px;
  45. font-family:"Microsoft YaHei";
  46. font-weight:400;
  47. color:rgba(%3,1);
  48. border-top-left-radius:%4px;
  49. border-bottom-left-radius:%5px;
  50. })");
  51. QString sDownLoadAppNormalStyle = sDownLoadAppStyle.arg("244,243,247").arg((int)(g_appInfoPtr->m_fRate*12))
  52. .arg("102, 102, 102")
  53. .arg((int)(g_appInfoPtr->m_fRate*6))
  54. .arg((int)(g_appInfoPtr->m_fRate*6));
  55. QString sDownLoadAppCheckStyle = sDownLoadAppStyle.arg("19,187,138").arg((int)(g_appInfoPtr->m_fRate * 12))
  56. .arg("255,255,255")
  57. .arg((int)(g_appInfoPtr->m_fRate * 6))
  58. .arg((int)(g_appInfoPtr->m_fRate * 6));
  59. QString sBindUserStyle = QString(R"(QPushButton
  60. {
  61. outline:none;
  62. background:rgba(%1,1);
  63. font-size:%2px;
  64. font-family:"Microsoft YaHei";
  65. font-weight:400;
  66. color:rgba(%3,1);
  67. border-top-right-radius:%4px;
  68. border-bottom-right-radius:%5px;
  69. })");
  70. QString sBindUserNormalStyle = sBindUserStyle.arg("244,243,247").arg((int)(g_appInfoPtr->m_fRate * 12))
  71. .arg("102, 102, 102").arg((int)(g_appInfoPtr->m_fRate*6))
  72. .arg((int)(g_appInfoPtr->m_fRate*6));
  73. QString sBindUserCheckStyle = sBindUserStyle.arg("19,187,138").arg((int)(g_appInfoPtr->m_fRate * 12))
  74. .arg("255,255,255").arg((int)(g_appInfoPtr->m_fRate * 6))
  75. .arg((int)(g_appInfoPtr->m_fRate * 6));
  76. if(type == ML_BTN_TYPE::mbt_downloadApp)
  77. {
  78. ui->btn_downloadApp->setStyleSheet(sDownLoadAppCheckStyle);
  79. ui->btn_bindUser->setStyleSheet(sBindUserNormalStyle);
  80. }
  81. else
  82. {
  83. ui->btn_downloadApp->setStyleSheet(sDownLoadAppNormalStyle);
  84. ui->btn_bindUser->setStyleSheet(sBindUserCheckStyle);
  85. }
  86. }
  87. void clMobileLogin::on_btn_downloadApp_clicked()
  88. {
  89. ui->label_qrcode->setPixmap(CQREncode::GenerateQRcode(g_appInfoPtr->m_sAppDownLoadUrl, ui->label_qrcode->width()));
  90. ui->label_useAppScan->setVisible(false);
  91. setBtnDown(ML_BTN_TYPE::mbt_downloadApp);
  92. }
  93. void clMobileLogin::on_btn_bindUser_clicked()
  94. {
  95. QString sUserInfo = QString(R"({"rootOrgId":%1,"studentCode":"%2","identityNumber":"%3"})")
  96. .arg(g_appInfoPtr->m_sRootOrgId).arg(g_appInfoPtr->m_sStudentCode).arg(g_appInfoPtr->m_sStudentIdentityNumber);
  97. ui->label_qrcode->setPixmap(CQREncode::GenerateQRcode(sUserInfo, ui->label_qrcode->width()));
  98. ui->label_useAppScan->setVisible(true);
  99. setBtnDown(ML_BTN_TYPE::mbt_bindUser);
  100. }