setCache(){
    if(this.judgeTime()){ //判断缓存是否过期,过期就重新添加一个
    wx.setStorageSync('oldTime',this.oldTime());
    }
}
judgeTime(){ //判断缓存是否过期
      let nowTime = Date.now();
      let oldTime = wx.getStorageSync('oldTime');
      if(oldTime && nowTime < oldTime){
       return false;
      }
      return true;
    }
 oldTime(){ //返回以现在为准的3天后的时间
      return Date.now() + 259200000; //毫秒(72小时)
    }
    this.setCache();

 

 

原文地址:https://blog.csdn.net/frank_hehe/article/details/106471555?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control。如有侵权联系删除

相关文章:

  • 2021-12-12
  • 2022-01-07
  • 2021-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-11-11
  • 2021-09-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-24
  • 2022-02-08
  • 2022-02-20
  • 2021-05-22
  • 2022-02-23
  • 2022-12-23
相关资源
相似解决方案