|
@@ -158,6 +158,15 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@abstract 刷新用户个人信息
|
|
|
*/
|
|
|
private func refreshUserInfo() -> Void {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
KMUserInfoVCModel().refreshUserInfo { success, msg in
|
|
|
if success {
|
|
|
KMMemberInfo.shared.isLogin = true
|
|
@@ -175,6 +184,15 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@param
|
|
|
*/
|
|
|
func signUpAction() -> Void {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
if email.count <= 0 || email.count > 100 || !isValidEmail() {
|
|
|
emailErrorMessage = NSLocalizedString("Email format error. Please enter the correct email.", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
return
|
|
@@ -235,6 +253,15 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
|
|
|
} else {
|
|
|
if(resultDict.code == 305) {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
KMMemberCenterManager.manager.getUserDeviceList(email: email) { [weak self] success, result in
|
|
|
guard self != nil else { return }
|
|
|
if success {
|
|
@@ -247,8 +274,14 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
let alert = NSAlert()
|
|
|
alert.messageText = NSLocalizedString(msg!, comment: "")
|
|
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if(NSApp.mainWindow != nil) {
|
|
|
- alert.beginSheetModal(for: NSApp.mainWindow!)
|
|
|
+ let response = alert.runModal()
|
|
|
+ if response == .alertFirstButtonReturn {
|
|
|
+ if(resultDict.code == 317) {
|
|
|
+ signUpState = .verificationCode
|
|
|
+ countDown(type: .login)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -260,6 +293,15 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@param
|
|
|
*/
|
|
|
func forgotPasswordNextAction(_ complete: @escaping ForgotPasswordComplete) -> Void {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
if email.count <= 0 || email.count > 100 || !isValidEmail() {
|
|
|
emailErrorMessage = NSLocalizedString("Please enter the correct email format", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
return
|
|
@@ -285,6 +327,15 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@param
|
|
|
*/
|
|
|
func enterVerificationCodeNextAction(_ complete: @escaping ForgotPasswordComplete) -> Void {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
if verificationCode.count <= 0 || verificationCode.count > 6 || !isValidVerificationCode() {
|
|
|
emailErrorMessage = NSLocalizedString("Verification code error.", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
complete(false, "")
|
|
@@ -309,6 +360,16 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@param
|
|
|
*/
|
|
|
func getVerificationCode(_ type: KMVerificationCodeType) -> Void {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if !isValidEmail() {
|
|
|
emailErrorMessage = NSLocalizedString("Please enter the correct email format", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
return
|
|
@@ -331,6 +392,16 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@param
|
|
|
*/
|
|
|
func resetPassword(_ complete: @escaping ForgotPasswordComplete) -> Void {
|
|
|
+ if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if password.count <= 0 || verificationCode.count > 30 {
|
|
|
passwordErrorMessage = NSLocalizedString("Password error.", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
return
|