merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
const QREvent = (function() {
|
||||
let isEligible = false;
|
||||
|
||||
function init() {
|
||||
setupEventListeners();
|
||||
setupModal();
|
||||
checkEligibility();
|
||||
}
|
||||
|
||||
function setupEventListeners() {
|
||||
$('#participateEvent').on('click', handleEventParticipation);
|
||||
}
|
||||
|
||||
function setupModal() {
|
||||
MicroModal.init({
|
||||
disableScroll: true,
|
||||
awaitCloseAnimation: true,
|
||||
});
|
||||
|
||||
$('.microModal .microModal__close').on('click', function() {
|
||||
const modalId = $(this).closest('.microModal').attr('id');
|
||||
closeModal(modalId);
|
||||
});
|
||||
}
|
||||
|
||||
function openModal(modalId) {
|
||||
MicroModal.show(modalId);
|
||||
}
|
||||
|
||||
function closeModal(modalId) {
|
||||
MicroModal.close(modalId);
|
||||
}
|
||||
|
||||
function checkEligibility() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/checkQREvntEligibility',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({}),
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
isEligible = response.resBody.result.eligible;
|
||||
updateUIBasedOnEligibility();
|
||||
} else {
|
||||
console.error('응모 가능 여부 확인 실패:', response.error);
|
||||
showErrorMessage('응모 가능 여부를 확인하는 중 오류가 발생했습니다.');
|
||||
}
|
||||
},
|
||||
error: handleAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
function updateUIBasedOnEligibility() {
|
||||
const $participateButton = $('#participateEvent');
|
||||
if (isEligible) {
|
||||
$participateButton.prop('disabled', false).text('이벤트 참여하기');
|
||||
} else {
|
||||
$participateButton.prop('disabled', true).text('이미 참여하셨습니다');
|
||||
$('#modalMessage').text('이미 참여하셨거나 응모가 불가능합니다.');
|
||||
openModal('modal-1');
|
||||
}
|
||||
}
|
||||
|
||||
function handleEventParticipation() {
|
||||
if (!isEligible) {
|
||||
openModal('modal-1');
|
||||
return;
|
||||
}
|
||||
|
||||
processWinning();
|
||||
}
|
||||
|
||||
function processWinning() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/processQREvntWinning',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({}),
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
const result = JSON.parse(response.resBody.result);
|
||||
if (result.won) {
|
||||
openModal('modal-2'); // 당첨
|
||||
} else {
|
||||
openModal('modal-3'); // 미당첨
|
||||
}
|
||||
isEligible = false; // 참여 후에는 더 이상 참여 불가능
|
||||
updateUIBasedOnEligibility();
|
||||
} else {
|
||||
showErrorMessage('이벤트 참여 중 오류가 발생했습니다.');
|
||||
}
|
||||
},
|
||||
error: handleAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
function viewCoupon() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/selectIssuedQREvntCoupon',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({}),
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
const result = JSON.parse(response.resBody.result);
|
||||
if (result.couponInfo) {
|
||||
updateCouponModal(result.couponInfo);
|
||||
openModal('modal-4'); // 쿠폰 정보 모달
|
||||
} else {
|
||||
showErrorMessage('발급된 쿠폰이 없습니다.');
|
||||
}
|
||||
} else {
|
||||
showErrorMessage('쿠폰 정보 조회 중 오류가 발생했습니다.');
|
||||
}
|
||||
},
|
||||
error: handleAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
function updateCouponModal(couponInfo) {
|
||||
$('#modal-4 .qcNo').text(couponInfo.couponNumber);
|
||||
$('#modal-4 .qcCnt').text(couponInfo.discountAmount);
|
||||
$('#modal-4 .qcTxt02').text(couponInfo.useCondition);
|
||||
$('#modal-4 .qcTxt03').text(couponInfo.validUntil);
|
||||
}
|
||||
|
||||
function handleAjaxError(jqXHR, textStatus, errorThrown) {
|
||||
console.error('Ajax error:', textStatus, errorThrown);
|
||||
showErrorMessage('서버 오류가 발생했습니다. 다시 시도해주세요.');
|
||||
}
|
||||
|
||||
function showErrorMessage(message) {
|
||||
alert(message);
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
openModal: openModal,
|
||||
viewCoupon: viewCoupon
|
||||
};
|
||||
})();
|
||||
|
||||
function onQRCodeScanned(scanResult) {
|
||||
QREvent.init();
|
||||
$('#participateEvent').click();
|
||||
}
|
||||
Reference in New Issue
Block a user