202404 入场需要查看免责声明

This commit is contained in:
2024-05-26 20:25:06 +08:00
parent 8b1c94b806
commit 298a18e933
7 changed files with 100 additions and 41 deletions

View File

@@ -26,7 +26,36 @@ const getCurrentPageUrl = () => {
return url;
}
const setTimeOutStorage = (key,value,timeout) => {
let timestamp = Date.parse(new Date());
wx.setStorageSync(key,
{
'value': value,
'timeout': timestamp + timeout
})
}
const getTimeoutStorage = (key) => {
// 当前时间
let timestamp = Date.parse(new Date());
// 缓存中的过期时间
let data = wx.getStorageSync(key);
let data_expiration = data.timeout;
let value = data.value;
// 如果缓存中没有data_expiration说明也没有token还未登录
if (data_expiration) {
// 如果超时了,清除缓存,重新登录
if (timestamp > data_expiration) {
wx.removeStorageSync(key);
return null;
}
}
return value;
}
module.exports = {
formatTime: formatTime,
getCurrentPageUrl: getCurrentPageUrl
getCurrentPageUrl: getCurrentPageUrl,
setTimeOutStorage: setTimeOutStorage,
getTimeoutStorage: getTimeoutStorage
}