<template>
    <div class="content">
        <div class="top-banner banner mypage-banner">
            <div class="flex-column align-center justify-center content">
                <h1 class="banner-title text-ct white" aria-live="assertive">{{ $getMenuInfo().menuNm }}</h1>
                <p class="box-title text-ct white">{{ $getMenuInfo().menuCn }}</p>
            </div>
        </div>
        <PageNavigationBar :navi="naviData" />
        <div class="pt100 pb100">
            <div v-if="innerStep === 1 || innerStep ===3" class="content">
                <div class="flex-column justify-center align-center content">
                    <div class="login-wrap pd30 border">
                        <div class="page-title mb30">
                            <p class="text-ct">비밀번호 확인</p>
                        </div>
                        <div class="pw-zone mb10">
                            <input type="password" name="" id="pw" placeholder="PASSWORD를 입력하세요." v-model="mbrEncptPswd"
                            @keyup.enter="checkPwd()" class="full-input"  />
                        </div>
                        <button class="large-btn blue-btn ml0" title="확인" @click="checkPwd()">
                            확인
                        </button>
                    </div>
                </div>
            </div>
            <div class="w1280" v-else-if="innerStep === 2" id="companyTitle1">
               <CompanyManageComponent @setPage="changePage" ></CompanyManageComponent>
            </div>
            <div class="w1280"  v-else-if="innerStep === 4" id="companyTitle4">
               <CompanyInfoUpdateComponent @setPage="changePage" ></CompanyInfoUpdateComponent>
            </div>
        </div>
    </div>
</template>

<script>
import PageNavigationBar from '../../../component/pagenavigationbar/PageNavigationBar.vue';
import CompanyManageComponent from './CompanyManageComponent.vue';
import CompanyInfoUpdateComponent from './CompanyInfoUpdateComponent.vue';
import { pwdCheck } from '../../../../resources/api/userPage';
import axios from "axios";
import _ from "lodash";


export default {
    data() {
        return {           
            innerStep: 1,         
            mbrEncptPswd :'',
            naviData: {},
        }
    },
    methods: {      
        // 페이지 변경 
        changePage : function(index){
            this.innerStep = index;
        },
        //현재비밀번호 확인
        async checkPwd() {          
            if(this.$isEmpty(this.mbrEncptPswd)){
                alert('비밀번호를 입력해 주세요')
                return false;  
            }

            const data = { 'mbrEncptPswd' : this.mbrEncptPswd }

            try {
                const res = await pwdCheck(data);
                if(res.status == 200) {
                     this.innerStep =  this.innerStep +1;
                     this.mbrEncptPswd = '';
                }
            } catch(error) {  
                alert(error.response.data.message)
            }
        },     
    },
    watch: {
    },
    computed: {
    },
    components: {
        'PageNavigationBar': PageNavigationBar,
        'CompanyManageComponent' : CompanyManageComponent,
        'CompanyInfoUpdateComponent' : CompanyInfoUpdateComponent
    },
    mounted() {      
        this.naviData = { 'main': '마이페이지', 'sub': '기업 관리' };

    }
}
</script>


<style scoped>
a {
    color: blue;
    text-decoration: underline;
  }
</style>
