diff --git a/src/api/ebiz/sale/sale.js b/src/api/ebiz/sale/sale.js index b7435ced8..f0ff5ee8b 100644 --- a/src/api/ebiz/sale/sale.js +++ b/src/api/ebiz/sale/sale.js @@ -343,4 +343,22 @@ export function getUniversalCodeLst(data) { method: 'post', data }) -} \ No newline at end of file +} + +// 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 + }) +} diff --git a/src/assets/js/utils/cacheUtils.js b/src/assets/js/utils/cacheUtils.js index 12b0845fa..2093012c3 100644 --- a/src/assets/js/utils/cacheUtils.js +++ b/src/assets/js/utils/cacheUtils.js @@ -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 },