#include "dialogbindsystem.h" #include "ui_dialogbindsystem.h" #include "WSSSO.h" #include "sncdatabase.h" #include "respregsysaccounts.h" #include "respbindsysaccount.h" #include DialogBindSystem::DialogBindSystem(QWidget *parent) : QDialog(parent), ui(new Ui::DialogBindSystem) { ui->setupUi(this); genValidateCode(); ui->buttonBox->setVisible(false); this->succeed = true ; this->setFixedHeight(200); this->setFixedWidth(300); } void DialogBindSystem::setSysRegInfo(QString sysCode,QString userHash) { this->sysCode = sysCode; this->userHash = userHash; } bool DialogBindSystem::serviceIsOpen() { return this->succeed; } DialogBindSystem::~DialogBindSystem() { delete ui; qDebug()<pushButtonRegService->setEnabled(false); WSSSO interface; QString regSrc = "mf-" + SNCDataBase::getAppVersion(); QString json = interface.regSysAccount(this->sysCode,this->userHash,regSrc); RespRegSysAccounts response(json); qDebug()<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)); }