|
|
|
@ -4,10 +4,13 @@ import constant from './constant' |
|
|
|
let storageKey = 'storage_data' |
|
|
|
|
|
|
|
// 存储节点变量名
|
|
|
|
let storageNodeKeys = [constant.avatar, constant.name, constant.userInfo, constant.loginInfo] |
|
|
|
let storageNodeKeys = [ |
|
|
|
constant.avatar, constant.name, |
|
|
|
constant.userInfo, constant.loginInfo |
|
|
|
] |
|
|
|
|
|
|
|
const storage = { |
|
|
|
set: function(key, value) { |
|
|
|
set: (key, value) => { |
|
|
|
if (storageNodeKeys.indexOf(key) != -1) { |
|
|
|
let tmp = uni.getStorageSync(storageKey) |
|
|
|
tmp = tmp ? tmp : {} |
|
|
|
@ -15,16 +18,16 @@ const storage = { |
|
|
|
uni.setStorageSync(storageKey, tmp) |
|
|
|
} |
|
|
|
}, |
|
|
|
get: function(key) { |
|
|
|
get: (key) => { |
|
|
|
let storageData = uni.getStorageSync(storageKey) || {} |
|
|
|
return storageData[key] || "" |
|
|
|
}, |
|
|
|
remove: function(key) { |
|
|
|
remove: (key) => { |
|
|
|
let storageData = uni.getStorageSync(storageKey) || {} |
|
|
|
delete storageData[key] |
|
|
|
uni.setStorageSync(storageKey, storageData) |
|
|
|
}, |
|
|
|
clean: function() { |
|
|
|
clean: () => { |
|
|
|
uni.removeStorageSync(storageKey) |
|
|
|
} |
|
|
|
} |
|
|
|
|