overseas/utils/cartCache.js

18 lines
432 B
JavaScript
Raw Normal View History

2024-03-21 18:05:36 +08:00
2024-03-21 17:52:58 +08:00
import { CART_TIME,CART_ID} from '@/config/cache';
import Cache from '../utils/cache';
export function checkCart() {
let cartTime = 0
if(Cache.get(CART_TIME)){
let time = Cache.get(CART_TIME)
cartTime = time + (2 * 60 * 60 * 1000); // 计算两个小时之后的时间戳
}
let newTime = Date.now();
if (cartTime < newTime) {
Cache.clear(CART_ID);
Cache.clear(CART_TIME);
return false;
} else {
return true;
}
}