增加退出登录

This commit is contained in:
TOP糯米 2023-03-17 00:35:23 +08:00
parent 2fcd9ceda3
commit e04c62df44
3 changed files with 16 additions and 2 deletions

View File

@ -236,5 +236,16 @@ export default {
return reject(response.msg);
}).catch(e => { });
});
},
/**
* 注销登录
*/
logout() {
prototype.$storage.set('user_access_token', null);
prototype.$storage.set('userinfo', null);
$store.commit('user/token', "");
prototype.$utils.toast('注销成功').then(() => {
prototype.$utils.toPage('/pages/index/index', {}, 'switch');
});
}
}

View File

@ -34,7 +34,7 @@
</view>
</view>
<view class="common-save-form-btn">
<view class="btn">退出账户</view>
<view class="btn" @click="logout">退出账户</view>
</view>
</view>
</app-layout>
@ -59,6 +59,9 @@ export default {
toPage(url) {
this.$utils.toPage(url);
},
logout() {
this.$models.user.logout();
},
},
};
</script>

View File

@ -16,7 +16,7 @@ export default {
},
getters: {
isLogin(state) {
return state.token.length > 0;
return state.token && state.token.length > 0;
},
},
mutations: {