diff --git a/src/api/authApi.js b/src/api/authApi.js index 84e2e85..1b14da0 100644 --- a/src/api/authApi.js +++ b/src/api/authApi.js @@ -51,4 +51,8 @@ export const authApi = { profile() { return http.get('/auth/profile') }, + // 회원 탈퇴 — 계정·데이터 전체 삭제 + withdraw() { + return http.delete('/auth/me') + }, } diff --git a/src/views/settings/AccountInfoView.vue b/src/views/settings/AccountInfoView.vue index 41a8b72..b2638b8 100644 --- a/src/views/settings/AccountInfoView.vue +++ b/src/views/settings/AccountInfoView.vue @@ -186,6 +186,29 @@ async function removePhoto() { function goEdit() { router.push('/settings/account/edit') } + +// ===== 회원 탈퇴 ===== +const withdrawing = ref(false) +async function withdraw() { + if (withdrawing.value) return + const ok = await dialog.confirm( + '정말 탈퇴하시겠어요?\n\n· 계정과 모든 데이터(가계부·계좌·게시글·댓글·포인트·결제내역)가 영구 삭제됩니다.\n· 삭제된 데이터는 복구할 수 없습니다.', + { title: '회원 탈퇴', danger: true }, + ) + if (!ok) return + const ok2 = await dialog.confirm('마지막 확인입니다. 정말 탈퇴를 진행할까요?', { title: '회원 탈퇴', danger: true }) + if (!ok2) return + withdrawing.value = true + try { + await authApi.withdraw() + await auth.clear() + router.replace('/') + dialog.alert('탈퇴가 완료되었습니다. 그동안 이용해 주셔서 감사합니다.') + } catch (e) { + withdrawing.value = false + alert(e.response?.data?.message || '탈퇴에 실패했습니다. 잠시 후 다시 시도해 주세요.') + } +} @@ -729,6 +758,27 @@ function goEdit() { font-weight: 600; cursor: pointer; } +.withdraw-area { + margin-top: 1.5rem; + text-align: center; +} +.withdraw-link { + border: 0; + background: transparent; + color: var(--color-text); + opacity: 0.5; + font-size: 0.85rem; + text-decoration: underline; + cursor: pointer; +} +.withdraw-link:hover { + color: #c0392b; + opacity: 1; +} +.withdraw-link:disabled { + opacity: 0.4; + cursor: default; +} .primary-btn:hover { background: hsla(160, 100%, 32%, 1); }