12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import siteInfo from 'siteInfo';
- const clearStorage = function() {
- uni.clearStorageSync();
- };
- const setStorageSync = function(key, data) {
- // #ifdef H5
- key += `_${siteInfo.id}` + `_${siteInfo.platform}`;
- // #endif
- uni.setStorageSync(key, data);
- };
- const getStorageSync = function(key) {
- // #ifdef H5
- key += `_${siteInfo.id}` + `_${siteInfo.platform}`;
- // #endif
- return uni.getStorageSync(key);
- };
- const getStorage = function({key, success, fail}) {
- // #ifdef H5
- key += `_${siteInfo.id}` + `_${siteInfo.platform}`;
- // #endif
- uni.getStorage({
- key: key,
- success: function(res) {
- success && success(res);
- },
- fail: function () {
- fail && fail();
- }
- });
- }
- const setStorage = function({key, data, success, fail}) {
- // #ifdef H5
- key += `_${siteInfo.id}` + `_${siteInfo.platform}`;
- // #endif
- uni.setStorage({
- key: key,
- data: data,
- success: function(res) {
- success && success(res);
- },
- fail: function () {
- fail && fail();
- }
- });
- }
- const removeStorageSync = function(key) {
- // #ifdef H5
- key += `_${siteInfo.id}` + `_${siteInfo.platform}`;
- // #endif
- uni.removeStorageSync(key);
- };
- const removeStorage = function({key, success, fail}) {
- // #ifdef H5
- key += `_${siteInfo.id}` + `_${siteInfo.platform}`;
- // #endif
- uni.removeStorage({
- key: key,
- success: function(res) {
- success && success(res);
- },
- fail: function () {
- fail && fail();
- }
- })
- }
- export { clearStorage, setStorageSync, getStorageSync, removeStorageSync, getStorage, setStorage, removeStorage }
|