Skip to content

Commit

Permalink
feat: add interaction for login page
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwa committed Oct 2, 2018
1 parent 570aba8 commit 9a498bf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"dev": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack.dev.js --hotOnly",
"build": "yarn clean && cross-env NODE_ENV=production webpack --config config/webpack.prod.js --progress",
"clean": "rm -vrf dist/* docs/*",
"precommit": "lint-staged"
"precommit": "lint-staged",
"mock": "node mock/server"
},
"dependencies": {
"@babel/runtime": "^7.0.0",
Expand Down
30 changes: 21 additions & 9 deletions src/view/Login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,31 @@ export default {
// `POST` to server, and activate loading animation
// check `errno` from response data, 0 to route, 1 to return false
this.loading = true
userLogin({
username: this.loginForm.username,
password: this.loginForm.password
}).then(res => {
const data = res.data
if (data.errno !== 0) {
console.error(`[${res.status}]: 验证失败`)
return
}
if (!window.localStorage) return
window.localStorage.setItem('__vue_design_pro__', res.data.token)
this.$router.replace('/dashboard/analysis')
})
.then(res => {
const data = res.data
if (data.errno !== 0) {
console.error(`[${res.status}]: 验证失败`)
this.$message({
showClose: true,
message: '用户名或密码错误',
type: 'error'
})
this.loading = false
return
}
if (!window.localStorage) return
window.localStorage.setItem('__vue_design_pro__', res.data.token)
this.loading = false
this.$router.replace('/dashboard/analysis')
})
})
}
}
Expand Down

0 comments on commit 9a498bf

Please sign in to comment.