Commit e86b9a80 by liwk

commit

1 parent 5f600791
...@@ -13,6 +13,7 @@ import { common } from '../api/api' ...@@ -13,6 +13,7 @@ import { common } from '../api/api'
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
let { meta: { authBase } } = to let { meta: { authBase } } = to
store.commit('jumpPath', to.name)
if (to.matched.some(recode => recode.meta.hasAuth)) { if (to.matched.some(recode => recode.meta.hasAuth)) {
const ua = navigator.userAgent.toLowerCase() const ua = navigator.userAgent.toLowerCase()
const params = getParams(window.location.href) const params = getParams(window.location.href)
...@@ -26,7 +27,7 @@ router.beforeEach((to, from, next) => { ...@@ -26,7 +27,7 @@ router.beforeEach((to, from, next) => {
next() next()
} else { } else {
let [redirectUrl] = window.location.href.split('?') let [redirectUrl] = window.location.href.split('?')
getSessionId(redirectUrl, { to, from, next }, authBase ? 'snsapi_base' : 'snsapi_userinfo') getSessionId(redirectUrl, authBase ? 'snsapi_base' : 'snsapi_userinfo')
} }
return return
} else { } else {
...@@ -38,20 +39,15 @@ router.beforeEach((to, from, next) => { ...@@ -38,20 +39,15 @@ router.beforeEach((to, from, next) => {
} }
}) })
const getSessionId = (redirectUrl, route, scope) => { const getSessionId = (redirectUrl, scope) => {
const params = getParams(window.location.href) const params = getParams(window.location.href)
if (params.code) { if (params.code) {
common.getSessionId({ code: params.code, state: scope }).then(res => { common.getSessionId({ code: params.code, state: scope }).then(res => {
if (res) { if (res) {
store.commit('jumpPath', route.to.name)
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
setUserInfo(data) setUserInfo(data)
} } else {
// else if (code == '-1' && errId == '1013') {
// window.vm.$router.replace({ name: 'common.phoneLogin' })
// }
else {
Notify({ type: 'danger', message }) Notify({ type: 'danger', message })
} }
} else { } else {
......
...@@ -112,6 +112,7 @@ export default { ...@@ -112,6 +112,7 @@ export default {
}, 1 * 1000) }, 1 * 1000)
}, },
login () { login () {
let { lastPath } = this.$store.state
let { tel, sms } = this let { tel, sms } = this
if (!rex.test(tel)) { if (!rex.test(tel)) {
this.showToast('请填写正确的手机号') this.showToast('请填写正确的手机号')
...@@ -128,6 +129,7 @@ export default { ...@@ -128,6 +129,7 @@ export default {
if (code == 0) { if (code == 0) {
sessionStorage.setItem('GL_EQUITY_USER_INFO', JSON.stringify(data)) sessionStorage.setItem('GL_EQUITY_USER_INFO', JSON.stringify(data))
this.$store.commit('setUserInfo', data) this.$store.commit('setUserInfo', data)
window.vm.$router.replace({ name: lastPath })
} else { } else {
this.showToast(message) this.showToast(message)
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!