Mypage/Menu3.vue

gegus1220·2022년 1월 7일
0

vue2

목록 보기
25/26
<template>
    <div>
        <el-card shadow="always" style="width:700px;">
            <el-form :inline="true" class="demo-form-inline" style="margin-bottom:-20px">
                <el-form-item label="현재비밀번호" label-width="150px">
                    <el-input v-model="member.userpw" ref="userpw" size="mini" show-password></el-input>
                </el-form-item>            
            </el-form>
            <el-button type="primary" size="mini" @click="handleDelete">회원탈퇴</el-button>

        </el-card>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                token      : sessionStorage.getItem("TOKEN"),

                member: {
                    userpw : '',
                }
            }
        },
        methods: {
            async handleDelete() {
                const ret          = confirm('정말 탈퇴하시겠습니까?');
                if(ret){
                    const url      = `/member/mypage?menu=3`
                    const headers  = { 
                        "Content-Type":"application/json",
                        "token": this.token 
                    }

                    const body     = this.member;
                    const response = await this.axios.put(url, body, { headers: headers } );

                    console.log(response.data);
                    if(response.data.status === 200) {
                        alert('정상적으로 탈퇴되었습니다');
                        // 토큰삭제 페이지이동 메뉴바꿈
                        this.$router.push({ name: "Logout" });
                    }               
                }

            }
        }
    }
</script>

<style scoped>

</style>

0개의 댓글