dialogbindsystem.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "dialogbindsystem.h"
  2. #include "ui_dialogbindsystem.h"
  3. #include "WSSSO.h"
  4. #include "respregsysaccounts.h"
  5. #include "respbindsysaccount.h"
  6. #include "sncdatabase.h"
  7. #include <QtGui>
  8. DialogBindSystem::DialogBindSystem(QWidget *parent) :
  9. QDialog(parent),
  10. ui(new Ui::DialogBindSystem)
  11. {
  12. ui->setupUi(this);
  13. genValidateCode();
  14. ui->buttonBox->setVisible(false);
  15. this->succeed = true ;
  16. }
  17. void DialogBindSystem::setSysRegInfo(QString sysCode,QString userHash)
  18. {
  19. this->sysCode = sysCode;
  20. this->userHash = userHash;
  21. }
  22. bool DialogBindSystem::serviceIsOpen()
  23. {
  24. return this->succeed;
  25. }
  26. DialogBindSystem::~DialogBindSystem()
  27. {
  28. delete ui;
  29. qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
  30. <<"SNCUser.DialogBindSystem Destroyed.";
  31. }
  32. void DialogBindSystem::on_pushButtonRegService_clicked()
  33. {
  34. ui->pushButtonRegService->setEnabled(false);
  35. WSSSO interface;
  36. QString regSrc = "mf-" + SNCDataBase::getAppVersion();
  37. QString json = interface.regSysAccount(this->sysCode,this->userHash,regSrc);
  38. RespRegSysAccounts response(json);
  39. if(json.isEmpty())
  40. {
  41. QMessageBox::warning(NULL,"极速号码魔方","网络连接失败!",QMessageBox::Ok);
  42. }
  43. else
  44. {
  45. if(response.getRtnCode()==1)
  46. {
  47. QMessageBox::information(NULL,"极速号码魔方","恭喜,服务开通成功!",QMessageBox::Ok);
  48. this->succeed = true ;
  49. this->close();
  50. }
  51. else
  52. {
  53. QMessageBox::critical(NULL,"极速号码魔方",response.getRtnMemo(),QMessageBox::Ok);
  54. }
  55. }
  56. ui->pushButtonRegService->setEnabled(true);
  57. }
  58. void DialogBindSystem::on_pushButtonBindService_clicked()
  59. {
  60. if(ui->lineEditValidateCode->text()!=ui->labelCode->text())
  61. {
  62. QMessageBox::critical(this,"提示","验证码不正确!",QMessageBox::Ok);
  63. genValidateCode();
  64. return ;
  65. }
  66. ui->pushButtonBindService->setEnabled(false);
  67. WSSSO interface;
  68. QString json = interface.bindSysAccount(this->sysCode,ui->lineEditUserID->text(),
  69. ui->lineEditUserPwd->text(),this->userHash);
  70. RespBindSysAccount response(json);
  71. if(json.isEmpty())
  72. {
  73. QMessageBox::warning(NULL,"极速号码魔方","网络连接失败!",QMessageBox::Ok);
  74. }
  75. else
  76. {
  77. if(response.getRtnCode()==1)
  78. {
  79. QMessageBox::information(NULL,"极速号码魔方","恭喜,服务绑定成功!",QMessageBox::Ok);
  80. this->succeed = true ;
  81. this->close();
  82. }
  83. else
  84. {
  85. QMessageBox::critical(NULL,"极速号码魔方",response.getRtnMemo(),QMessageBox::Ok);
  86. }
  87. }
  88. genValidateCode();
  89. ui->pushButtonBindService->setEnabled(true);
  90. }
  91. void DialogBindSystem::genValidateCode()
  92. {
  93. QTime time;
  94. time= QTime::currentTime();
  95. qsrand(time.msec()+time.second()*1000);
  96. int rnd = qrand()%9999;
  97. QString code = "00000"+QString::number(rnd);
  98. this->ui->labelCode->setText(code.right(4));
  99. }