Mypage/Menu2.vue

gegus1220·2022년 1월 7일
0

vue2

목록 보기
24/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-form :inline="true" class="demo-form-inline" style="margin-bottom:-20px">
                <el-form-item label="바꿀 비밀번호" label-width="150px">
                    <el-input v-model="member.userpw1" ref="userpw1" size="mini" show-password ></el-input>
                </el-form-item>
            </el-form>

            <el-form :inline="true" class="demo-form-inline" style="margin-bottom:-20px">
                <el-form-item label="바꿀 비밀번호 확인" label-width="150px">
                    <el-input v-model="member.userpw2" ref="userpw2" size="mini" show-password></el-input>
                </el-form-item>
            </el-form>

            <el-button type="primary" size="mini" @click="handleUpdate">비밀번호변경</el-button>

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

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

                member: {
                    userpw : '',
                    userpw1: '',
                    userpw2: '',
                }
            }
        },
        methods: {
            async handleUpdate() {
                const url      = `/member/mypage?menu=2`
                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.member.userpw  = '';
                    this.member.userpw1 = '';
                    this.member.userpw2 = '';
                }               
            }
        }
    }
</script>

<style scoped>

</style>

0개의 댓글