Commit e86b9a80 by liwk

commit

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