mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2025-09-19 14:00:01 +08:00
清除缓存
This commit is contained in:
parent
389595840b
commit
d682a549a5
@ -5,57 +5,59 @@ import wechatAuth from './plugins/wechatAuth' // 微信登录插件
|
|||||||
const qs = require('qs')
|
const qs = require('qs')
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
const loginStatus = Number(store.getters.loginStatus)
|
store.dispatch('user/fedLogOut').then(() => {
|
||||||
document.title = getPageTitle(to.meta.title)
|
})
|
||||||
if (loginStatus === 0) {
|
// const loginStatus = Number(store.getters.loginStatus)
|
||||||
// 微信未授权登录跳转到授权登录页面
|
// document.title = getPageTitle(to.meta.title)
|
||||||
const url = window.location.href
|
// if (loginStatus === 0) {
|
||||||
// 解决重复登录url添加重复的code与state问题
|
// // 微信未授权登录跳转到授权登录页面
|
||||||
const parseUrl = qs.parse(url.split('?')[1])
|
// const url = window.location.href
|
||||||
let loginUrl
|
// // 解决重复登录url添加重复的code与state问题
|
||||||
if (parseUrl.code && parseUrl.state) {
|
// const parseUrl = qs.parse(url.split('?')[1])
|
||||||
delete parseUrl.code
|
// let loginUrl
|
||||||
delete parseUrl.state
|
// if (parseUrl.code && parseUrl.state) {
|
||||||
loginUrl = `${url.split('?')[0]}?${qs.stringify(parseUrl)}`
|
// delete parseUrl.code
|
||||||
} else {
|
// delete parseUrl.state
|
||||||
loginUrl = url
|
// loginUrl = `${url.split('?')[0]}?${qs.stringify(parseUrl)}`
|
||||||
}
|
// } else {
|
||||||
// alert(loginUrl)
|
// loginUrl = url
|
||||||
wechatAuth.redirect_uri = loginUrl
|
// }
|
||||||
// 无论拒绝还是授权都设置成1
|
// // alert(loginUrl)
|
||||||
store.dispatch('user/setLoginStatus', 1)
|
// wechatAuth.redirect_uri = loginUrl
|
||||||
window.location.href = wechatAuth.authUrl
|
// // 无论拒绝还是授权都设置成1
|
||||||
} else if (loginStatus === 1) {
|
// store.dispatch('user/setLoginStatus', 1)
|
||||||
// 微信已经授权回调获取code
|
// window.location.href = wechatAuth.authUrl
|
||||||
try {
|
// } else if (loginStatus === 1) {
|
||||||
wechatAuth.returnFromWechat(to.fullPath)
|
// // 微信已经授权回调获取code
|
||||||
} catch (err) {
|
// try {
|
||||||
store.dispatch('user/setLoginStatus', 0)
|
// wechatAuth.returnFromWechat(to.fullPath)
|
||||||
location.reload()
|
// } catch (err) {
|
||||||
|
// store.dispatch('user/setLoginStatus', 0)
|
||||||
|
// location.reload()
|
||||||
|
// // next()
|
||||||
|
// }
|
||||||
|
// // 同意授权 to.fullPath 携带code参数,拒绝授权没有code参数
|
||||||
|
// // alert(to.fullPath)
|
||||||
|
// // 重新赋值,不然获取不到code
|
||||||
|
// const code = wechatAuth.code
|
||||||
|
// // alert(code)
|
||||||
|
// if (code) {
|
||||||
|
// store
|
||||||
|
// .dispatch('user/loginWechatAuth', code)
|
||||||
|
// .then(res => {
|
||||||
|
// store.dispatch('user/setLoginStatus', 2)
|
||||||
// next()
|
// next()
|
||||||
}
|
// })
|
||||||
// 同意授权 to.fullPath 携带code参数,拒绝授权没有code参数
|
// .catch(() => {
|
||||||
// alert(to.fullPath)
|
// store.dispatch('user/setLoginStatus', 0)
|
||||||
// 重新赋值,不然获取不到code
|
// location.reload()
|
||||||
const code = wechatAuth.code
|
// })
|
||||||
// alert(code)
|
// } else {
|
||||||
if (code) {
|
// store.dispatch('user/setLoginStatus', 0)
|
||||||
store
|
// location.reload()
|
||||||
.dispatch('user/loginWechatAuth', code)
|
// }
|
||||||
.then(res => {
|
// } else {
|
||||||
store.dispatch('user/setLoginStatus', 2)
|
// // alert(to.fullPath)
|
||||||
next()
|
// next()
|
||||||
})
|
// }
|
||||||
.catch(() => {
|
|
||||||
store.dispatch('user/setLoginStatus', 0)
|
|
||||||
location.reload()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
store.dispatch('user/setLoginStatus', 0)
|
|
||||||
location.reload()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// alert(to.fullPath)
|
|
||||||
next()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ export function saveLoginStatus(status) {
|
|||||||
//storage.set(LoginStatusKey, status)
|
//storage.set(LoginStatusKey, status)
|
||||||
var date=new Date();
|
var date=new Date();
|
||||||
date.setTime(date.getTime()+5*60*1000); //设置date为当前时间+5分
|
date.setTime(date.getTime()+5*60*1000); //设置date为当前时间+5分
|
||||||
document.cookie=LoginStatusKey+"="+status+"; expires="+date.toGMTString(); //将date赋值给expires
|
document.cookie=LoginStatusKey+"="+status+"; expires="+date.toGMTString() // 将date赋值给expires
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user