def login(self): username = self.postWidgets["username"].currentText() if username.isEmpty(): QToolTip.showText(self.postWidgets["username"].mapToGlobal(QPoint(0, 0)), self.tr(u"请输入12306账号")) return password = self.postWidgets["password"].text() if password.isEmpty(): QToolTip.showText(self.mapToGlobal(self.postWidgets["password"].pos()), self.tr(u"请输入12306密码")) return while True: vcode = self.getLoginVCode() if not vcode: break train12306 = train.getInstance() if train12306.isVCodeRight(train12306.reqVCodeCheck("sjrand", vcode)): loginRes = train12306.reqLoginSuggest( { # 可以获取和展示登录失败原因 "loginUserDTO.user_name": str(username), "userDTO.password": str(password), "randCode": vcode, "randCode_validate": "", } ) if not train12306.isLoginSuccess(loginRes): self.updateMessage(train12306.getLoginFailedReason(loginRes), color="red") else: self.triggerWidgets["submitButton"].setDisabled(True) self.updateMessage(u"登录成功", color="green") break
def login(self): username = self.postWidgets["username"].currentText() if username.isEmpty(): QToolTip.showText(self.postWidgets["username"].mapToGlobal(QPoint(0, 0)), self.tr(u"请输入12306账号")) return password = self.postWidgets["password"].text() if password.isEmpty(): QToolTip.showText(self.mapToGlobal(self.postWidgets["password"].pos()), self.tr(u"请输入12306密码")) return while True: vcode = self.getLoginVCode() if not vcode: break train12306 = train.getInstance() if (train12306.isVCodeRight(train12306.reqVCodeCheck("sjrand", vcode))): loginRes = train12306.reqLoginSuggest({ #可以获取和展示登录失败原因 "loginUserDTO.user_name": str(username), "userDTO.password": str(password), "randCode": vcode, "randCode_validate": '', }) if not train12306.isLoginSuccess(loginRes): self.updateMessage(train12306.getLoginFailedReason(loginRes), color = "red") else: self.triggerWidgets["submitButton"].setDisabled(True) self.updateMessage(u"登录成功", color = "green") break
def showImage(self, codeModule = "", codeRand = ""): if codeModule and codeRand: self.codeModule = codeModule self.codeRand = codeRand self.initPointWidgets() train12306 = train.getInstance() imageRes = train12306.reqVCodeImage(self.codeModule, self.codeRand) pixmap = QPixmap() pixmap.loadFromData(imageRes) self.triggerWidgets["imageLabel"].setPixmap(pixmap) if self.isHidden(): return self.exec_() return 0