Commit f076ef5b authored by spc's avatar spc

注销清除数据

parent ba786b2f
......@@ -101,6 +101,20 @@ export const useGlobalStore = defineStore('global', {
*/
closeTaskPerson() {
this.isShowTaskPerson = false;
}
},
/**
* 清除认证信息(注销时使用)
*/
clearAuthData() {
this.cuk = null;
this.openId = null;
this.unionId = null;
// 清除本地存储
uni.removeStorageSync('cuk');
uni.removeStorageSync('openId');
uni.removeStorageSync('unionId');
},
},
});
\ No newline at end of file
......@@ -69,5 +69,15 @@ this.hasShownPopup = false
md.login(mdData);
}
},
/**
* 清除首页信息(注销时使用)
*/
clearHomeData() {
this.homeInfo = null;
this.isLogin = false;
this.babyExistence = false;
this.hasShownPopup = false;
},
},
});
......@@ -381,5 +381,20 @@ export const useUserStore = defineStore("userInfo", {
return false;
}
},
/**
* 清除用户信息(注销时使用)
*/
clearUserData() {
this.userInfo = null;
this.babyInfo = null;
this.memberInfo = null;
this.babyNickCache = [];
this.cepingjieguoInfo = null;
// 清除本地存储
uni.removeStorageSync('memberId');
uni.removeStorageSync('loginStatus');
},
},
});
\ No newline at end of file
......@@ -38,6 +38,9 @@
<script>
import { doTerminate } from '@/api/user.js';
import { jump, JumpType } from '../../utils';
import { useUserStore } from '../../stores/user.js';
import { useGlobalStore } from '../../stores/global.js';
import { useHomeStore } from '../../stores/home.js';
export default {
data() {
......@@ -77,20 +80,28 @@ export default {
// 跳转到注销页面
navigateToLogoff() {
uni.showLoading({
title: '正在处理注销申请...'
title: '正在处理申请...'
});
doTerminate().then(res => {
console.log('注销接口返回结果:', res);
uni.hideLoading();
if (res.ok) {
// 清除本地缓存的用户信息
const userStore = useUserStore();
const globalStore = useGlobalStore();
const homeStore = useHomeStore();
// 可以跳转到登录页面或首页
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
});
}, 1500);
userStore.clearUserData();
globalStore.clearAuthData();
homeStore.clearHomeData();
console.log('用户信息已清除');
// 跳转到首页
uni.reLaunch({
url: '/pages/index/index?pageType=home'
});
} else {
uni.showToast({
title: res.message || '注销申请失败',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment