Files
2025-05-02 14:41:47 +08:00

54 lines
1.1 KiB
Vue

<template>
<view>
<u-cell-group :border="false">
<u-cell-item title="退出登录" :border-bottom="false" @click="logout" hover-class="none"></u-cell-item>
</u-cell-group>
<u-modal v-model="showLogout" :content="content" :show-cancel-button="true" @confirm="confirmLogout"></u-modal>
</view>
</template>
<script>
import {userLogout} from '@/api/user'
import { mapState, mapGetters } from 'vuex'
export default {
data() {
return {
showLogout: false,
content: '确定退出登录'
}
},
methods: {
logout() {
this.showLogout = true
},
confirmLogout() {
console.log(this.token)
// 退出登录
userLogout({
token: this.token
}).then((res) => {
if (res.code == 1) {
this.$store.commit('LOGOUT')
this.$toast({
title: '退出成功'
})
setTimeout(() => {
uni.redirectTo({
url: '/pages/login/login'
})
}, 500)
}
})
}
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
</style>