var dtime = '_deadtime';
function cachePut(k, v, t) {
wx.setStorageSync(k,v)
var seconds = parseInt(t);
if (seconds > 0) {
var timestamp = Date.parse(new Date());
timestamp = timestamp / 1000 + seconds;
wx.setStorageSync(k + dtime, timestamp + "")
} else {
wx.removeStorageSync(k + dtime)
}
}
function cacheGet(k, def) {
var deadtime = parseInt(wx.getStorageSync(k + dtime))
if (deadtime) {
if (parseInt(deadtime) < Date.parse(new Date()) / 1000) {
if (def) { return def; } else { return; }
}
}
var res = wx.getStorageSync(k);
if (res) {
return res;
} else {
return def;
}
}
function cacheRem(k) {
wx.removeStorageSync(k);
wx.removeStorageSync(k + dtime);
}
function cacheClear() {
wx.clearStorageSync();
}
module.exports = {
cachePut: cachePut,
cacheGet: cacheGet,
cacheRem: cacheRem,
cacheClear: cacheClear,
}
你好!请问我这个问题属不属于这种情况,如果是有偿请你帮我解决一下,谢谢。已发贴https://developers.weixin.qq.com/community/develop/doc/000084fa6b03c06db66bd5c385b400
需要触发后拿到seconds才会清除么?