mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2025-04-06 03:57:50 +08:00
token and user
This commit is contained in:
parent
ef41935b28
commit
f464cb3ce1
@ -8,7 +8,8 @@ router.beforeEach((to, from, next) => {
|
|||||||
// store.dispatch('user/fedLogOut').then(() => {
|
// store.dispatch('user/fedLogOut').then(() => {
|
||||||
// })
|
// })
|
||||||
const loginStatus = Number(store.getters.loginStatus)
|
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)
|
document.title = getPageTitle(to.meta.title)
|
||||||
if (loginStatus === 0) {
|
if (loginStatus === 0) {
|
||||||
// 微信未授权登录跳转到授权登录页面
|
// 微信未授权登录跳转到授权登录页面
|
||||||
|
@ -7,6 +7,10 @@ const UserInfoKey = 'User-Info' // 用户信息 {} {...}
|
|||||||
|
|
||||||
export function loadLoginStatus() {
|
export function loadLoginStatus() {
|
||||||
return cookies.get(LoginStatusKey) || 0
|
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) {
|
// export function saveLoginStatus(status) {
|
||||||
@ -14,16 +18,22 @@ export function loadLoginStatus() {
|
|||||||
// return status
|
// return status
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
export function saveLoginStatus(status) {
|
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
|
||||||
|
// var exp = new Date()
|
||||||
|
// exp.setTime(exp.getTime() + 5 * 60 * 1000)
|
||||||
|
// document.cookie = LoginStatusKey + '=' + escape(status) + ';expires=' + exp.toGMTString()
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeLoginStatus() {
|
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)
|
cookies.remove(LoginStatusKey)
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div class="user-info-container">
|
<div class="user-info-container">
|
||||||
<div class="user-info-warpper">
|
<div class="user-info-warpper">
|
||||||
<div class="user-info">
|
<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-info-center">
|
||||||
<div class="user-name">{{ vipInfo.nickName|formatName }}<span class="user-level"></span></div>
|
<div class="user-name">{{ vipInfo.nickName|formatName }}<span class="user-level"></span></div>
|
||||||
<div class="user-code">代购编号:{{ vipInfo.userCode }}</div>
|
<div class="user-code">代购编号:{{ vipInfo.userCode }}</div>
|
||||||
@ -68,7 +68,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
qrcodeVisible: false,
|
qrcodeVisible: false,
|
||||||
codeVisible: false,
|
codeVisible: false,
|
||||||
vipInfo: {},
|
vipInfo: null,
|
||||||
qrSrc: '',
|
qrSrc: '',
|
||||||
qrTitle: '',
|
qrTitle: '',
|
||||||
qrTips: '',
|
qrTips: '',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user