123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- module.exports = {
- setStore: setStore,
- getStore: getStore,
- clearAll: clearAll,
- remove: remove,
- }
- //同步储存缓存数据
- function setStore(key, value) {
- try {
- // console.log("gasdfasfqwerqwerqr===0000==" + JSON.stringify(value));
- wx.setStorageSync(key, value);
- } catch (e) {
- // console.log("gasdfasfqwerqwerqr===111==" + JSON.stringify(e));
- }
- };
- //同步取出缓存数据
- function getStore(key) {
- try {
- // 使用同步方法获取数据
- const list = wx.getStorageSync(key);
- // console.log("gasdfasfqwerqwerqr===222==" + JSON.stringify(list));
- if (list) {
- return list;
- } else {
- return [];
- }
- } catch (e) {
- return [];
- }
- };
- ///不清除的有
- // {token,chatRecord,freeTimes}
- //清空数据
- function clearAll() {
- const constant = require('./constant.js');
- removeByKey(constant.param.userInfo);
- }
- //移除指定key
- function remove(key) {
- try {
- wx.removeStorageSync(key)
- } catch (e) {}
- }
|