diff --git a/common/account.js b/common/account.js new file mode 100644 index 0000000..b394963 --- /dev/null +++ b/common/account.js @@ -0,0 +1,15 @@ +// xuchao: 账号级本地缓存集中管理。权益页首屏会读这些缓存做兜底展示, +// 换账号/退出时漏清就会把上一个账号的中奖状态、卡号、到期时间当成当前账号的数据展示。 +const ACCOUNT_KEYS = ['token', 'phone', 'isAuth', 'hasWin', 'cardNumber', 'expiresTime', + 'rightsCount', 'totalValueFen', 'authFlowStarted', 'authName', 'authIdNo'] + +export default { + // 清空当前账号的本地会话与权益缓存(定位 lng/lat 属于设备信息,不在此列) + clearAccountCache() { + ACCOUNT_KEYS.forEach(key => uni.removeStorageSync(key)) + }, + // 账号标识(手机号) + setAccountPhone(phone) { + uni.setStorageSync('phone', phone) + } +} diff --git a/pages/index/index.vue b/pages/index/index.vue index b646d2e..7ad14a7 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -34,6 +34,8 @@