token and user

This commit is contained in:
406803045 2019-06-14 15:16:48 +08:00
parent ef41935b28
commit f464cb3ce1
3 changed files with 19 additions and 8 deletions

View File

@ -8,7 +8,8 @@ router.beforeEach((to, from, next) => {
// store.dispatch('user/fedLogOut').then(() => {
// })
const loginStatus = Number(store.getters.loginStatus)
console.log('loginStatus='+loginStatus)
console.log('loginStatus=' + loginStatus)
console.log('token=' + store.getters.token)
document.title = getPageTitle(to.meta.title)
if (loginStatus === 0) {
// 微信未授权登录跳转到授权登录页面

View File

@ -7,6 +7,10 @@ const UserInfoKey = 'User-Info' // 用户信息 {} {...}
export function loadLoginStatus() {
return cookies.get(LoginStatusKey) || 0
// var arr
// var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
// if ((arr = document.cookie.match(reg))) return unescape(arr[2])
// else return null
}
// export function saveLoginStatus(status) {
@ -14,16 +18,22 @@ export function loadLoginStatus() {
// return status
// }
export function saveLoginStatus(status) {
//storage.set(LoginStatusKey, status)
var date=new Date();
date.setTime(date.getTime()+5*60*1000); //设置date为当前时间+5分
document.cookie=LoginStatusKey+"="+status+"; expires="+date.toGMTString() // 将date赋值给expires
// storage.set(LoginStatusKey, status)
var date = new Date()
date.setTime(date.getTime() + 5 * 60 * 1000) // 设置date为当前时间+5分
document.cookie = LoginStatusKey + '=' + status + '; expires=' + date.toGMTString() // 将date赋值给expires
// var exp = new Date()
// exp.setTime(exp.getTime() + 5 * 60 * 1000)
// document.cookie = LoginStatusKey + '=' + escape(status) + ';expires=' + exp.toGMTString()
return status
}
export function removeLoginStatus() {
// var exp = new Date()
// exp.setTime(exp.getTime() - 1)
// var cval = saveLoginStatus(LoginStatusKey)
// if (cval != null) document.cookie = LoginStatusKey + '=' + cval + ';expires=' + exp.toGMTString()
cookies.remove(LoginStatusKey)
return ''
}

View File

@ -5,7 +5,7 @@
<div class="user-info-container">
<div class="user-info-warpper">
<div class="user-info">
<img class="user-avatar" :src="vipInfo.userImg" alt="用户头像">
<img class="user-avatar" :src="vipInfo.userImg">
<div class="user-info-center">
<div class="user-name">{{ vipInfo.nickName|formatName }}<span class="user-level"></span></div>
<div class="user-code">代购编号{{ vipInfo.userCode }}</div>
@ -68,7 +68,7 @@ export default {
return {
qrcodeVisible: false,
codeVisible: false,
vipInfo: {},
vipInfo: null,
qrSrc: '',
qrTitle: '',
qrTips: '',