【优化】个人中心板块底部增加清理缓存和清理用户登录数据的按钮。

This commit is contained in:
jianweie
2023-05-12 17:30:54 +08:00
parent bef55afb2d
commit 279e19ebb4
2 changed files with 65 additions and 23 deletions

View File

@@ -207,6 +207,12 @@
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<!-- todo:: 微信客服 --> <!-- todo:: 微信客服 -->
<!-- #endif --> <!-- #endif -->
<u-grid-item @click="clearCache">
<u-icon name="trash" :size="25" color="#666" label="清除缓存" labelPos="bottom" labelSize="13" space="25" top="15"></u-icon>
</u-grid-item>
<u-grid-item @click="logOff">
<u-icon name="arrow-downward" :size="25" color="#666" label="注销登录" labelPos="bottom" labelSize="13" space="25" top="15"></u-icon>
</u-grid-item>
</u-grid> </u-grid>
</view> </view>
</view> </view>
@@ -430,6 +436,38 @@
pointShowName() { return this.$store.state.config.pointShowName }, pointShowName() { return this.$store.state.config.pointShowName },
}, },
methods: { methods: {
// 退出登录
logOff() {
var that = this;
this.$common.modelShow('退出', '确认退出登录吗?', () => {
that.$store.commit('hasLogin', false);
that.$store.commit('userInfo', "");
that.$db.del('userToken')
uni.reLaunch({
url: '/pages/index/default/default'
})
})
},
// 清除缓存
clearCache() {
// 重新获取统一配置信息
this.$u.api.shopConfigV2().then(res => {
this.$store.commit('config', res.data)
})
//获取地区信息
this.$u.api.getAreaList().then(res => {
if (res.status) {
// 删除地区缓存信息
this.$db.del('areaList');
this.$db.set('areaList', res.data)
}
});
this.$refs.uToast.show({ message: '清除成功', type: 'success' })
uni.reLaunch({
url: '/pages/index/default/default'
})
},
goAgentPanel() { goAgentPanel() {
var _this = this; var _this = this;
uni.showLoading({ uni.showLoading({

View File

@@ -43,12 +43,12 @@
<u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon> <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
</u-cell> </u-cell>
</u-list-item> </u-list-item>
<u-list-item> <!--<u-list-item>
<u-cell title="清除缓存" @click="clearCache"> <u-cell title="清除缓存" @click="clearCache">
<u-icon slot="icon" shape="square" size="18" randomBgColor name="trash"></u-icon> <u-icon slot="icon" shape="square" size="18" randomBgColor name="trash"></u-icon>
<u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon> <u-icon slot="right-icon" shape="square" size="18" randomBgColor name="arrow-right"></u-icon>
</u-cell> </u-cell>
</u-list-item> </u-list-item>-->
<!-- #ifdef APP-PLUS || APP-PLUS-NVUE --> <!-- #ifdef APP-PLUS || APP-PLUS-NVUE -->
<u-list-item> <u-list-item>
<u-cell title="切换账号" @click="changeAccount"> <u-cell title="切换账号" @click="changeAccount">
@@ -74,29 +74,32 @@
navigateToHandle(pageUrl) { navigateToHandle(pageUrl) {
this.$u.route(pageUrl) this.$u.route(pageUrl)
}, },
// 清除缓存 //// 清除缓存
clearCache() { //clearCache() {
// 重新获取统一配置信息 // // 重新获取统一配置信息
this.$u.api.shopConfigV2().then(res => { // this.$u.api.shopConfigV2().then(res => {
this.$store.commit('config', res.data) // this.$store.commit('config', res.data)
}) // })
//获取地区信息 // //获取地区信息
this.$u.api.getAreaList().then(res => { // this.$u.api.getAreaList().then(res => {
if (res.status) { // if (res.status) {
// 删除地区缓存信息 // // 删除地区缓存信息
this.$db.del('areaList'); // this.$db.del('areaList');
this.$db.set('areaList', res.data) // this.$db.set('areaList', res.data)
} // }
}); // });
setTimeout(() => { // setTimeout(() => {
this.$refs.uToast.show({ message: '清除成功', type: 'success' }) // this.$refs.uToast.show({ message: '清除成功', type: 'success' })
}, 500) // }, 500)
}, //},
// 退出登录 // 退出登录
logOff() { logOff() {
var that = this;
this.$common.modelShow('退出', '确认退出登录吗?', () => { this.$common.modelShow('退出', '确认退出登录吗?', () => {
this.$db.del('userToken') that.$store.commit('hasLogin', false);
that.$store.commit('userInfo', "");
that.$db.del('userToken')
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/default/default' url: '/pages/index/default/default'
}) })
@@ -104,9 +107,10 @@
}, },
// 切换账号 // 切换账号
changeAccount() { changeAccount() {
var that = this;
this.$common.modelShow('切换', '确认切换登录账号吗?', () => { this.$common.modelShow('切换', '确认切换登录账号吗?', () => {
this.$db.del('userToken') that.$db.del('userToken')
this.$u.route({ url: '/pages/login/loginBySMS/loginBySMS', }); that.$u.route({ url: '/pages/login/loginBySMS/loginBySMS', });
}) })
} }
} }