mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-09 11:06:43 +08:00
本地缓存存redis并从redis中获取方法修改
This commit is contained in:
@@ -343,4 +343,22 @@ export function getUniversalCodeLst(data) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
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 {AESCacheEncrypt,AESCacheDecrypt} from '@/assets/js/utils/cryptoJsUtil'
|
||||||
import configApp from '@/config'
|
import configApp from '@/config'
|
||||||
import cacheKeys from '@/assets/js/utils/needCacheKey'
|
import cacheKeys from '@/assets/js/utils/needCacheKey'
|
||||||
|
import { getCacheRedis, setCacheRedis } from '@/api/ebiz/sale/sale'
|
||||||
export default {
|
export default {
|
||||||
|
async setCacheRedis(params){
|
||||||
|
await setCacheRedis(params)
|
||||||
|
},
|
||||||
setLocItem: function(key, value) {
|
setLocItem: function(key, value) {
|
||||||
const exist = cacheKeys.encodeKeys.find(item => {
|
const exist = cacheKeys.encodeKeys.find(item => {
|
||||||
return item === key
|
return item === key
|
||||||
})
|
})
|
||||||
//设置localStorage 值
|
|
||||||
if (cacheKeys.isAll || exist) {
|
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 {
|
} 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) {
|
getLocItem: function(key) {
|
||||||
// 获取localStorage 中值
|
// 获取localStorage 中值
|
||||||
let value = window.localStorage.getItem(key)
|
let value = ''
|
||||||
if (value && value != '') {
|
if(key != 'token') {
|
||||||
const exist = cacheKeys.encodeKeys.find(item => {
|
let params = {
|
||||||
return item === key
|
key: key
|
||||||
})
|
|
||||||
if (cacheKeys.isAll || exist) {
|
|
||||||
return AESCacheDecrypt(value, configApp.CACHE_ENCRYP)
|
|
||||||
}
|
}
|
||||||
|
value = this.getCacheRedis(params).then(res=>{
|
||||||
|
console.log(res)
|
||||||
|
debugger
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
value = window.localStorage.getItem(key)
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user