Files
JayuCloud/WeChatProgram/utils/storage.js
T

32 lines
636 B
JavaScript

const STORAGE_KEYS = {
ACCESS_TOKEN: 'accessToken',
REFRESH_TOKEN: 'refreshToken',
USER_INFO: 'userInfo',
NEED_SET_PASSWORD: 'needSetPassword',
PREFERRED_MINI_LOGIN_SHOP_ID: 'preferredMiniLoginShopId'
}
function getStorage(key, defaultValue) {
try {
const value = wx.getStorageSync(key)
return value === '' || value === undefined ? defaultValue : value
} catch (error) {
return defaultValue
}
}
function setStorage(key, value) {
wx.setStorageSync(key, value)
}
function removeStorage(key) {
wx.removeStorageSync(key)
}
module.exports = {
STORAGE_KEYS,
getStorage,
setStorage,
removeStorage
}