30 lines
929 B
Vue
30 lines
929 B
Vue
<template>
|
|
<div class="box-border w-auto border border-[#EEEEEE] rounded-6px border-solid bg-[#FFFFFF] px-30px py-21px mt-10px">
|
|
<el-button type="danger" @click="handleClick">注销账号</el-button>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import useUserStore from '~/stores/user'
|
|
const userStore = useUserStore()
|
|
import { userLogout } from '~/api/personal-center/index'
|
|
const handleClick = () => {
|
|
console.log('注销账号')
|
|
ElMessageBox.confirm('确定注销账号吗?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
}).then(async () => {
|
|
console.log('注销账号')
|
|
const res = await userLogout()
|
|
if (res.code === 0) {
|
|
ElMessage.success('注销成功')
|
|
navigateTo('/')
|
|
clearNuxtState(['token', 'userInfo'])
|
|
userStore.logout()
|
|
userStore.$reset()
|
|
}
|
|
})
|
|
}
|
|
</script>
|