merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정

This commit is contained in:
jilee4unity
2026-05-28 23:34:06 +09:00
7250 changed files with 570509 additions and 25 deletions

View File

@@ -0,0 +1,126 @@
/**
* CpslmknSettings.js
*
* 캡슐 메이킹 게임 설정 페이지 관련 기능 구현
* 초록잎/도토리 보유 내역 보기, 알림 설정 등 사용자 설정 기능 제공
*/
/**
* 토스트 메시지 표시 함수
* @param {string} message - 표시할 메시지
*/
function showToast(message) {
// 기존에 토스트 요소가 있으면 제거
$('.toastPop').remove();
// 토스트 요소 생성 및 추가
const $toast = $('<div class="toastPop">' + message + '</div>');
$('body').append($toast);
// 토스트 표시 및 자동 제거
setTimeout(function() {
$toast.addClass('show');
setTimeout(function() {
$toast.removeClass('show');
// 애니메이션 완료 후 요소 제거
setTimeout(function() {
$toast.remove();
}, 300);
}, 2000);
}, 100);
}
/**
* 초록잎/도토리 보유 내역 페이지로 이동하는 함수
* 사용자가 현재까지 모은 아이템 내역을 확인할 수 있는 페이지로 이동
*/
function goToLeafHistory() {
const sopmalCd = $('#sopmalCd').val();
window.location.href = `/sopmal/bnft/leafHistory?sopmalCd=${sopmalCd}`;
}
/**
* 알림 설정 토글 함수
* 사용자의 알림 수신 동의 상태를 변경하고 서버에 업데이트
* 스위치 토글 시 호출되어 서버에 알림 설정 변경 요청
*/
function toggleNotification() {
// 토글 스위치 요소 및 현재 선택 상태 가져오기
const $switch = $('input[role="switch"]'); // 토글 스위치 요소
const isChecked = $switch.prop('checked'); // 현재 스위치 상태 (체크됨/안됨)
const agreAt = isChecked ? 'Y' : 'N'; // 동의 여부 값 (Y: 동의, N: 미동의)
// 서버에 알림 설정 변경 요청
$.ajax({
url: '/sopmal/bnft/notification',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({
// bnfDvCd, bnfAgreDvCd는 백엔드에서 고정값 사용 또는 자동 인식 가능 시 제거 가능
bnfDvCd: '050',
bnfAgreDvCd: '010',
agreAt: agreAt // 동의 여부 (Y/N) - 필수 전송
}),
// 요청 성공 시 처리
success: function(response) {
// 응답 결과 파싱 (WnbtResponse 구조 가정)
try {
// responseHandler가 이미 파싱해줄 수 있으나, 안전하게 처리
let resultData = {};
if (typeof response.resBody?.result === 'string') {
resultData = JSON.parse(response.resBody.result);
} else {
resultData = response.resBody?.result || {};
}
if (resultData.success === true) {
// 설정 변경 성공 메시지 (기존 alert 대신 다른 UI 고려 가능)
showToast(resultData.message || '알림 설정이 변경되었습니다.');
} else {
// 설정 변경 실패 메시지
showToast(resultData.message || '알림 설정 변경에 실패했습니다.');
// 서버 처리 실패 시 UI 상태 복원 (토글 원상태로)
$switch.prop('checked', !isChecked);
}
} catch (e) {
console.error("알림 설정 응답 처리 오류:", e);
showToast('알림 설정 응답 처리 중 오류가 발생했습니다.');
$switch.prop('checked', !isChecked); // 오류 시 UI 복원
}
},
// 요청 실패 시 처리
error: function(jqXHR, textStatus, errorThrown) {
// 통신 오류 메시지
console.error("알림 설정 API 호출 실패:", textStatus, errorThrown);
showToast('서버와의 통신 중 오류가 발생했습니다.');
// 통신 실패 시 UI 상태 복원 (토글 원상태로)
$switch.prop('checked', !isChecked);
}
});
}
/**
* 페이지 로드 시 실행되는 초기화 함수
* 페이지 UI 설정, 이벤트 리스너 등록, 초기 상태 설정
*/
$(document).ready(function() {
// 초록잎/도토리 보유 내역 링크 클릭 이벤트 리스너 추가
$('.productManagement li:first-child a').on('click', function(e) {
e.preventDefault(); // 기본 링크 동작 방지
goToLeafHistory(); // 보유 내역 페이지로 이동 함수 호출
});
// 알림 설정 스위치 변경 이벤트 리스너 추가
$('input[role="switch"]').on('change', toggleNotification);
// 페이지 로드 시 서버에서 받아온 사용자의 현재 알림 설정 상태에 따라 스위치 초기화
// notificationStatus 변수는 JSP에서 전역으로 선언되어 있어야 함 ('Y' 또는 'N')
if (typeof notificationStatus !== 'undefined') {
$('input[role="switch"]').prop('checked', notificationStatus === 'Y');
}
});