2026-04-01 15:18:35 +08:00
|
|
|
const STORAGE_KEYS = {
|
|
|
|
|
ACCESS_TOKEN: 'accessToken',
|
|
|
|
|
REFRESH_TOKEN: 'refreshToken',
|
|
|
|
|
USER_INFO: 'userInfo',
|
2026-04-02 13:20:28 +08:00
|
|
|
NEED_SET_PASSWORD: 'needSetPassword',
|
2026-04-20 16:02:57 +08:00
|
|
|
PREFERRED_MINI_LOGIN_SHOP_ID: 'preferredMiniLoginShopId',
|
|
|
|
|
DEVICE_ID: 'miniDeviceId'
|
2026-04-01 15:18:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|