<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	layout:decorator="mob/common/layout/MypageLayoutMob">
<!--
 *******************************************************************************
 * @source  : MypageCustConfirmFormMob.html
 * @desc    : 마이페이지 > 회원정보 확인 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2021 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.04.26   jsshin      최초 작성
 *******************************************************************************
 -->
<body>
<th:block layout:fragment="content">
<main class="container my">
	<section class="content my_page">
		<div class="inner">
			<div class="pass_confirm">
				<p class="desc">정보를 안전하게 보호하기 위하여<br>비밀번호를 다시 확인합니다. </p>
				<form id="confirmForm" class="form_wrap" action="/mypage/customer/modify/form" method="post">
					<div class="form_field">
						<th:block th:if="${snsType == ''}">
							<input type="text" id="custId" name="custId" th:value="${custId}" class="form_control" readonly="readonly"/>
						</th:block>
						<th:block th:unless="${snsType == ''}">
							<th:block th:if="${snsType == 'NV'}">
								<span>네이버 간편가입회원</span>
							</th:block>
							<th:block th:if="${snsType == 'KK'}">
								<span>카카오 간편가입회원</span>
							</th:block>
							<th:block th:if="${snsType == 'YS'}">
								<span>YES24 간편가입회원</span>
							</th:block>
						</th:block>
					</div>
					<div class="form_field">
						<input type="password" id="passwd" name="passwd" class="form_control" placeholder="비밀번호를 입력해 주세요"/>
					</div>
					<div class="btn_group_flex">
						<div>
							<button type="button" class="btn btn_default btn_block" onclick="cfnGoToPage(_PAGE_MAIN);">
								<span>취소</span>
							</button>
						</div>
						<div>
							<button type="button" id="btnConfirm" class="btn btn_dark btn_block">
								<span>확인</span>
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</section>
</main>
<script th:inline="javascript">
	/*<![CDATA[*/
	//엔터키 확인
	$('#confirmForm input[name=passwd]').keypress(function (event) {
		if (event.which === 13) {
			event.preventDefault();
			fnValidConfirm();
		}
	});

	// 확인버튼
	$('#btnConfirm').on('click', function () {
		fnValidConfirm();
	});

	// 확인
	var fnValidConfirm = function () {
		var $passwd = $('#confirmForm input[name=passwd]');
		if (gagajf.isNull($passwd.val())) {
			$passwd.blur();
			mcxDialog.alertC("비밀번호를 입력해 주세요.", {
				sureBtnText: "확인",
				sureBtnClick: function () {
					$passwd.focus();
				}
			});
			return;
		}
		gagajf.ajaxFormSubmit("/mypage/customer/password/confirm", '#confirmForm', fnConfirmCallback);
	};

	var fnConfirmCallback = function (result) {
		let $passwd = $('#confirmForm input[name=passwd]');
		let $custId = $('#confirmForm input[name=custId]');
		if (result.isMatch) {
			$('#confirmForm').submit();
		} else {
			$passwd.val('');
			$custId.focus();
			mcxDialog.alertC('비밀번호가 일치하지 않습니다.', {
				sureBtnText: '확인',
				sureBtnClick: function() {
					$passwd.focus();
				}
			});
			return;
		}
	};

	$(document).ready(function() {
		$('#htopTitle').text('내 정보 관리');
	});

	/*]]>*/
</script>

</th:block>
</body>
</html>