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

登录优化

上级 af3952dc
......@@ -65,7 +65,8 @@ export default {
// 接口请求
handleRequest() {
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)
this.loading = false
})
......@@ -73,8 +74,11 @@ export default {
// 登录成功
handleSuccess(response) {
this.$message({ type: 'success', message: this.$t('loginPwd.successMessage') })
const { info } = response.data
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 {
this.$emit('success', response)
}
......
......@@ -75,7 +75,8 @@ export default {
// 登录
handleRequest() {
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)
this.loading = false
})
......@@ -83,8 +84,11 @@ export default {
// 登录成功
handleSuccess(response) {
this.$message({ type: 'success', message: this.$t('loginCode.successMessage') })
const { info } = response.data
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 {
this.$emit('success', response)
}
......
......@@ -12,8 +12,9 @@ import Element from 'element-ui'
Vue.use(VueRouter)
const router = createRouter()
router.beforeEach((to, from, next) => {
const { rd } = to.query
rd && window.sessionStorage.setItem('next_url', rd)
const { rd, service } = to.query
const nextUrl = rd || service
nextUrl && window.sessionStorage.setItem('next_url', nextUrl)
next()
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论