mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-09 05:16:44 +08:00
本地缓存存redis并从redis中获取方法修改
This commit is contained in:
@@ -344,3 +344,21 @@ export function getUniversalCodeLst(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// redis存数据
|
||||
export function getCacheRedis(data) {
|
||||
return request({
|
||||
url: getUrl('/app/cacheConfig/getCacheRedis', 1),
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// redis取数据
|
||||
export function setCacheRedis(data) {
|
||||
return request({
|
||||
url: getUrl('/app/cacheConfig/setCacheRedis', 1),
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,28 +1,53 @@
|
||||
import {AESCacheEncrypt,AESCacheDecrypt} from '@/assets/js/utils/cryptoJsUtil'
|
||||
import configApp from '@/config'
|
||||
import cacheKeys from '@/assets/js/utils/needCacheKey'
|
||||
import { getCacheRedis, setCacheRedis } from '@/api/ebiz/sale/sale'
|
||||
export default {
|
||||
async setCacheRedis(params){
|
||||
await setCacheRedis(params)
|
||||
},
|
||||
setLocItem: function(key, value) {
|
||||
const exist = cacheKeys.encodeKeys.find(item => {
|
||||
return item === key
|
||||
})
|
||||
//设置localStorage 值
|
||||
if (cacheKeys.isAll || exist) {
|
||||
window.localStorage.setItem(key, AESCacheEncrypt(value, configApp.CACHE_ENCRYP))
|
||||
let params = {
|
||||
key: key,
|
||||
value: AESCacheEncrypt(value, configApp.CACHE_ENCRYP)
|
||||
}
|
||||
this.setCacheRedis(params)
|
||||
} else {
|
||||
window.localStorage.setItem(key, value)
|
||||
let params = {
|
||||
key: key,
|
||||
value: AESCacheEncrypt(value, configApp.CACHE_ENCRYP)
|
||||
}
|
||||
this.setCacheRedis(params)
|
||||
}
|
||||
},
|
||||
|
||||
async getCacheRedis(params){
|
||||
let resultData = ''
|
||||
await getCacheRedis(params).then(res=>{
|
||||
if(res){
|
||||
resultData = res
|
||||
}
|
||||
})
|
||||
return resultData
|
||||
},
|
||||
getLocItem: function(key) {
|
||||
// 获取localStorage 中值
|
||||
let value = window.localStorage.getItem(key)
|
||||
if (value && value != '') {
|
||||
const exist = cacheKeys.encodeKeys.find(item => {
|
||||
return item === key
|
||||
})
|
||||
if (cacheKeys.isAll || exist) {
|
||||
return AESCacheDecrypt(value, configApp.CACHE_ENCRYP)
|
||||
let value = ''
|
||||
if(key != 'token') {
|
||||
let params = {
|
||||
key: key
|
||||
}
|
||||
value = this.getCacheRedis(params).then(res=>{
|
||||
console.log(res)
|
||||
debugger
|
||||
})
|
||||
|
||||
} else {
|
||||
value = window.localStorage.getItem(key)
|
||||
}
|
||||
return value
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user