chore: optimize the code; 🌟

This commit is contained in:
iczer 2020-07-15 19:32:43 +08:00
parent 3ff12474cd
commit 687a3adc37
3 changed files with 15 additions and 16 deletions

View File

@ -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
}
}
}
}

View File

@ -7,7 +7,7 @@ import {request, METHOD} from '@/utils/request'
* @param password 账户密码
* @returns {Promise<AxiosResponse<T>>}
*/
function login(name, password) {
async function login(name, password) {
return request(LOGIN, METHOD.POST, {
name: name,
password: password

View File

@ -6,7 +6,7 @@ const METHOD = {
}
/**
* axios请求函数
* axios请求
* @param url 请求地址
* @param method {METHOD} http method
* @param params 请求参数