feat: 退出登录

This commit is contained in:
2025-09-20 15:24:40 +08:00
parent dc8b939ff3
commit 67474d73a4
4 changed files with 43 additions and 17 deletions

View File

@@ -36,8 +36,13 @@
</template>
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, defineEmits } from "vue";
import { getLoginUserPhone } from "@/request/api/LoginApi";
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
import { useAppStore } from "@/store";
const appStore = useAppStore();
const emits = defineEmits(["closeDrawer"]);
// 假数据
const userInfo = ref({
@@ -51,12 +56,12 @@ const menuList = ref([
// { label: '修改手机号', type: 'navigate', url: '/pages/change-phone/change-phone' },
{
label: "账号注销",
type: "navigate",
url: "/pages/cancel-account/cancel-account",
type: "action",
url: "cancelAccount",
},
// { label: '营业资质&协议', type: 'navigate', url: '/pages/agreement/agreement' },
{ label: "联系客服", type: "action", action: "contactService" },
{ label: "订阅消息", type: "action", action: "subscribeMessage" },
// { label: "联系客服", type: "action", action: "contactService" },
// { label: "订阅消息", type: "action", action: "subscribeMessage" },
]);
// 组件挂载时调用
@@ -79,6 +84,8 @@ const handleMenuClick = (item) => {
} else if (item.type === "action") {
if (item.action === "contactService") {
uni.showToast({ title: "联系客服功能待实现", icon: "none" });
} else if (item.action === "cancelAccount") {
handleLogout();
} else if (item.action === "subscribeMessage") {
uni.requestSubscribeMessage({
tmplIds: ["fMIt1q9GgM3Ep0DJSNgVPm4C3lCpQdz2TediETcv3iM"],
@@ -98,7 +105,9 @@ const handleLogout = () => {
success: (res) => {
if (res.confirm) {
uni.clearStorageSync();
uni.reLaunch({ url: "/pages/login/index" });
appStore.setHasToken(false);
emits("closeDrawer");
uni.$emit(NOTICE_EVENT_LOGOUT);
}
},
});