itn 2023-08-14
이벤트 결제하기 화면 다음 결제시 결제수단 UPDATE 기능추가
@b1cc058ad69cb39d3202921cdcf7a719e24122cd
src/main/webapp/WEB-INF/jsp/web/event/pay/EventPayViewV2.jsp
--- src/main/webapp/WEB-INF/jsp/web/event/pay/EventPayViewV2.jsp
+++ src/main/webapp/WEB-INF/jsp/web/event/pay/EventPayViewV2.jsp
@@ -15,6 +15,9 @@
 var tabType = "${tabType}";
 
 $(document).ready(function(){
+	//다음 결제시 결제수단 SELECT
+	getNextPayMethod();	
+	
 	// 충전금액 세팅
 	setPriceMake();
 	
@@ -24,9 +27,116 @@
 	if (tabType == "2") {
 		$("#btnDdedicatedAccount").trigger("click");
 	}
-	
 });
 
+//다음 결제시 결제수단 SELECT
+function getNextPayMethod() {
+	var nextPayMethod = "";
+	$.ajax({
+	    type: "POST",
+	    url: "/web/member/pay/selectNextPayMethodAjax.do",
+	    data: {},
+	    dataType:'json',
+	    async: false,
+	    success: function (data) {
+			if (data.isSuccess) { 
+				if (data.nextPayMethod != '') {
+					nextPayMethod = data.nextPayMethod;
+					
+					// 버튼 영역
+					$(".btn_tab").removeClass("active");
+					// 금액 영역
+					$(".area_tabcont").removeClass("on");
+					
+					if (nextPayMethod == "CARD") {
+						$(".btn_charge1").addClass("active");
+						$("#tab2_1").addClass("area_tabcont on");
+					}
+					else if (nextPayMethod == "VBANK") {
+						$(".btn_charge2").addClass("active");
+						$("#tab2_2").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "BANK") {
+						$(".btn_charge3").addClass("active");
+						$("#tab2_3").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "CELLPHONE") {
+						// 휴대폰일경우 카드결제 초기화
+						$(".btn_charge1").addClass("active");
+						$("#tab2_1").addClass("area_tabcont on");
+					}						
+					else if (nextPayMethod == "NAV") {
+						$(".btn_charge5").addClass("active");
+						$("#tab2_5").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "KKO") {
+						$(".btn_charge6").addClass("active");
+						$("#tab2_6").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "TOS") {
+						$(".btn_charge7").addClass("active");
+						$("#tab2_7").addClass("area_tabcont on");
+					}	
+					else if (nextPayMethod == "PYC") {
+						$(".btn_charge8").addClass("active");
+						$("#tab2_8").addClass("area_tabcont on");
+					}		
+					
+					// 체크박스
+					$("input:checkbox[id='agree']").prop("checked", true); 
+				}
+			} 
+		},
+	    error: function (e) {
+	    	
+	    }
+	});		
+}
+
+// 다음 결제시 결제수단 UPDATE
+function setNextPayMethod() {
+	var nextPayMethod = "";
+	if ($("input:checkbox[id='agree']").is(":checked") == true) {
+		var $currentTab = $('.area_tab').children('.active').index();
+		if ($currentTab == 0) {	
+			nextPayMethod = "CARD";
+		} else if ($currentTab == 1) {	
+			nextPayMethod = "VBANK";		
+		} else if ($currentTab==2) {	
+			nextPayMethod = "BANK";		
+		} else {	
+			if ($currentTab == 3) {
+				nextPayMethod = "NAV";	// 네이버페이
+			} else if ($currentTab==4) {
+				nextPayMethod = "KKO";	// 카카오페이
+			} else if ($currentTab==5) {
+				nextPayMethod = "TOS";	// 토스페이
+			} else if ($currentTab==6) {
+				nextPayMethod = "PYC";	// 페이코
+			}	
+		}	
+	}
+	else {
+		nextPayMethod = "";		
+	}
+	
+	// 업데이트		
+	$.ajax({
+	    type: "POST",
+	    url: "/web/member/pay/updateNextPayMethodAjax.do",
+	    data: {"nextPayMethod" : nextPayMethod},
+	    dataType:'json',
+	    async: false,
+	    success: function (data) {
+			if (data.isSuccess) { 
+
+			} 
+		},
+	    error: function (e) {
+	    	
+	    }
+	});					
+}
 
 //결제수단 상태 체크
 function checkPayTypeStatusAjax(payMethod) {
@@ -189,6 +299,9 @@
 		return false;
 	}
 
