195 lines
8.9 KiB
HTML
195 lines
8.9 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
layout:decorate="~{layout/kjbank_title_layout}">
|
|
<body>
|
|
<section layout:fragment="title">
|
|
<div class="page-title-banner">
|
|
<img th:src="@{/img/img_title_bg.png}" class="title-image">
|
|
<h1>내 정보 관리</h1>
|
|
</div>
|
|
</section>
|
|
<section layout:fragment="contentFragment">
|
|
<div class="org-register-container">
|
|
|
|
<!-- 초대 알림 배너 -->
|
|
<div th:if="${hasPendingInvitation}" class="invitation_alert_banner" style="background-color: #f0f8ff; border: 1px solid #2196F3; border-radius: 4px; padding: 15px 20px; margin: 20px 0;">
|
|
<div style="display: flex; align-items: center; justify-content: space-between;">
|
|
<div>
|
|
<strong style="color: #1976D2;">법인 회원 초대가 대기 중입니다</strong>
|
|
<p style="margin: 5px 0 0 0; color: #666;">기관에서 귀하를 법인 회원으로 초대했습니다. 초대를 수락하면 해당 기관의 법인 회원으로 전환됩니다.</p>
|
|
</div>
|
|
<div>
|
|
<a th:href="@{/signup/decision(invitation=${invitationToken})}" class="common_btn_type_1 blue" style="white-space: nowrap;">
|
|
<span>초대 확인</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="common-title-bar">
|
|
<h2 class="common-title">기본 정보</h2>
|
|
</div>
|
|
<div class="register-form-container">
|
|
<form id="updateForm" method="post" th:action="@{/mypage/update}" th:object="${user}">
|
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
|
|
<div class="register-form">
|
|
<th:block th:replace="~{apps/mypage/components/commonUserInfo :: commonUserInfo}"></th:block>
|
|
</div>
|
|
|
|
<!-- Corporate Transfer Button -->
|
|
<div class="corporate-transfer-section">
|
|
<button type="button" class="btn btn-secondary btn_business btn-block">
|
|
법인회원 전환
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<input type="hidden" name="finalMobileNumber"/>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="form-actions form-actions--with-withdrawal">
|
|
<a class="withdrawal-link"><img th:src="@{/img/btn_withdrawal.png}" alt="회원탈퇴">회원탈퇴</a>
|
|
<div class="form-actions-buttons">
|
|
<button type="button" class="btn btn-submit btn-secondary" th:onclick="|location.href='@{/}'|">취소</button>
|
|
<button type="button" class="btn btn-submit btn-primary submit-btn">수정</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<th:block layout:fragment="contentScript">
|
|
<script th:if="${error}" th:inline="javascript">
|
|
$(document).ready(function () {
|
|
customPopups.showAlert([[${error}]]);
|
|
});
|
|
</script>
|
|
<script th:inline="javascript">
|
|
$(document).ready(function() {
|
|
// 기존 success 메시지 처리
|
|
var successMsg = [[${success}]];
|
|
console.log("Success message:", successMsg);
|
|
if (successMsg) {
|
|
console.log("Showing alert");
|
|
customPopups.showAlert(successMsg);
|
|
}
|
|
});
|
|
</script>
|
|
<script th:replace="~{apps/mypage/components/commonUserInfo :: commonUserInfoScript}"></script>
|
|
<script th:inline="javascript">
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const form = document.getElementById('updateForm');
|
|
|
|
// 수정 버튼 이벤트
|
|
const submitButton = document.querySelector('.btn-primary.submit-btn');
|
|
if (submitButton) {
|
|
submitButton.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
|
|
try {
|
|
// 원래 값들 가져오기
|
|
const originalName = document.querySelector('input[name="userName"]').defaultValue;
|
|
const originalPrefix = document.querySelector('input[name="mobilePrefix"]').value;
|
|
const originalMiddle = document.querySelector('input[name="mobileMiddle"]').value;
|
|
const originalLast = document.querySelector('input[name="mobileLast"]').value;
|
|
const originalMobileNumber = `${originalPrefix}-${originalMiddle}-${originalLast}`;
|
|
|
|
// 현재 값들 가져오기
|
|
const currentName = document.querySelector('input[name="userName"]').value.trim();
|
|
const newPhoneContainer = document.getElementById('newPhoneNumberContainer');
|
|
const isNewPhoneVisible = newPhoneContainer && newPhoneContainer.style.display !== 'none';
|
|
const mobileNumberInput = document.getElementById('mobileNumber');
|
|
|
|
// 변경사항 체크
|
|
let hasChanges = false;
|
|
|
|
// 이름 변경 체크
|
|
if (currentName !== originalName) {
|
|
hasChanges = true;
|
|
}
|
|
|
|
// 휴대폰 번호 변경 체크
|
|
if (isNewPhoneVisible) {
|
|
if (window.isAuthVerified) {
|
|
const prefix = $('#phoneMobile').val();
|
|
const middle = document.getElementById('newMobileMiddle').value;
|
|
const last = document.getElementById('newMobileLast').value;
|
|
const newMobileNumber = `${prefix}-${middle}-${last}`;
|
|
|
|
if (newMobileNumber !== originalMobileNumber) {
|
|
hasChanges = true;
|
|
}
|
|
|
|
if (prefix && prefix !== '선택' && middle && last) {
|
|
mobileNumberInput.value = newMobileNumber;
|
|
} else {
|
|
customPopups.showAlert('휴대폰 번호를 올바르게 입력해주세요.');
|
|
return;
|
|
}
|
|
} else {
|
|
customPopups.showAlert('인증번호확인을 완료해주세요.');
|
|
return;
|
|
}
|
|
} else {
|
|
mobileNumberInput.value = originalMobileNumber;
|
|
}
|
|
|
|
// 변경사항이 없는 경우
|
|
if (!hasChanges) {
|
|
customPopups.showAlert('변경된 내용이 없습니다.');
|
|
return;
|
|
}
|
|
|
|
// 불필요한 필드 제거
|
|
const fieldsToRemove = [
|
|
'mobilePrefix', 'mobileMiddle', 'mobileLast',
|
|
'newMobilePrefix', 'newMobileMiddle', 'newMobileLast',
|
|
'authNumber', 'finalMobileNumber'
|
|
];
|
|
|
|
fieldsToRemove.forEach(fieldName => {
|
|
const elements = form.querySelectorAll(`[name="${fieldName}"]`);
|
|
elements.forEach(element => element.remove());
|
|
});
|
|
|
|
form.submit();
|
|
|
|
} catch (error) {
|
|
console.error('Error during form submission:', error);
|
|
customPopups.showAlert('처리 중 오류가 발생했습니다. 다시 시도해 주세요.');
|
|
}
|
|
});
|
|
}
|
|
|
|
// 법인전환 버튼 이벤트
|
|
const businessTransferBtn = document.querySelector('.btn_business');
|
|
if (businessTransferBtn) {
|
|
businessTransferBtn.addEventListener('click', () => {
|
|
customPopups.showConfirm(
|
|
'법인 회원으로 전환하시겠습니까?',
|
|
(confirmed) => {
|
|
if (confirmed) {
|
|
const transferForm = document.createElement('form');
|
|
transferForm.method = 'GET';
|
|
transferForm.action = '/mypage/org-transfer';
|
|
document.body.appendChild(transferForm);
|
|
transferForm.submit();
|
|
}
|
|
}
|
|
);
|
|
});
|
|
}
|
|
|
|
// 회원탈퇴 버튼 이벤트
|
|
const withdrawalBtn = document.querySelector('.withdrawal-link');
|
|
if (withdrawalBtn) {
|
|
withdrawalBtn.addEventListener('click', (e) => {
|
|
e.preventDefault();
|
|
document.getElementById('withdrawalPopup').style.display = 'block';
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
</th:block>
|
|
</body>
|
|
</html>
|