| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import $C from './config.js'
- const {
- brandId,
- branchId
- } = uni.getStorageSync('brandInfo')
- export default {
- // 获取存储列表数据
- getStorage(key) {
- // let data = null;
- // // #ifdef H5
- // if($C.env === 'dev'){
- // data = window.sessionStorage.getItem(key)
- // } else {
- // data = uni.getStorageSync(key)
- // }
- // // #endif
- // // #ifndef H5
- // data = uni.getStorageSync(key)
- // // #endif
- return uni.getStorageSync(key)
- },
- // 设置存储
- setStorage(key, data) {
- // // #ifdef H5
- // if($C.env === 'dev'){
- // return window.sessionStorage.setItem(key,data)
- // } else {
- // return uni.setStorageSync(key,data)
- // }
- // // #endif
- // // #ifndef H5
- return uni.setStorageSync(key, data)
- // // #endif
- },
- // 删除存储
- removeStorage(key) {
- // // #ifdef H5
- // if($C.env === 'dev'){
- // return window.sessionStorage.removeItem(key);
- // } else {
- // return uni.removeStorageSync(key)
- // }
- // // #endif
- // // #ifndef H5
- return uni.removeStorageSync(key)
- // // #endif
- },
- setUserInfo(userInfoData) {
- // console.log(userInfoData);
- var userInfoStr = uni.setStorageSync("userInfo", JSON.stringify(userInfoData))
- console.log(userInfoStr);
- },
- getUserInfo() {
- var userInfoData = uni.getStorageSync(`userInfo_${brandId}`);
- return userInfoData;
- },
- getConfigName(data, key, value, nameKey) {
- if (Array.isArray(data)) {
- let result = data.find(item => item[key] == value)
- return result && result[nameKey] || ''
- }
- },
- getDataName(key) {
- console.log(9000, key, `${key}_${brandId}_${branchId}`)
- return `${key}_${brandId}_${branchId}`
- }
- }
|