From d951a941456b87a5110194cd284cd38fdec57615 Mon Sep 17 00:00:00 2001 From: smallchill Date: Wed, 27 Mar 2019 09:10:49 +0800 Subject: [PATCH] =?UTF-8?q?:ok=5Fhand:=20=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=A4=B1=E8=B4=A5=E5=90=8E=E6=9C=AA=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/user.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 92c55be..12a6757 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,4 +1,5 @@ import {setToken, setRefreshToken, removeToken} from '@/util/auth' +import {Message} from 'element-ui' import {setStore, getStore} from '@/util/store' import {isURL, validatenull} from '@/util/validate' import {deepClone} from '@/util/util' @@ -44,12 +45,19 @@ const user = { LoginByUsername({commit}, userInfo) { return new Promise((resolve) => { loginByUsername(userInfo.tenantCode, userInfo.username, userInfo.password, userInfo.type).then(res => { - const data = res.data; - commit('SET_TOKEN', data.access_token); - commit('SET_REFRESH_TOKEN', data.refresh_token); - commit('SET_USERIFNO', data); - commit('DEL_ALL_TAG'); - commit('CLEAR_LOCK'); + if(res.status === 200) { + const data = res.data; + commit('SET_TOKEN', data.access_token); + commit('SET_REFRESH_TOKEN', data.refresh_token); + commit('SET_USERIFNO', data); + commit('DEL_ALL_TAG'); + commit('CLEAR_LOCK'); + } else { + Message({ + message: res.data.error_description, + type: 'error' + }) + } resolve(); }) })