From 4daf5f80a8a8502dec53b66e5591101e14c91a87 Mon Sep 17 00:00:00 2001 From: caill <815519168@qq.com> Date: Tue, 12 Dec 2023 16:49:30 +0800 Subject: [PATCH] login --- src/config/http.js | 5 +++-- src/pages/modules/login/login.vue | 34 ++++++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/config/http.js b/src/config/http.js index cf6921f..0434ddf 100644 --- a/src/config/http.js +++ b/src/config/http.js @@ -1,5 +1,5 @@ import axios from 'axios' -// import { Dialog } from './utils.js' +import { Dialog } from './utils.js' import store from '../vuex/store' import router from '@/router' import i18n from '../i18n/i18n' @@ -37,6 +37,7 @@ axios.interceptors.response.use( if (error && error.response) { switch (error.response.status) { case 400: + Dialog(error.message) break case 401: store.dispatch('setSignOut') @@ -57,7 +58,7 @@ export const post = (sevmethod, params) => { resolve(response.data) }, error => { // Dialog(error.message) - reject(error.message) + reject(error) }) .catch((error) => { reject(error) diff --git a/src/pages/modules/login/login.vue b/src/pages/modules/login/login.vue index a4fff67..2b73ec6 100644 --- a/src/pages/modules/login/login.vue +++ b/src/pages/modules/login/login.vue @@ -151,23 +151,29 @@ export default { async _authlogin () { try { let res = await authlogin(this.username, encrypt(this.password)) - let obj = {} - obj = Object.assign({}, res) - this.$store.dispatch('userInfo', JSON.stringify(obj)) - this.hide() - this.$router.push('/index/home') + if (res.code === '1') { + let obj = {} + obj = Object.assign({}, res.result) + this.$store.dispatch('userInfo', JSON.stringify(obj)) + this.hide() + this.$router.push('/index/home') + } else { + this.Dialog(res.desc) + } } catch (err) { this.disabled = false // this.toast(err) - const loading = this.$loading({ - lock: true, - text: this.$t('common.loading'), - spinner: 'el-icon-loading', - background: 'rgba(0, 0, 0, 0.7)' - }) - setTimeout(() => { - loading.close() - }, 4000) + if (err.status !== 400) { + const loading = this.$loading({ + lock: true, + text: this.$t('common.loading'), + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + setTimeout(() => { + loading.close() + }, 4000) + } } }, show (e) {