overseas/utils/cartCache.js

26 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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;
}
}