|
@@ -66,16 +66,18 @@ class KMVerficationCodeWindowController: NSWindowController {
|
|
|
self.verificationCodeView.doneAction = { [unowned self] (view, data , sender) in
|
|
|
print("注销")
|
|
|
KMRequestServerManager.manager.logOff(verifyCode: data.verifyCode, complete: { [unowned self] success, result in
|
|
|
- if success {
|
|
|
- verficationCodeMainWindow?.endSheet(view.window!)
|
|
|
- view.window?.close()
|
|
|
- verficationCodeController = nil
|
|
|
- verficationCodeMainWindow = nil
|
|
|
- self.didCancellation?()
|
|
|
- } else {
|
|
|
- self.verificationCodeView.showAlert(result: result)
|
|
|
+ if self.verificationCodeView != nil {
|
|
|
+ if success {
|
|
|
+ verficationCodeMainWindow?.endSheet(view.window!)
|
|
|
+ view.window?.close()
|
|
|
+ verficationCodeController = nil
|
|
|
+ verficationCodeMainWindow = nil
|
|
|
+ self.didCancellation?()
|
|
|
+ } else {
|
|
|
+ self.verificationCodeView.showAlert(result: result)
|
|
|
+ }
|
|
|
+ self.verificationCodeView.changeDoneButtonState(enable: true)
|
|
|
}
|
|
|
- self.verificationCodeView.changeDoneButtonState(enable: true)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -85,11 +87,13 @@ class KMVerficationCodeWindowController: NSWindowController {
|
|
|
|
|
|
self.verificationCodeView.verificationCodeAction = { [unowned self] (view, data, codeString) in
|
|
|
KMRequestServerManager.manager.verificationCode(account: data.email, verifyCode: codeString, verifyCodeType: view.verifyCodeType) { success, result in
|
|
|
- if success {
|
|
|
- self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: true)
|
|
|
- } else {
|
|
|
- self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: false)
|
|
|
- self.verificationCodeView.showAlert(result: result)
|
|
|
+ if self.verificationCodeView != nil {
|
|
|
+ if success {
|
|
|
+ self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: true)
|
|
|
+ } else {
|
|
|
+ self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: false)
|
|
|
+ self.verificationCodeView.showAlert(result: result)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -107,16 +111,18 @@ class KMVerficationCodeWindowController: NSWindowController {
|
|
|
|
|
|
func sendVerifyCode(sender: NSTextView?) {
|
|
|
KMRequestServerManager.manager.getVerifyCode(verifyCodeType: self.verificationCodeView.verifyCodeType, email: self.verificationCodeView.model.email) { [unowned self] success, result in
|
|
|
- if success {
|
|
|
- self.verificationCodeView.resetTimer()
|
|
|
- } else {
|
|
|
- self.verificationCodeView.showAlert(result: result)
|
|
|
- self.verificationCodeView.time = self.verificationCodeView.startTime
|
|
|
- self.verificationCodeView.updateLanguage()
|
|
|
- }
|
|
|
-
|
|
|
- if sender != nil {
|
|
|
- sender!.isSelectable = true
|
|
|
+ if self.verificationCodeView != nil {
|
|
|
+ if success {
|
|
|
+ self.verificationCodeView.resetTimer()
|
|
|
+ } else {
|
|
|
+ self.verificationCodeView.showAlert(result: result)
|
|
|
+ self.verificationCodeView.time = self.verificationCodeView.startTime
|
|
|
+ self.verificationCodeView.updateLanguage()
|
|
|
+ }
|
|
|
+
|
|
|
+ if sender != nil {
|
|
|
+ sender!.isSelectable = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|