guhongwei 4 years ago
parent
commit
1ba4b7cfa1
2 changed files with 10 additions and 4 deletions
  1. 4 2
      src/store/adminLogin.js
  2. 6 2
      src/views/Login.vue

+ 4 - 2
src/store/adminLogin.js

@@ -39,9 +39,11 @@ const actions = {
     if (res.errcode === 0) {
       localStorage.setItem('token', res.data);
       user = jwt.decode(res.data);
-      commit('setUser', user, { root: true });
+      if (user.code == 'CGPJXTYW') {
+        commit('setUser', user, { root: true });
+        return res;
+      }
     }
-    return res;
   },
   async updatePwd({ commit }, { id, ...data }) {
     const res = await this.$axios.$post(`${api.adminLoginInfo}/password/${id}`, data);

+ 6 - 2
src/views/Login.vue

@@ -132,8 +132,12 @@ export default {
     async adminLogin() {
       let res = await this.login({ user: this.form });
       if (this.$checkRes(res)) {
-        this.$message.success('登录成功');
-        this.$router.push('/homeIndex');
+        if (res) {
+          this.$message.success('登录成功');
+          this.$router.push('/homeIndex');
+        } else {
+          this.$message.error('当前用户不是此平台用户,请更换账号登录');
+        }
       }
     },
     // 专家登陆