standardize all hardcoded text across分销 and member pages to use language packs, fix template syntax errors in level.vue, and unify text display logic
91 lines
2.5 KiB
JavaScript
91 lines
2.5 KiB
JavaScript
export default {
|
||
methods: {
|
||
// 清除登录态(token / 用户信息 / 购物车 / 本地存储)
|
||
clearLoginState() {
|
||
this.$store.commit('setToken', '');
|
||
this.$store.commit('setMemberInfo', '');
|
||
this.$store.dispatch('emptyCart');
|
||
uni.removeStorageSync('authInfo');
|
||
uni.removeStorageSync('privacyAgreed');
|
||
},
|
||
|
||
// 退出登录
|
||
logout() {
|
||
uni.showModal({
|
||
title: this.$lang('logoutTitle'),
|
||
content: this.$lang('logoutContent'),
|
||
success: (res) => {
|
||
if (res.confirm) {
|
||
this.clearLoginState();
|
||
this.$util.redirectTo(this.$util.LOGIN_PAGE_URL);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
|
||
// 账号注销入口:先查状态,根据状态分流
|
||
cancellation() {
|
||
this.getCancelStatus();
|
||
},
|
||
|
||
// 查询注销状态并跳转对应页面
|
||
// status: undefined/null → 未申请 → 协议页 cancellation.vue
|
||
// status: 0 → 审核中 → 状态页 cancelstatus.vue
|
||
// status: 1 → 通过 → 成功页 cancelsuccess.vue
|
||
// status: -1 → 拒绝 → 拒绝页 cancelrefuse.vue
|
||
getCancelStatus() {
|
||
this.$api.sendRequest({
|
||
url: '/membercancel/api/membercancel/info',
|
||
success: res => {
|
||
if (res.code >= 0) {
|
||
if (res.data) {
|
||
if (res.data.status == 0) {
|
||
this.$util.redirectTo('/pages_tool/member/cancelstatus');
|
||
} else if (res.data.status == 1) {
|
||
this.$util.redirectTo('/pages_tool/member/cancelsuccess');
|
||
} else {
|
||
this.$util.redirectTo('/pages_tool/member/cancelrefuse');
|
||
}
|
||
} else {
|
||
this.$util.redirectTo('/pages_tool/member/cancellation');
|
||
}
|
||
} else if (res.code == -1) {
|
||
this.clearLoginState();
|
||
this.$util.redirectTo(this.$util.LOGIN_PAGE_URL);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
|
||
// 提交注销申请并清理登录态(供 assets.vue 等页面调用)
|
||
submitCancelApply(options = {}) {
|
||
uni.showModal({
|
||
title: options.title || this.$lang('member.riskTip'),
|
||
content: options.content || this.$lang('member.confirmLogoutAccount'),
|
||
confirmColor: '#000000',
|
||
success: res => {
|
||
if (res.confirm) {
|
||
this.$api.sendRequest({
|
||
url: '/membercancel/api/membercancel/apply',
|
||
success: rres => {
|
||
if (rres.code >= 0) {
|
||
if (options.clearStateAndRedirect) {
|
||
this.clearLoginState();
|
||
this.$util.redirectTo(this.$util.LOGIN_PAGE_URL);
|
||
} else {
|
||
this.$util.redirectTo('/pages_tool/member/cancelstatus');
|
||
}
|
||
} else {
|
||
this.$util.showToast({
|
||
title: rres.message
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
};
|