提交
This commit is contained in:
29
甲情_甲意/miniprogram/app.js
Normal file
29
甲情_甲意/miniprogram/app.js
Normal file
@ -0,0 +1,29 @@
|
||||
App({
|
||||
onLaunch() {
|
||||
my.getStorage({
|
||||
key: 'userInfo',
|
||||
success: (res) => {
|
||||
const userInfo = res.data;
|
||||
const currentTimestamp = new Date().getTime();
|
||||
const lastLoginTimestamp = userInfo.timestamp; // 获取上次登录时间戳
|
||||
// 计算时间差(单位:毫秒)
|
||||
const timeDiff = currentTimestamp - lastLoginTimestamp;
|
||||
const oneDay = 86400* 1000; // 24小时的毫秒数
|
||||
// 如果时间差大于24小时,则清除缓存
|
||||
if (timeDiff > oneDay) {
|
||||
console.log('超过24小时,清除缓存');
|
||||
my.removeStorage({
|
||||
key: 'userInfo',
|
||||
success: function () {
|
||||
console.log('用户信息已删除');
|
||||
},
|
||||
fail: function (err) {
|
||||
console.error('删除失败:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
})
|
Reference in New Issue
Block a user