Ver código fonte

1、登录超时问题

yys 1 semana atrás
pai
commit
ff6faa21d7

+ 12 - 3
src/views/qw/user/cuDeptIdIndex.vue

@@ -783,7 +783,7 @@ export default {
 			  this.qwCode.waitCount = (this.qwCode.waitCount || 0) + 1;
 			  if (this.qwCode.waitCount >= 20) {
 			    this.$message.warning('登录确认超时,请重新点击登录后再扫码');
-			    this.clearDl();
+			    this.abortPendingLogin();
 			  }
 		  }
         }).catch(() => {});
@@ -800,19 +800,28 @@ export default {
 			this.qwCode.submitted = true;
 			this.qwCode.waitCount = 0;
 			if (res.msg === 'NOT_NEED_VERIFY') {
-				this.$message.info('当前无需验证码,正在确认登录状态...');
+				this.$message.info('验证码已提交,正在确认登录状态...');
 			} else {
 				this.$message.success('验证成功,账号信息确认中...');
 			}
 			this.loginQwPolling();
 		}).catch(err => {
 			const msg = (err && err.message) ? err.message : '';
-			if (msg.indexOf('重新点击登录') !== -1 || msg.indexOf('已过期') !== -1 || msg.indexOf('企业不一致') !== -1) {
+			if (msg.indexOf('重新点击登录') !== -1 || msg.indexOf('已过期') !== -1 || msg.indexOf('企业不一致') !== -1 || msg.indexOf('登录状态已变化') !== -1) {
 				this.clearDl();
 			}
 		});
 	},
 
+	abortPendingLogin() {
+		const qwUserId = this.qwUserId;
+		this.clearDl();
+		if (!qwUserId) {
+			return;
+		}
+		outLoginQwIpad({ qwUserId: qwUserId }).catch(() => {});
+	},
+
 	clearDl(){
 		this.qwCode.open=false;
 		this.qwCode.code=null;

+ 15 - 5
src/views/qw/user/index.vue

@@ -893,11 +893,11 @@ export default {
               this.qwCode.open = true;
             }
           } else if (this.qwCode.submitted) {
-            // 验码后等待终态,超时则提示重试,避免一直空转
+            // 验码后等待终态,超时则清理主机半登录再提示重试
             this.qwCode.waitCount = (this.qwCode.waitCount || 0) + 1;
             if (this.qwCode.waitCount >= 20) {
               this.$message.warning('登录确认超时,请重新点击登录后再扫码');
-              this.clearDl();
+              this.abortPendingLogin();
             }
           }
         }).catch(() => {});
@@ -914,20 +914,30 @@ export default {
         this.qwCode.submitted = true;
         this.qwCode.waitCount = 0;
         if (res.msg === 'NOT_NEED_VERIFY') {
-          this.$message.info('当前无需验证码,正在确认登录状态...');
+          this.$message.info('验证码已提交,正在确认登录状态...');
         } else {
           this.$message.success('验证成功,账号信息确认中...');
         }
         this.loginQwPolling();
       }).catch(err => {
         const msg = (err && err.message) ? err.message : '';
-        // 需要重新发起登录的错误,直接收掉弹窗
-        if (msg.indexOf('重新点击登录') !== -1 || msg.indexOf('已过期') !== -1 || msg.indexOf('企业不一致') !== -1) {
+        // 需要重新发起登录的错误,收掉弹窗;后端已清主机则仅清前端
+        if (msg.indexOf('重新点击登录') !== -1 || msg.indexOf('已过期') !== -1 || msg.indexOf('企业不一致') !== -1 || msg.indexOf('登录状态已变化') !== -1) {
           this.clearDl();
         }
       });
     },
 
+    // 验码后确认超时:退出主机半登录,避免再次登录仍卡死
+    abortPendingLogin() {
+      const qwUserId = this.qwUserId;
+      this.clearDl();
+      if (!qwUserId) {
+        return;
+      }
+      outLoginQwIpad({qwUserId: qwUserId}).catch(() => {});
+    },
+
     clearDl() {
       this.qwCode.open = false;
       this.qwCode.code = null;

+ 12 - 3
src/views/qw/user/myIndex.vue

@@ -870,7 +870,7 @@ export default {
             this.qwCode.waitCount = (this.qwCode.waitCount || 0) + 1;
             if (this.qwCode.waitCount >= 20) {
               this.$message.warning('登录确认超时,请重新点击登录后再扫码');
-              this.clearDl();
+              this.abortPendingLogin();
             }
           }
         }).catch(() => {});
@@ -887,19 +887,28 @@ export default {
         this.qwCode.submitted = true;
         this.qwCode.waitCount = 0;
         if (res.msg === 'NOT_NEED_VERIFY') {
-          this.$message.info('当前无需验证码,正在确认登录状态...');
+          this.$message.info('验证码已提交,正在确认登录状态...');
         } else {
           this.$message.success('验证成功,账号信息确认中...');
         }
         this.loginQwPolling();
       }).catch(err => {
         const msg = (err && err.message) ? err.message : '';
-        if (msg.indexOf('重新点击登录') !== -1 || msg.indexOf('已过期') !== -1 || msg.indexOf('企业不一致') !== -1) {
+        if (msg.indexOf('重新点击登录') !== -1 || msg.indexOf('已过期') !== -1 || msg.indexOf('企业不一致') !== -1 || msg.indexOf('登录状态已变化') !== -1) {
           this.clearDl();
         }
       });
     },
 
+    abortPendingLogin() {
+      const qwUserId = this.qwUserId;
+      this.clearDl();
+      if (!qwUserId) {
+        return;
+      }
+      outLoginQwIpad({qwUserId: qwUserId}).catch(() => {});
+    },
+
     clearDl() {
       this.qwCode.open = false;
       this.qwCode.code = null;