Parcourir la source

处理登录以及跳转

yys il y a 2 semaines
Parent
commit
5b97edaa92
2 fichiers modifiés avec 23 ajouts et 12 suppressions
  1. 17 0
      src/api/login.js
  2. 6 12
      src/views/login.vue

+ 17 - 0
src/api/login.js

@@ -12,6 +12,9 @@ export function login(username, password, code, uuid, tenantCode) {
   return request({
     url: '/login',
     method: 'post',
+    headers: {
+      isToken: false
+    },
     data: data
   })
 }
@@ -28,6 +31,9 @@ export function checkIsNeedCheck(username, password, code, uuid, tenantCode) {
   return request({
     url: '/checkIsNeedCheck',
     method: 'post',
+    headers: {
+      isToken: false
+    },
     data: data
   })
 }
@@ -44,6 +50,14 @@ export function register(data) {
   })
 }
 
+// 是否首次登录
+export function getFirstLogin() {
+  return request({
+    url: '/getFirstLogin',
+    method: 'get'
+  })
+}
+
 // 获取用户详细信息
 export function getInfo() {
   return request({
@@ -65,6 +79,9 @@ export function getCodeImg() {
   return request({
     url: '/captchaImage',
     method: 'get',
+    headers: {
+      isToken: false
+    },
     timeout: 20000
   })
 }

+ 6 - 12
src/views/login.vue

@@ -181,18 +181,17 @@ export default {
     },
     checkFirstLogin() {
       getFirstLogin().then(res => {
+        this.loading = false;
         if (res.code === 200 && res.data) {
-          // 将首次登录状态存储到本地
-          localStorage.setItem('isFirstLogin', res.data ? 'true' : 'false');
-          // 如果是首次登录,跳转到设置密码页面
+          localStorage.setItem('isFirstLogin', 'true');
           this.$router.push('/set-password');
         } else {
-          // 否则进入首页
+          localStorage.setItem('isFirstLogin', 'false');
           this.$router.push({ path: this.redirect || "/" });
         }
       }).catch(() => {
         this.loading = false;
-        this.getCode();
+        this.$router.push({ path: this.redirect || "/" });
       });
     },
     getCode() {
@@ -244,13 +243,8 @@ export default {
             .dispatch("Login", {...this.loginForm, captchaOnOff: this.captchaOnOff})
             .then(res => {
               if (res.needSms) {
-                this.wechatDialogVisible = true;
-                // 等 visible 更新后,直接调用弹窗 open()
-                this.$nextTick(() => {
-                  if (this.$refs.wechatDialog) {
-                    this.$refs.wechatDialog.open(this.loginForm.username);
-                  }
-                });
+                this.loading = false;
+                this.$message.warning('需要短信验证,但验证组件未启用,请联系管理员');
               } else {
                 // 登录成功后检查是否是首次登录
                 this.checkFirstLogin();