Commit f076ef5b authored by spc's avatar spc

注销清除数据

parent ba786b2f
...@@ -101,6 +101,20 @@ export const useGlobalStore = defineStore('global', { ...@@ -101,6 +101,20 @@ export const useGlobalStore = defineStore('global', {
*/ */
closeTaskPerson() { closeTaskPerson() {
this.isShowTaskPerson = false; 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 ...@@ -69,5 +69,15 @@ this.hasShownPopup = false
md.login(mdData); 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", { ...@@ -381,5 +381,20 @@ export const useUserStore = defineStore("userInfo", {
return false; 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 @@ ...@@ -38,6 +38,9 @@
<script> <script>
import { doTerminate } from '@/api/user.js'; import { doTerminate } from '@/api/user.js';
import { jump, JumpType } from '../../utils'; 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 { export default {
data() { data() {
...@@ -77,20 +80,28 @@ export default { ...@@ -77,20 +80,28 @@ export default {
// 跳转到注销页面 // 跳转到注销页面
navigateToLogoff() { navigateToLogoff() {
uni.showLoading({ uni.showLoading({
title: '正在处理注销申请...' title: '正在处理申请...'
}); });
doTerminate().then(res => { doTerminate().then(res => {
console.log('注销接口返回结果:', res); console.log('注销接口返回结果:', res);
uni.hideLoading(); uni.hideLoading();
if (res.ok) { if (res.ok) {
// 清除本地缓存的用户信息
const userStore = useUserStore();
const globalStore = useGlobalStore();
const homeStore = useHomeStore();
// 可以跳转到登录页面或首页 userStore.clearUserData();
setTimeout(() => { globalStore.clearAuthData();
uni.reLaunch({ homeStore.clearHomeData();
url: '/pages/index/index'
}); console.log('用户信息已清除');
}, 1500);
// 跳转到首页
uni.reLaunch({
url: '/pages/index/index?pageType=home'
});
} else { } else {
uni.showToast({ uni.showToast({
title: res.message || '注销申请失败', 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