提交 494f66ca authored 作者: 王鹏飞's avatar 王鹏飞

登录优化

上级 af3952dc
...@@ -65,7 +65,8 @@ export default { ...@@ -65,7 +65,8 @@ export default {
// 接口请求 // 接口请求
handleRequest() { handleRequest() {
this.loading = true this.loading = true
api.login(this.ruleForm, { headers: this.headers }).then(response => { const params = Object.assign({}, this.$route.query, this.ruleForm)
api.login(params, { headers: this.headers }).then(response => {
response.code === 0 ? this.handleSuccess(response) : this.$message.error(response.msg) response.code === 0 ? this.handleSuccess(response) : this.$message.error(response.msg)
this.loading = false this.loading = false
}) })
...@@ -73,8 +74,11 @@ export default { ...@@ -73,8 +74,11 @@ export default {
// 登录成功 // 登录成功
handleSuccess(response) { handleSuccess(response) {
this.$message({ type: 'success', message: this.$t('loginPwd.successMessage') }) this.$message({ type: 'success', message: this.$t('loginPwd.successMessage') })
const { info } = response.data
if (this.nextUrl) { if (this.nextUrl) {
window.location.href = this.nextUrl let query = info ? `id=${info.id}&username=${info.username}&mobile=${info.mobile}` : ''
query = this.nextUrl.includes('?') ? `&${query}` : `?${query}`
window.location.href = this.nextUrl + query
} else { } else {
this.$emit('success', response) this.$emit('success', response)
} }
......
...@@ -75,7 +75,8 @@ export default { ...@@ -75,7 +75,8 @@ export default {
// 登录 // 登录
handleRequest() { handleRequest() {
this.loading = true this.loading = true
api.login(this.ruleForm, { headers: this.headers }).then(response => { const params = Object.assign({}, this.$route.query, this.ruleForm)
api.login(params, { headers: this.headers }).then(response => {
response.code === 0 ? this.handleSuccess(response) : this.$message.error(response.msg) response.code === 0 ? this.handleSuccess(response) : this.$message.error(response.msg)
this.loading = false this.loading = false
}) })
...@@ -83,8 +84,11 @@ export default { ...@@ -83,8 +84,11 @@ export default {
// 登录成功 // 登录成功
handleSuccess(response) { handleSuccess(response) {
this.$message({ type: 'success', message: this.$t('loginCode.successMessage') }) this.$message({ type: 'success', message: this.$t('loginCode.successMessage') })
const { info } = response.data
if (this.nextUrl) { if (this.nextUrl) {
window.location.href = this.nextUrl let query = info ? `id=${info.id}&username=${info.username}&mobile=${info.mobile}` : ''
query = this.nextUrl.includes('?') ? `&${query}` : `?${query}`
window.location.href = this.nextUrl + query
} else { } else {
this.$emit('success', response) this.$emit('success', response)
} }
......
...@@ -12,8 +12,9 @@ import Element from 'element-ui' ...@@ -12,8 +12,9 @@ import Element from 'element-ui'
Vue.use(VueRouter) Vue.use(VueRouter)
const router = createRouter() const router = createRouter()
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const { rd } = to.query const { rd, service } = to.query
rd && window.sessionStorage.setItem('next_url', rd) const nextUrl = rd || service
nextUrl && window.sessionStorage.setItem('next_url', nextUrl)
next() next()
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论