| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #include "dialogbindsystem.h"
- #include "ui_dialogbindsystem.h"
- #include "WSSSO.h"
- #include "respregsysaccounts.h"
- #include "respbindsysaccount.h"
- #include "sncdatabase.h"
- #include <QtGui>
- DialogBindSystem::DialogBindSystem(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogBindSystem)
- {
- ui->setupUi(this);
- genValidateCode();
- ui->buttonBox->setVisible(false);
- this->succeed = true ;
- }
- void DialogBindSystem::setSysRegInfo(QString sysCode,QString userHash)
- {
- this->sysCode = sysCode;
- this->userHash = userHash;
- }
- bool DialogBindSystem::serviceIsOpen()
- {
- return this->succeed;
- }
- DialogBindSystem::~DialogBindSystem()
- {
- delete ui;
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"SNCUser.DialogBindSystem Destroyed.";
- }
- void DialogBindSystem::on_pushButtonRegService_clicked()
- {
- ui->pushButtonRegService->setEnabled(false);
- WSSSO interface;
- QString regSrc = "mf-" + SNCDataBase::getAppVersion();
- QString json = interface.regSysAccount(this->sysCode,this->userHash,regSrc);
- RespRegSysAccounts response(json);
- if(json.isEmpty())
- {
- QMessageBox::warning(NULL,"极速号码魔方","网络连接失败!",QMessageBox::Ok);
- }
- else
- {
- if(response.getRtnCode()==1)
- {
- QMessageBox::information(NULL,"极速号码魔方","恭喜,服务开通成功!",QMessageBox::Ok);
- this->succeed = true ;
- this->close();
- }
- else
- {
- QMessageBox::critical(NULL,"极速号码魔方",response.getRtnMemo(),QMessageBox::Ok);
- }
- }
- ui->pushButtonRegService->setEnabled(true);
- }
- void DialogBindSystem::on_pushButtonBindService_clicked()
- {
- if(ui->lineEditValidateCode->text()!=ui->labelCode->text())
- {
- QMessageBox::critical(this,"提示","验证码不正确!",QMessageBox::Ok);
- genValidateCode();
- return ;
- }
- ui->pushButtonBindService->setEnabled(false);
- WSSSO interface;
- QString json = interface.bindSysAccount(this->sysCode,ui->lineEditUserID->text(),
- ui->lineEditUserPwd->text(),this->userHash);
- RespBindSysAccount response(json);
- if(json.isEmpty())
- {
- QMessageBox::warning(NULL,"极速号码魔方","网络连接失败!",QMessageBox::Ok);
- }
- else
- {
- if(response.getRtnCode()==1)
- {
- QMessageBox::information(NULL,"极速号码魔方","恭喜,服务绑定成功!",QMessageBox::Ok);
- this->succeed = true ;
- this->close();
- }
- else
- {
- QMessageBox::critical(NULL,"极速号码魔方",response.getRtnMemo(),QMessageBox::Ok);
- }
- }
- genValidateCode();
- ui->pushButtonBindService->setEnabled(true);
- }
- void DialogBindSystem::genValidateCode()
- {
- QTime time;
- time= QTime::currentTime();
- qsrand(time.msec()+time.second()*1000);
- int rnd = qrand()%9999;
- QString code = "00000"+QString::number(rnd);
- this->ui->labelCode->setText(code.right(4));
- }
|