diff --git a/src/pages/login/Login.vue b/src/pages/login/Login.vue index 2b3a5a9..c6deeef 100644 --- a/src/pages/login/Login.vue +++ b/src/pages/login/Login.vue @@ -100,22 +100,21 @@ export default { this.logging = true const name = this.form.getFieldValue('name') const password = this.form.getFieldValue('password') - // 登录 - login(name, password) - .then((res) => { - this.logging = false - const result = res.data - if (result.code >= 0) { - const user = result.data.user - this.$router.push('/dashboard/workplace') - this.$store.commit('account/setUser', user) - this.$message.success(result.message, 3) - } else { - this.error = result.message - } - }) + login(name, password).then(this.afterLogin) } }) + }, + afterLogin(res) { + this.logging = false + const result = res.data + if (result.code >= 0) { + const user = result.data.user + this.$router.push('/dashboard/workplace') + this.$store.commit('account/setUser', user) + this.$message.success(result.message, 3) + } else { + this.error = result.message + } } } } diff --git a/src/services/user.js b/src/services/user.js index c9d00e2..b6447c3 100644 --- a/src/services/user.js +++ b/src/services/user.js @@ -7,7 +7,7 @@ import {request, METHOD} from '@/utils/request' * @param password 账户密码 * @returns {Promise>} */ -function login(name, password) { +async function login(name, password) { return request(LOGIN, METHOD.POST, { name: name, password: password diff --git a/src/utils/request.js b/src/utils/request.js index c0871a4..84e16a1 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -6,7 +6,7 @@ const METHOD = { } /** - * axios请求函数 + * axios请求 * @param url 请求地址 * @param method {METHOD} http method * @param params 请求参数