cartCache.js 1.0 KB

1234567891011121314151617181920212223242526
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. import { CART_TIME,CART_ID} from '@/config/cache';
  11. import Cache from '../utils/cache';
  12. export function checkCart() {
  13. let cartTime = 0
  14. if(Cache.get(CART_TIME)){
  15. let time = Cache.get(CART_TIME)
  16. cartTime = time + (2 * 60 * 60 * 1000); // 计算两个小时之后的时间戳
  17. }
  18. let newTime = Date.now();
  19. if (cartTime < newTime) {
  20. Cache.clear(CART_ID);
  21. Cache.clear(CART_TIME);
  22. return false;
  23. } else {
  24. return true;
  25. }
  26. }