Files
SEONexus/code/public/template/shikong/huiyuan/js/public/localstorage.js
2025-04-21 17:49:17 +08:00

37 lines
880 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//本地储存
export const storageObj = {
loginStatus: window.location.hostname+'loginStatus', //登录状态
userInfo:window.location.hostname+'userInfo',
tokenKey : window.location.hostname+'mi_login_token', //token 本地储存key
isMember: window.location.hostname+'isMember', //是否会员 本地储存key
isBingPhoneReturn: window.location.hostname+'isBingPhoneReturn', //是否绑定手机页面返回
}
/**
* 获取登录状态
*/
export function getLoginStatus() {
return localStorage.getItem(storageObj.loginStatus) || false;
}
/**
* 获取会员信息
*/
export function getUserInfo() {
let userInfo = localStorage.getItem(storageObj.userInfo);
// 如果 data 不为 null 且长度大于 0解析 JSON否则返回 null 或原始数据
return userInfo && userInfo.length > 0 ? JSON.parse(userInfo) : userInfo;
}