diff --git a/components/SplashScreen.vue b/components/SplashScreen.vue index 711405c..20d000a 100644 --- a/components/SplashScreen.vue +++ b/components/SplashScreen.vue @@ -38,6 +38,13 @@ onMounted(() => { splashData = {} } + // 清理不是今天的缓存,只保留今天的记录 + const cleanedSplashData = {} + if (splashData[dateStr]) { + cleanedSplashData[dateStr] = splashData[dateStr] + } + splashData = cleanedSplashData + // 获取今天的显示次数 const todayCount = splashData[dateStr] || 0 diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 1b698ae..f0b6a9a 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -585,6 +585,21 @@ export default { if (!this.checkPhoneBound()) return + // 检查冷却时间 + const cooldownKey = 'avatar_update_cooldown' + const lastUpdate = uni.getStorageSync(cooldownKey) + const now = Date.now() + const cooldownDays = 7 + + if (lastUpdate && now - lastUpdate < cooldownDays * 24 * 60 * 60 * 1000) { + const daysRemaining = Math.ceil((cooldownDays * 24 * 60 * 60 * 1000 - (now - lastUpdate)) / (24 * 60 * 60 * 1000)) + uni.showToast({ + title: `头像修改冷却中,还需${daysRemaining}天`, + icon: 'none' + }) + return + } + uni.chooseImage({ count: 1, sizeType: ['compressed'], // 选择压缩图 @@ -615,6 +630,9 @@ export default { userInfo.avatar = data.avatar || base64 uni.setStorageSync('user_info', userInfo) + // 记录修改时间(7天冷却) + uni.setStorageSync('avatar_update_cooldown', Date.now()) + uni.hideLoading() uni.showToast({ title: '头像修改成功', icon: 'success' }) } catch (err) { @@ -653,6 +671,21 @@ export default { return } + // 检查冷却时间 + const cooldownKey = 'nickname_update_cooldown' + const lastUpdate = uni.getStorageSync(cooldownKey) + const now = Date.now() + const cooldownDays = 7 + + if (lastUpdate && now - lastUpdate < cooldownDays * 24 * 60 * 60 * 1000) { + const daysRemaining = Math.ceil((cooldownDays * 24 * 60 * 60 * 1000 - (now - lastUpdate)) / (24 * 60 * 60 * 1000)) + uni.showToast({ + title: `昵称修改冷却中,还需${daysRemaining}天`, + icon: 'none' + }) + return + } + uni.showModal({ title: '修改昵称', editable: true, @@ -685,6 +718,9 @@ export default { userInfo.nickname = data.nickname || newNickname uni.setStorageSync('user_info', userInfo) + // 记录修改时间(7天冷却) + uni.setStorageSync('nickname_update_cooldown', Date.now()) + uni.hideLoading() uni.showToast({ title: '昵称修改成功', icon: 'success' }) } catch (err) {