+	// 다음 결제시 결제수단 UPDATE
+	setNextPayMethod();	
+	
 	var payMethod = "";
 	document.pgForm.action = "/web/member/pay/PayActionAjax.do";
 	
@@ -536,6 +649,9 @@
 		
 	}
 	
+	// 다음 결제시 결제수단 UPDATE
+	setNextPayMethod();	
+	
 	var data = new FormData(document.pgForm);
 	url = "/web/member/pay/updateVacsAccountUsrIdAjax.do";
 	
@@ -820,12 +936,12 @@
 						<ul class="area_tab type03">
 							<li class="btn_charge1 btn_tab active"><button type="button" onclick="TabTypePay(this,'1');"><i></i>신용카드</button></li>
 							<li class="btn_charge2 btn_tab"><button type="button" onclick="TabTypePay(this,'2');" id="btnDdedicatedAccount"><i></i>전용계좌</button></li>
-							<li class="btn_charge3 btn_tab"><button type="button" onclick="TabTypePay(this,'4');"><i></i>즉시이체</button></li>
+							<li class="btn_charge3 btn_tab"><button type="button" onclick="TabTypePay(this,'3');"><i></i>즉시이체</button></li>
 							
-							<li class="btn_charge5 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'6');"><i></i></button></li>
-							<li class="btn_charge6 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'7');"><i></i></button></li>
-							<li class="btn_charge7 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'8');"><i></i></button></li>
-							<li class="btn_charge8 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'9');"><i></i></button></li>														
+							<li class="btn_charge5 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'5');"><i></i></button></li>
+							<li class="btn_charge6 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'6');"><i></i></button></li>
+							<li class="btn_charge7 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'7');"><i></i></button></li>
+							<li class="btn_charge8 btn_tab simple_pay event_simple"><button type="button" onclick="TabTypePay(this,'8');"><i></i></button></li>														
 						</ul>
 						<div class="checkbox_wrap"><input type="checkbox" id="agree"><label for="agree">선택한 수단을 다음 충전 시에도 이용합니다.</label></div>
 
@@ -994,7 +1110,7 @@
 						<!-- //전용계좌 -->
 
 						<!-- 즉시이체 -->
-						<div class="area_tabcont" id="tab2_4">
+						<div class="area_tabcont" id="tab2_3">
 							<p class="tType1_title"><img src="/publish/images/content/icon_charging5_small.png" alt=""> 즉시이체</p>
 							<table class="tType1">
 								<caption></caption>
@@ -1052,7 +1168,7 @@
 						<!-- //즉시이체 -->
 						
 						<!-- 네이버페이 -->
-						<div class="area_tabcont" id="tab2_6">
+						<div class="area_tabcont" id="tab2_5">
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> 네이버페이</p>
 							<table class="tType1">
 								<colgroup>
@@ -1121,7 +1237,7 @@
 						<!-- //네이버페이 -->
 
 						<!-- 카카오페이 -->
-						<div class="area_tabcont current" id="tab2_7">
+						<div class="area_tabcont current" id="tab2_6">
 							<!-- 신규계좌발급 시 -->
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> 카카오페이</p>
 							<table class="tType1">
@@ -1190,7 +1306,7 @@
 						<!-- //카카오페이 -->
 
 						<!-- 토스페이 -->
-						<div class="area_tabcont current" id="tab2_8">
+						<div class="area_tabcont current" id="tab2_7">
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> 토스페이</p>
 							<table class="tType1">
 								<caption></caption>
@@ -1249,7 +1365,7 @@
 						<!-- //토스페이 -->
 
 						<!-- 페이코 -->
-						<div class="area_tabcont current" id="tab2_9">
+						<div class="area_tabcont current" id="tab2_8">
 							<p class="tType1_title"><img src="/publish/images/simple_small.png" alt="간편결제"> PAYCO</p>
 							<table class="tType1">
 								<caption></caption>
src/main/webapp/WEB-INF/jsp/web/pay/PayViewV2.jsp
--- src/main/webapp/WEB-INF/jsp/web/pay/PayViewV2.jsp
+++ src/main/webapp/WEB-INF/jsp/web/pay/PayViewV2.jsp
@@ -19,6 +19,9 @@
 var tabType = "${tabType}";
 
 $(document).ready(function(){
+	//다음 결제시 결제수단 SELECT
+	getNextPayMethod();
+
 	// 충전금액 세팅
 	setPriceMake();
 	
@@ -29,9 +32,6 @@
 		$("#btnDdedicatedAccount").trigger("click");
 	}
 
-	//다음 결제시 결제수단 SELECT
-	getNextPayMethod();
-	
 	// 등급제 대상 여부
 	getMberGrdChk();	
 });
Add a comment
List