chore: optimize the code; 🌟

master
iczer 4 years ago
parent 3ff12474cd
commit 687a3adc37
  1. 27
      src/pages/login/Login.vue
  2. 2
      src/services/user.js
  3. 2
      src/utils/request.js

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

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

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

Loading…
Cancel
Save