码迷,mamicode.com
首页 > 微信 > 详细

小程序 缓存过期问题

时间:2019-06-20 18:47:10      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:fft   mod   推送   port   程序   current   bsp   exp   设置   

1 module.exports = {
2   set: function(k, v, time) {
3     var effTime = parseInt(Date.parse(new Date())) + 86400000 * time; //有效时期时间戳
4     wx.setStorageSync(k, v ? v : effTime);
5   }
6 };
7 //86400000 就是一天等于多少毫秒

 

1  // 点击推送通知按钮设置7天有效时间缓存
2   openNotice: function() {
3     Storage.set(‘oldStorTime‘, ‘‘, 7); 
4   }

 

1 //判断
2 Off:function(){
3      var currentTime = Date.parse(new Date()); //当前时间戳
4      if (currentTime < wx.getStorageSync(‘oldStorTime‘)) {
5        //console.log("缓存时间有效")
6      } else {
7       //console.log("缓存时间已过期")
8      }
9 }

 

小程序 缓存过期问题

标签:fft   mod   推送   port   程序   current   bsp   exp   设置   

原文地址:https://www.cnblogs.com/hermitks/p/11060537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!