解决砍价页面未登录情况下,跳转登录页面无法回跳的问题

This commit is contained in:
Gaoxs
2020-09-19 16:55:50 +08:00
parent 6a33c4ec80
commit 5b8633f4b6
4 changed files with 20 additions and 25 deletions

View File

@ -335,11 +335,9 @@ export const handleGetUserInfo = () => {
getUserInfo().then(res => {
console.log('获取用户信息')
store.dispatch('setUserInfo', res.data)
console.log('获取用户信息后跳转回显的页面')
let redirect = cookie.get('redirect')
let redirect = cookie.get('redirect')
if (redirect) {
reLaunch({
path: redirect,
@ -347,14 +345,13 @@ export const handleGetUserInfo = () => {
});
return
}
reLaunch({
path: '/pages/home/index',
// query
});
// var pages = getCurrentPages() //获取加载的页面
// debugger
// var currentPage = pages[pages.length - 1] //获取当前页面的对象
// let url = "/pages/home/index"
// let query = {}
@ -390,7 +387,6 @@ export const handleGetUserInfo = () => {
// });
// } else {
// let redirect = cookie.get('redirect')
// debugger
// if (redirect) {
// reLaunch({
@ -498,7 +494,6 @@ export const handleLoginStatus = (location, complete, fail, success) => {
// 是否可以访问
let isAuth = false
console.log('即将跳转', location, parseUrl(location))
// 从 location 中获取当前urllocation typeof string || object
@ -521,6 +516,7 @@ export const handleLoginStatus = (location, complete, fail, success) => {
}
return new Promise((resolve, reject) => {
if (isAuth) {
// 有token
if (path == '/pages/home/index' || path == '/pages/shop/GoodsClass/index' || path == '/pages/shop/ShoppingCart/index' || path == '/pages/user/User/index') {
@ -640,11 +636,12 @@ export function routerPermissions(url, type) {
// })
// }
} else {
console.log(path)
// 如果不是小程序跳转到登录页
cookie.set('redirect', path)
push({
path: '/pages/user/Login/index',
})
cookie.set('redirect', path)
}
}