merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
// 초기화 함수
|
||||
function initializeCapsuleSelection(data) {
|
||||
capsuleData = data;
|
||||
loadImages();
|
||||
setupProductSelection();
|
||||
setupModal();
|
||||
setupStartButton();
|
||||
}
|
||||
|
||||
// 이미지 로드 함수
|
||||
function loadImages() {
|
||||
document.querySelectorAll('.thum img').forEach((img, index) => {
|
||||
const product = capsuleData.productList[index];
|
||||
img.src = encodeURI(product.imgFilCours.replace(/\\/g, '/'));
|
||||
});
|
||||
}
|
||||
|
||||
// 제품 선택 기능 설정
|
||||
function setupProductSelection() {
|
||||
document.querySelectorAll('.gameProduct').forEach(product => {
|
||||
product.addEventListener('click', function() {
|
||||
document.querySelectorAll('.gameProduct').forEach(p => p.classList.remove('selected'));
|
||||
this.classList.add('selected');
|
||||
this.querySelector('input[type="radio"]').checked = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 모달 설정
|
||||
function setupModal() {
|
||||
MicroModal.init({
|
||||
disableScroll: true,
|
||||
awaitCloseAnimation: true,
|
||||
});
|
||||
|
||||
// 풀스크린 팝업 트리거 이벤트 리스너
|
||||
document.querySelectorAll('.fullscreen-trigger').forEach(trigger => {
|
||||
trigger.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
const modalId = this.getAttribute('data-micromodal-trigger');
|
||||
openModal(modalId);
|
||||
});
|
||||
});
|
||||
|
||||
// 풀스크린 팝업 닫기 이벤트 리스너
|
||||
document.querySelectorAll('.microModal .microModal__close').forEach(closeBtn => {
|
||||
closeBtn.addEventListener('click', function() {
|
||||
const modalId = this.closest('.microModal').id;
|
||||
closeModal(modalId);
|
||||
});
|
||||
});
|
||||
|
||||
// 풀스크린 팝업 뒤로가기 이벤트 리스너
|
||||
window.addEventListener('popstate', function(event) {
|
||||
const modalId = window.location.hash.replace('#', '');
|
||||
if (modalId) {
|
||||
closeModal(modalId);
|
||||
} else {
|
||||
document.querySelectorAll('.microModal').forEach(modal => {
|
||||
MicroModal.close(modal.id);
|
||||
});
|
||||
}
|
||||
document.body.style.overflow = '';
|
||||
});
|
||||
|
||||
// 페이지 로드 시 해시 체크
|
||||
if (window.location.hash) {
|
||||
const modalId = window.location.hash.replace('#', '');
|
||||
openModal(modalId);
|
||||
}
|
||||
}
|
||||
|
||||
// 모달 열기 함수
|
||||
function openModal(modalId) {
|
||||
MicroModal.show(modalId, {
|
||||
onShow: function (modal) {
|
||||
if (window.location.hash !== '#' + modalId) {
|
||||
window.history.pushState({ modal: 'open' }, '', '#' + modalId);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 모달 닫기 함수
|
||||
function closeModal(modalId) {
|
||||
document.body.style.overflow = '';
|
||||
MicroModal.close(modalId);
|
||||
window.history.replaceState({}, '', window.location.pathname);
|
||||
}
|
||||
|
||||
// 만들기 시작 버튼 설정 함수
|
||||
function setupStartButton() {
|
||||
$('.bottomBtnControls .btn').on('click', function() {
|
||||
const selectedProduct = getSelectedProduct();
|
||||
if (selectedProduct) {
|
||||
updateModalContent(selectedProduct);
|
||||
openModal('modal-1');
|
||||
} else {
|
||||
alert('제품을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 추가 유틸리티 함수들
|
||||
function getSelectedProduct() {
|
||||
const selectedRadio = $('input[name="gameproduct"]:checked');
|
||||
if (selectedRadio.length) {
|
||||
const bnfInnb = selectedRadio.val();
|
||||
return capsuleData.productList.find(product => product.bnfInnb == bnfInnb);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 모달 내용 업데이트 함수
|
||||
function updateModalContent(product) {
|
||||
$('#modal-1 .microModal__title').html(`<b>${product.cnSj}</b><br>제품을 선택하셨네요.`);
|
||||
}
|
||||
|
||||
// 진행 상태 저장 또는 업데이트 함수
|
||||
function upsertProgressStatus(bnfInnb) {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/upsertProgressStatus',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ bnfInnb: bnfInnb }),
|
||||
success: function(response) {
|
||||
let result = JSON.parse(response.resBody.result);
|
||||
if (result.success) {
|
||||
// 만들기 화면으로 이동
|
||||
window.location.href = '/sopmal/bnft/makeStartCapsule?bnfInnb=' + bnfInnb;
|
||||
} else {
|
||||
alert('진행 상태 저장에 실패했습니다. 다시 시도해주세요.');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('서버 오류가 발생했습니다. 다시 시도해주세요.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 페이지 로드 시 실행
|
||||
$(document).ready(function() {
|
||||
initializeCapsuleSelection(capsuleData);
|
||||
|
||||
// 모달의 '예' 버튼 클릭 이벤트
|
||||
$('#modal-1 .microModal__btn-primary').on('click', function() {
|
||||
const selectedProduct = getSelectedProduct();
|
||||
if (selectedProduct) {
|
||||
upsertProgressStatus(selectedProduct.bnfInnb);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
function initializeSpecialEventSlider() {
|
||||
const $slides = $('.specialEventSlider .innerIcon');
|
||||
const slideCount = $slides.length;
|
||||
let currentIndex = 0;
|
||||
let interval;
|
||||
|
||||
// Show the slide at the specified index
|
||||
function showSlide(index) {
|
||||
$slides.hide();
|
||||
$slides.eq(index).fadeIn();
|
||||
updatePagination(index);
|
||||
}
|
||||
|
||||
// Create pagination buttons dynamically
|
||||
function createPagination() {
|
||||
const $pagination = $('.pagination');
|
||||
$pagination.empty();
|
||||
for (let i = 0; i < slideCount; i++) {
|
||||
$pagination.append(`<button data-index="${i}"></button>`);
|
||||
}
|
||||
updatePagination(0);
|
||||
}
|
||||
|
||||
// Update active state of pagination buttons
|
||||
function updatePagination(activeIndex) {
|
||||
$('.pagination button').removeClass('active');
|
||||
$('.pagination button').eq(activeIndex).addClass('active');
|
||||
}
|
||||
|
||||
// Show the next slide
|
||||
function nextSlide() {
|
||||
currentIndex = (currentIndex + 1) % slideCount;
|
||||
showSlide(currentIndex);
|
||||
}
|
||||
|
||||
// Show the previous slide
|
||||
function previousSlide() {
|
||||
currentIndex = (currentIndex - 1 + slideCount) % slideCount;
|
||||
showSlide(currentIndex);
|
||||
}
|
||||
|
||||
// Start automatic sliding
|
||||
function startSliding() {
|
||||
interval = setInterval(nextSlide, 3000);
|
||||
}
|
||||
|
||||
// Stop automatic sliding
|
||||
function stopSliding() {
|
||||
clearInterval(interval);
|
||||
}
|
||||
|
||||
// Initialize the slider
|
||||
createPagination();
|
||||
showSlide(currentIndex);
|
||||
startSliding();
|
||||
|
||||
// Set up event handlers
|
||||
$('.capsuleCollectTop').hover(stopSliding, startSliding);
|
||||
$('.pagination').on('click', 'button', function() {
|
||||
currentIndex = $(this).data('index');
|
||||
showSlide(currentIndex);
|
||||
});
|
||||
|
||||
// Add click event to advance to the next slide
|
||||
$('.capsuleCollectTop').on('click', function() {
|
||||
nextSlide();
|
||||
});
|
||||
|
||||
// Touch events for mobile support
|
||||
let touchStartX = 0;
|
||||
let touchEndX = 0;
|
||||
|
||||
$('.capsuleCollectTop').on('touchstart', function(e) {
|
||||
touchStartX = e.originalEvent.touches[0].clientX;
|
||||
});
|
||||
|
||||
$('.capsuleCollectTop').on('touchend', function(e) {
|
||||
touchEndX = e.originalEvent.changedTouches[0].clientX;
|
||||
handleSwipe();
|
||||
});
|
||||
|
||||
function handleSwipe() {
|
||||
if (touchStartX - touchEndX > 50) {
|
||||
nextSlide(); // Left swipe
|
||||
} else if (touchEndX - touchStartX > 50) {
|
||||
previousSlide(); // Right swipe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
initializeSpecialEventSlider();
|
||||
});
|
||||
@@ -0,0 +1,336 @@
|
||||
$(document).ready(function() {
|
||||
// 버블 효과 생성
|
||||
createBubbles();
|
||||
|
||||
// 플라스크 애니메이션 적용
|
||||
$('.flask1, .flask2, .flask3, .flask4, .flask5, .line1, .line2, .line3').each(function(index) {
|
||||
animateFlask($(this), [300, 1000, 200, 300, 500, 500, 300, 300][index]);
|
||||
});
|
||||
|
||||
// 초록잎/도토리 넣기 버튼 이벤트 리스너
|
||||
$('#cntGameItem').on('click', useLeaf);
|
||||
|
||||
// 초록잎/도토리 모으기 버튼 이벤트 리스너
|
||||
$('.btn.sm.outline.theme2').on('click', goToCollectPage);
|
||||
|
||||
// 클립 버튼 이벤트 리스너
|
||||
$(document).on('click', '#currentProgressButton', function() {
|
||||
loadProgressModalData();
|
||||
});
|
||||
|
||||
// 설정 버튼 이벤트 리스너
|
||||
$('#CapsuleettingsButton').on('click', function(e) {
|
||||
e.preventDefault(); // 기본 동작 방지
|
||||
goToSettingsPage();
|
||||
});
|
||||
|
||||
// 진행 단계 모달 내의 "다른 선물로 다시 시작" 버튼 이벤트 리스너
|
||||
$('.btn.giftReset').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
showRestartConfirmModal();
|
||||
});
|
||||
|
||||
// 확인 모달의 "처음부터 다시시작" 버튼 이벤트 리스너
|
||||
$(document).on('click', '#restartFromBeginning', function() {
|
||||
console.log("처음부터 다시시작 버튼 클릭됨");
|
||||
MicroModal.close('modal-3');
|
||||
restartCapsule();
|
||||
});
|
||||
|
||||
// 새로 시작하기 버튼 이벤트 리스너
|
||||
$(document).on('click', '.newStartButton', function() {
|
||||
window.location.href = '/sopmal/bnft/selectCapsule';
|
||||
});
|
||||
|
||||
// 초기 게임 상태 설정
|
||||
updateGameStatus(initialGameStatus);
|
||||
|
||||
// MicroModal 초기화
|
||||
MicroModal.init({
|
||||
disableScroll: true,
|
||||
awaitCloseAnimation: true,
|
||||
onShow: function(modal) {
|
||||
if (modal.id === 'modal-1') {
|
||||
resizeModal(modal);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 페이지 로드 시 해시 체크
|
||||
if (window.location.hash) {
|
||||
var modalId = window.location.hash.replace('#', '');
|
||||
openModal(modalId);
|
||||
}
|
||||
});
|
||||
|
||||
function createBubbles() {
|
||||
const bubbles = [
|
||||
{ size: 12, left: '20%', bottom: '-10%', delay: 0, duration: 3 },
|
||||
{ size: 10, left: '60%', bottom: '10%', delay: 0.6, duration: 2.8 },
|
||||
{ size: 8, left: '30%', bottom: '30%', delay: 0.4, duration: 2.6 },
|
||||
{ size: 6, left: '70%', bottom: '50%', delay: 1, duration: 2.4 },
|
||||
{ size: 4, left: '40%', bottom: '70%', delay: 0.8, duration: 2.2 },
|
||||
{ size: 2, left: '50%', bottom: '90%', delay: 1.2, duration: 2 }
|
||||
];
|
||||
|
||||
$.each(bubbles, function(index, bubble) {
|
||||
$('<div>')
|
||||
.addClass('bubble')
|
||||
.css({
|
||||
width: bubble.size,
|
||||
height: bubble.size,
|
||||
left: bubble.left,
|
||||
bottom: bubble.bottom,
|
||||
animationDuration: bubble.duration + 's',
|
||||
animationDelay: bubble.delay + 's'
|
||||
})
|
||||
.appendTo('#bubbleContainer');
|
||||
});
|
||||
}
|
||||
|
||||
function animateFlask($flaskElement, interval) {
|
||||
const $images = $flaskElement.find('.svgContainer img');
|
||||
let currentIndex = 0;
|
||||
|
||||
function showNextImage() {
|
||||
$images.eq(currentIndex).hide();
|
||||
currentIndex = (currentIndex + 1) % $images.length;
|
||||
$images.eq(currentIndex).show();
|
||||
}
|
||||
|
||||
$images.hide().eq(0).show();
|
||||
setInterval(showNextImage, interval);
|
||||
}
|
||||
|
||||
function updateGameStatus(newStatus) {
|
||||
$('.percentage-bar').width(newStatus.progressPercent + '%');
|
||||
$('.per-flask span').text(newStatus.progressStep + '단계');
|
||||
$('.per-txt').text(newStatus.progressPercent + '% 채웠어요.');
|
||||
$('#ContingItem').html(`<i class="${shopCode === 'NC' ? 'ico_leaf' : 'ico_acorn'}"></i>${newStatus.remainingLeafCount}개`);
|
||||
$('.bar-container').attr('class', `bar-container flask0${newStatus.progressStep}`);
|
||||
$('#currentStep').text(newStatus.progressStep + '단계');
|
||||
}
|
||||
|
||||
function useLeaf() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/useLeaf',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
useLeafCnt: 10,
|
||||
bnfInnb: 81,
|
||||
progrsStep: initialGameStatus.progressStep // 현재 진행 단계 추가
|
||||
}),
|
||||
success: function(response) {
|
||||
let result = JSON.parse(response.resBody.result);
|
||||
if (result.success === true) {
|
||||
try {
|
||||
updateGameStatus(result);
|
||||
} catch (e) {
|
||||
showToast(result.error || '초록잎/도토리 사용에 실패했습니다.');
|
||||
}
|
||||
} else {
|
||||
showToast('서버 응답이 올바르지 않습니다.');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
showToast('서버와의 통신 중 오류가 발생했습니다.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function restartCapsule() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/restartCapsule',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ bnfInnb: 81 }), // bnfInnb 값은 실제 사용하는 값으로 변경해야 합니다.
|
||||
success: function(response) {
|
||||
let result = JSON.parse(response.resBody.result);
|
||||
if (result.success === true) {
|
||||
showToast('캡슐 만들기가 초기화되었습니다. 새로 시작합니다.');
|
||||
// 페이지 이동
|
||||
window.location.href = '/sopmal/bnft/selectCapsule';
|
||||
} else {
|
||||
showToast(response.message || '캡슐 만들기 초기화에 실패했습니다.');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
showToast('서버와의 통신 중 오류가 발생했습니다.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function showToast(message) {
|
||||
const $toast = $('#acorn_toast');
|
||||
$toast.text(message).addClass('show');
|
||||
setTimeout(() => {
|
||||
$toast.removeClass('show');
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function goToCollectPage() {
|
||||
window.location.href = '/sopmal/bnft/cpslmknCollectList';
|
||||
}
|
||||
|
||||
function goToSettingsPage() {
|
||||
// URL에서 bnfInnb 값을 추출
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const bnfInnb = urlParams.get('bnfInnb');
|
||||
|
||||
// bnfInnb 값이 있으면 설정 페이지 URL에 추가
|
||||
let settingsUrl = '/sopmal/bnft/cpslmknSettings';
|
||||
if (bnfInnb) {
|
||||
settingsUrl += `?bnfInnb=${bnfInnb}`;
|
||||
}
|
||||
|
||||
// 설정 페이지로 이동
|
||||
window.location.href = settingsUrl;
|
||||
}
|
||||
|
||||
function showRestartConfirmModal() {
|
||||
openModal('modal-3');
|
||||
}
|
||||
|
||||
function loadProgressModalData() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/selectProgressModalData',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ bnfInnb: 81 }),
|
||||
beforeSend: function() {
|
||||
showLoadingIndicator();
|
||||
},
|
||||
success: function(response) {
|
||||
let result = JSON.parse(response.resBody.result);
|
||||
if (result.success === true) {
|
||||
updateProgressModal(result);
|
||||
openModal('modal-1');
|
||||
} else {
|
||||
showToast(result.error || '데이터를 불러오는 데 실패했습니다.');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching modal data:', error);
|
||||
showToast('서버와의 통신 중 오류가 발생했습니다.');
|
||||
},
|
||||
complete: function() {
|
||||
hideLoadingIndicator();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateProgressModal(data) {
|
||||
$('#currentStep').text(data.currentStep + '단계');
|
||||
$('#progressBar').css('width', data.progressPercent + '%');
|
||||
$('#giftTitle').text(data.giftTitle);
|
||||
$('#giftDescription').text(data.giftDescription);
|
||||
loadImage('giftImage', data.giftImageUrl, $('#giftImage'));
|
||||
$('#importantNotice').html(data.importantNotice);
|
||||
|
||||
// 진행 단계에 따라 클래스 추가
|
||||
$('.gameStatusBar span').removeClass('on');
|
||||
for (let i = 1; i <= data.currentStep; i++) {
|
||||
$(`.gameStatusBar .step0${i}`).addClass('on');
|
||||
}
|
||||
|
||||
// 5단계(완성)일 경우 'last' 클래스에도 'on' 추가
|
||||
if (data.currentStep === 5) {
|
||||
$('.gameStatusBar .last').addClass('on');
|
||||
}
|
||||
|
||||
// **추가된 부분: '새로 시작하기' 버튼 표시 여부 제어**
|
||||
if (data.progressPercent >= 100) {
|
||||
$('#newStartButtonContainer').show();
|
||||
} else {
|
||||
$('#newStartButtonContainer').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function loadImage(imageType, imagePath, $img) {
|
||||
if ($img.length && imagePath) {
|
||||
var fullImagePath = '/sopmal/bnft/image?path=' + encodeURIComponent(uploadDirs + imagePath);
|
||||
$img.attr('src', fullImagePath);
|
||||
console.log(`${imageType} image loaded successfully:`, fullImagePath);
|
||||
} else {
|
||||
console.warn(`Image element not found for ${imageType} or imagePath is empty`);
|
||||
}
|
||||
}
|
||||
|
||||
function resizeModal(modal) {
|
||||
const modalContent = modal.querySelector('.microModal__container');
|
||||
const modalBody = modal.querySelector('.microModal__body');
|
||||
const modalTop = modal.querySelector('.microModal__top');
|
||||
const modalContentArea = modal.querySelector('.microModal__content');
|
||||
const viewportHeight = window.innerHeight;
|
||||
const desiredHeight = viewportHeight * 0.9;
|
||||
|
||||
modalContent.style.height = `${desiredHeight}px`;
|
||||
modalContent.style.maxHeight = `${desiredHeight}px`;
|
||||
modalContent.style.width = '100%';
|
||||
modalContent.style.maxWidth = '100%';
|
||||
modalContent.style.margin = '0';
|
||||
modalContent.style.padding = '0';
|
||||
|
||||
modalBody.style.height = '100%';
|
||||
modalBody.style.padding = '0';
|
||||
|
||||
if (modalTop) {
|
||||
modalTop.style.padding = '10px';
|
||||
}
|
||||
|
||||
if (modalContentArea) {
|
||||
const topHeight = modalTop ? modalTop.offsetHeight : 0;
|
||||
modalContentArea.style.height = `calc(100% - ${topHeight}px)`;
|
||||
modalContentArea.style.overflowY = 'auto';
|
||||
modalContentArea.style.padding = '10px';
|
||||
}
|
||||
|
||||
const gameStatus = modal.querySelector('.gameStatus');
|
||||
const gameStatusBar = modal.querySelector('.gameStatusBar');
|
||||
const gameGiftInbox = modal.querySelector('.gameGiftInbox');
|
||||
|
||||
if (gameStatus) gameStatus.style.margin = '10px 0';
|
||||
if (gameStatusBar) gameStatusBar.style.margin = '10px 0';
|
||||
if (gameGiftInbox) gameGiftInbox.style.margin = '10px 0';
|
||||
}
|
||||
|
||||
function showLoadingIndicator() {
|
||||
$('#clipButton').text('로딩 중...').prop('disabled', true);
|
||||
}
|
||||
|
||||
function hideLoadingIndicator() {
|
||||
$('#clipButton').text('현재 진행 상태').prop('disabled', false);
|
||||
}
|
||||
|
||||
function openModal(modalId) {
|
||||
MicroModal.show(modalId, {
|
||||
onShow: function(modal) {
|
||||
if (modal.id === 'modal-1') {
|
||||
resizeModal(modal);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function closeModal(modalId) {
|
||||
document.body.style.overflow = '';
|
||||
MicroModal.close(modalId);
|
||||
window.history.replaceState({}, '', window.location.pathname);
|
||||
}
|
||||
|
||||
// 풀스크린 팝업 뒤로가기 이벤트 리스너
|
||||
window.addEventListener('popstate', function (event) {
|
||||
var modalId = window.location.hash.replace('#', '');
|
||||
if (modalId) {
|
||||
closeModal(modalId);
|
||||
} else {
|
||||
$('.microModal').each(function () {
|
||||
MicroModal.close($(this).attr('id'));
|
||||
});
|
||||
}
|
||||
document.body.style.overflow = '';
|
||||
});
|
||||
@@ -0,0 +1,168 @@
|
||||
// CpslmknIntro.js
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
initializeIntro();
|
||||
initializeModal();
|
||||
openInitialModal();
|
||||
initializeButtonEvents();
|
||||
});
|
||||
|
||||
function openInitialModal() {
|
||||
// 페이지 로드 시 모달 자동 오픈
|
||||
openModal('modal-1');
|
||||
}
|
||||
|
||||
function initializeIntro() {
|
||||
var $slides = $('.gameIntroWrap');
|
||||
var $paging = $('.gamePaging');
|
||||
var currentIndex = 0;
|
||||
var slideCount = $slides.length;
|
||||
|
||||
// 페이징 생성
|
||||
for (var i = 0; i < slideCount; i++) {
|
||||
$paging.append('<span></span>');
|
||||
}
|
||||
|
||||
// 초기 슬라이드 및 페이징 설정
|
||||
showSlide(currentIndex);
|
||||
|
||||
// gameIntroPaging 클릭 이벤트
|
||||
$('.gameIntroPaging').on('click', function() {
|
||||
currentIndex = (currentIndex + 1) % slideCount;
|
||||
showSlide(currentIndex);
|
||||
});
|
||||
|
||||
// 페이징 클릭 이벤트
|
||||
$paging.on('click', 'span', function() {
|
||||
currentIndex = $(this).index();
|
||||
showSlide(currentIndex);
|
||||
});
|
||||
|
||||
function showSlide(index) {
|
||||
$slides.hide().eq(index).fadeIn();
|
||||
$paging.find('span').removeClass('active').eq(index).addClass('active');
|
||||
}
|
||||
}
|
||||
|
||||
function initializeModal() {
|
||||
MicroModal.init({
|
||||
disableScroll: true,
|
||||
awaitCloseAnimation: true,
|
||||
});
|
||||
|
||||
// 풀스크린 팝업 트리거 이벤트 리스너
|
||||
$('.fullscreen-trigger').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var modalId = $(this).attr('data-micromodal-trigger');
|
||||
openModal(modalId);
|
||||
});
|
||||
|
||||
// 풀스크린 팝업 닫기 이벤트 리스너
|
||||
$('.microModal .microModal__close').on('click', function() {
|
||||
var modalId = $(this).closest('.microModal').attr('id');
|
||||
closeModal(modalId);
|
||||
});
|
||||
|
||||
// 풀스크린 팝업 뒤로가기 이벤트 리스너
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
|
||||
// 페이지 로드 시 Hash 체크
|
||||
if (window.location.hash) {
|
||||
var modalId = window.location.hash.replace('#', '');
|
||||
openModal(modalId);
|
||||
}
|
||||
|
||||
// 모달 내 버튼 클릭 이벤트
|
||||
$('.microModal__btnContainer .btn').on('click', function() {
|
||||
closeModal('modal-1');
|
||||
// 여기에 캡슐 만들기 페이지로 이동하는 로직 추가
|
||||
// 예: window.location.href = 'capsule-making-page.html';
|
||||
});
|
||||
}
|
||||
|
||||
function openModal(modalId) {
|
||||
MicroModal.show(modalId, {
|
||||
onShow: function(modal) {
|
||||
if (window.location.hash !== '#' + modalId) {
|
||||
window.history.pushState({ modal: 'open' }, '', '#' + modalId);
|
||||
}
|
||||
},
|
||||
disableScroll: true,
|
||||
awaitCloseAnimation: true
|
||||
});
|
||||
}
|
||||
|
||||
function closeModal(modalId) {
|
||||
document.body.style.overflow = '';
|
||||
MicroModal.close(modalId);
|
||||
window.history.replaceState({}, '', window.location.pathname);
|
||||
}
|
||||
|
||||
function handlePopState(event) {
|
||||
var modalId = window.location.hash.replace('#', '');
|
||||
if (modalId) {
|
||||
closeModal(modalId);
|
||||
} else {
|
||||
$('.microModal').each(function() {
|
||||
MicroModal.close($(this).attr('id'));
|
||||
});
|
||||
}
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
// 쇼핑몰 코드에 따른 텍스트 변경 함수
|
||||
function updateTexts() {
|
||||
const isNC = shopCode === 'NC';
|
||||
const itemName = isNC ? '초록잎' : '도토리';
|
||||
const capsuleName = isNC ? '뉴트리캡슐' : '닥터린캡슐';
|
||||
|
||||
$('.gameTop').text(`진짜 영양제를 무료로 받는 방법`);
|
||||
$('.gameIntroWrap:nth-child(2) .tit').text(`1. ${itemName}을 모아주세요.`);
|
||||
$('.gameIntroWrap:nth-child(2) p').html(`혜택 메뉴의 다양한 이벤트에 참여하면<br>${capsuleName} 만들기에 필요한<br>${itemName}을 드려요.`);
|
||||
$('.gameIntroWrap:nth-child(3) p').html(`보유한 ${itemName}을<br>실험실의 유리병에 넣어주세요.<br>모든 유리병이 가득 채워지면<br>${capsuleName}이 완성됩니다.`);
|
||||
$('.gameIntroWrap:nth-child(4) p').html(`${capsuleName}을 완성하면<br>진짜 영양제를 선물로 보내드려요.<br>그럼, 지금부터 시작해 볼까요?`);
|
||||
$('.microModal__btnContainer .btn').text(`${capsuleName} 만들러 가볼까?`);
|
||||
}
|
||||
|
||||
//이전 진행 상태 확인 함수
|
||||
function checkPreviousProgress() {
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/checkPreviousProgress',
|
||||
method: 'POST',
|
||||
contentType: 'application/json', // 서버에서 JSON 형식의 데이터를 기대할 때
|
||||
data: JSON.stringify({ bnfInnb: 87626 }),
|
||||
success: function(response) {
|
||||
let result = JSON.parse(response.resBody.result);
|
||||
if (result.success === true) {
|
||||
// 이전에 선택한 제품이 있으면 바로 만들기 화면으로 이동
|
||||
window.location.href = '/sopmal/bnft/makeStartCapsule?bnfInnb=' + response.bnfInnb;
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
console.error('이전 진행 상태 확인 중 오류가 발생했습니다.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initializeButtonEvents() {
|
||||
const goCapsuleMakingButton = document.getElementById('goCapsuleMaking');
|
||||
if (goCapsuleMakingButton) {
|
||||
goCapsuleMakingButton.addEventListener('click', goToCapsuleMakingPage);
|
||||
}
|
||||
}
|
||||
|
||||
function goToCapsuleMakingPage() {
|
||||
window.location.href = 'http://dev.nutricore.co.kr:18310/sopmal/bnft/selectCapsule';
|
||||
}
|
||||
|
||||
// 모달 내 버튼 클릭 이벤트 업데이트
|
||||
$('.microModal__btnContainer .btn').on('click', function() {
|
||||
closeModal('modal-1');
|
||||
goToCapsuleMakingPage();
|
||||
});
|
||||
|
||||
// 페이지 로드 시 텍스트 업데이트
|
||||
$(document).ready(function() {
|
||||
// checkPreviousProgress(); // 이전 진행 상태 확인
|
||||
updateTexts();
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
// 초록잎/도토리 보유 내역 페이지로 이동하는 함수
|
||||
function goToLeafHistory() {
|
||||
// TODO: 실제 페이지 URL로 수정 필요
|
||||
window.location.href = '/sopmal/bnft/leafHistory';
|
||||
}
|
||||
|
||||
// 알림 설정 토글 함수
|
||||
function toggleNotification() {
|
||||
const $switch = $('input[role="switch"]');
|
||||
const isChecked = $switch.prop('checked');
|
||||
const agreAt = isChecked ? 'Y' : 'N';
|
||||
|
||||
$.ajax({
|
||||
url: '/sopmal/bnft/capsuleAlarmAgreement',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
bnfDvCd: '050', // 캡슐만들기의 혜택 구분 코드
|
||||
bnfAgreDvCd: '010', // 알림동의 구분 코드
|
||||
agreAt: agreAt
|
||||
}),
|
||||
success: function(response) {
|
||||
let result = JSON.parse(response.resBody.result);
|
||||
if (result.success === true) {
|
||||
alert('알림 설정이 변경되었습니다.');
|
||||
} else {
|
||||
alert('알림 설정 변경에 실패했습니다.');
|
||||
// 체크박스 상태를 원래대로 되돌림
|
||||
$switch.prop('checked', !isChecked);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('서버와의 통신 중 오류가 발생했습니다.');
|
||||
// 체크박스 상태를 원래대로 되돌림
|
||||
$switch.prop('checked', !isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 페이지 로드 시 실행
|
||||
$(document).ready(function() {
|
||||
const leafText = shopCode === 'NC' ? '초록잎' : '도토리';
|
||||
|
||||
// 초록잎/도토리 보유 내역 링크 텍스트 설정
|
||||
$('.productManagement li:first-child a').text(`${leafText} 보유내역`);
|
||||
|
||||
// 초록잎/도토리 보유 내역 링크에 이벤트 리스너 추가
|
||||
$('.productManagement li:first-child a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
goToLeafHistory();
|
||||
});
|
||||
|
||||
// 알림 설정 스위치에 이벤트 리스너 추가
|
||||
$('input[role="switch"]').on('change', toggleNotification);
|
||||
|
||||
// 초기 알림 상태 설정
|
||||
$('input[role="switch"]').prop('checked', notificationStatus === 'Y');
|
||||
|
||||
// 엑스 버튼 클릭 이벤트 리스너
|
||||
$('.header__toBack__btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
window.history.back();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user