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,345 @@
// 출석체크 관련 기능을 담당하는 즉시 실행 함수
const Atend = (function() {
// 현재 날짜 정보
const currentDate = new Date();
const currentMonth = currentDate.getMonth();
const currentYear = currentDate.getFullYear();
const currentDay = currentDate.getDate();
const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
const firstDayOfMonth = new Date(currentYear, currentMonth, 1).getDay();
// DOM 요소
const daysContainer = document.querySelector(".days");
const checkAttendanceButton = document.getElementById("check-attendance");
// 월 이름 배열
const monthNames = ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"];
// 출석 일자 배열 (공백 제거 처리)
const trimmedAttendanceDays = trimArrayElements(attendanceDays);
// 초기화 함수
function init() {
updateMonthTitle();
generateCalendar();
addEventListeners();
loadImages();
}
// 월 제목 업데이트
function updateMonthTitle() {
document.querySelector(".month-tit").textContent = monthNames[currentMonth];
}
// 달력 생성
function generateCalendar() {
generateEmptyCells();
generateDays();
}
// 달력 앞부분 빈 셀 생성
function generateEmptyCells() {
for (let i = 0; i < firstDayOfMonth; i++) {
const emptyCell = document.createElement("div");
daysContainer.appendChild(emptyCell);
}
}
// 달력 일자 생성
function generateDays() {
for (let day = 1; day <= daysInMonth; day++) {
const calendarDay = document.createElement("div");
calendarDay.textContent = day;
const formattedDay = formatDate(currentYear, currentMonth + 1, day);
if (trimmedAttendanceDays.includes(formattedDay)) {
calendarDay.classList.add("success");
}
if (day === currentDay) {
calendarDay.classList.add("today");
}
daysContainer.appendChild(calendarDay);
}
}
// 이벤트 리스너 추가
function addEventListeners() {
checkAttendanceButton.addEventListener("click", handleAttendanceCheck);
}
// 출석체크 처리
function handleAttendanceCheck() {
const formattedToday = formatDate(currentYear, currentMonth + 1, currentDay);
if (!trimmedAttendanceDays.includes(formattedToday)) {
const attendanceCount = trimmedAttendanceDays.length + 1;
const bnfRwdCateDvCd = getBenefitRewardCode(attendanceCount);
saveAttendance(formattedToday, bnfRwdCateDvCd);
} else {
openModal('modal-already-checked');
}
}
// 출석 정보 저장
function saveAttendance(formattedToday, bnfRwdCateDvCd) {
$.ajax({
url: '/sopmal/bnft/participateAttendanceCheck',
method: 'POST',
contentType: 'application/json; charset=UTF-8',
data: JSON.stringify({
bnfInnb: screenInfo.bnfInnb,
mbrInnb: 87626, // 하드코딩된 회원 고유번호
bnfPrtDt: formattedToday,
mbrDvCd: 'GC', // 하드코딩된 회원 구분 코드
bnfRwdCateDvCd: bnfRwdCateDvCd,
bnfRwdGodsDvCd: '010'
}),
success: handleAttendanceSuccess(formattedToday),
error: handleAttendanceError
});
}
// 출석 저장 성공 처리
function handleAttendanceSuccess(formattedToday) {
return function(response) {
console.log('Attendance saved:', response);
trimmedAttendanceDays.push(formattedToday);
updateCalendarUI();
showAttendanceModal();
getLatestAttendanceInfo();
};
}
// 출석 저장 실패 처리
function handleAttendanceError(xhr, status, error) {
console.error('Failed to save attendance:', error);
alert('출석체크를 저장하는 데 실패했습니다. 다시 시도해주세요.');
}
// 달력 UI 업데이트
function updateCalendarUI() {
const todayElement = Array.from(daysContainer.children).find(child => child.textContent == currentDay);
if (todayElement) {
todayElement.classList.add("success");
}
}
// 출석 모달 표시
function showAttendanceModal() {
const attendanceCount = trimmedAttendanceDays.length;
if (attendanceCount === 10) {
openModal('modal-2');
} else if (attendanceCount === 20) {
openModal('modal-3');
} else if (attendanceCount === daysInMonth) {
openModal('modal-4');
} else {
openModal('modal-1');
}
}
// 최신 출석 정보 조회
function getLatestAttendanceInfo() {
$.ajax({
url: '/sopmal/bnft/getLatestAttendanceInfo',
method: 'POST',
data: JSON.stringify({
mbrInnB: 87626,
bnfInnb: screenInfo.bnfInnb
}), // 하드코딩된 회원 고유번호
contentType: 'application/json; charset=utf-8',
success: function(response) {
updateAttendanceInfo(response.attendanceCount, response.totalAttendanceMileage);
},
error: function(xhr, status, error) {
console.error('Failed to fetch latest attendance info:', error);
}
});
}
// 출석 정보 UI 업데이트
function updateAttendanceInfo(attendanceCount, totalAttendanceMileage) {
document.querySelector(".cnt1").textContent = `${attendanceCount}회`;
document.querySelector(".cnt2").textContent = `${totalAttendanceMileage}원`;
}
// 이미지 로딩
function loadImages() {
console.log('Starting to load images');
loadImage('representative', screenInfo.representativeImagePath, $('.Att-bg img'));
loadImage('reward', screenInfo.rewardImagePath, $('.eventAtt-banner img'));
}
// 개별 이미지 로딩
function loadImage(imageType, imagePath, $img) {
if (!imagePath) {
console.warn(`Image path for ${imageType} is not available`);
return;
}
if ($img.length) {
$.ajax({
url: '/sopmal/bnft/image',
method: 'GET',
data: { path: imagePath, type: imageType },
xhrFields: { responseType: 'blob' },
success: function(data) {
const imageUrl = URL.createObjectURL(data);
$img.attr('src', imageUrl);
console.log(`${imageType} image loaded successfully`);
if (imageType === 'reward') {
updateRewardBannerLink();
}
},
error: function() {
console.error(`Failed to load ${imageType} image`);
$img.attr('src', '/path/to/fallback-image.jpg');
}
});
} else {
console.warn(`Image element not found for ${imageType}`);
}
}
// 보상 배너 링크 업데이트
function updateRewardBannerLink() {
const $bannerLink = $('.eventAtt-banner a');
if ($bannerLink.length && screenInfo.scrRwdLinkUrl) {
$bannerLink.attr('href', screenInfo.scrRwdLinkUrl);
console.log('Updated banner link URL:', screenInfo.scrRwdLinkUrl);
}
}
// 유틸리티 함수들
function trimArrayElements(arr) {
return arr.map(element => element.replace(/[\[\]\s]/g, ''));
}
function formatDate(year, month, day) {
return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
}
function getBenefitRewardCode(attendanceCount) {
if (attendanceCount === 10) return '01020';
if (attendanceCount === 20) return '01030';
if (attendanceCount === daysInMonth) return '01040';
return '01010';
}
// 알림 상태 조회
function getNotificationStatus() {
$.ajax({
url: '/sopmal/bnft/getNotificationStatus',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({ bnfInnb: screenInfo.bnfInnb }),
success: function(response) {
updateNotificationButton(response.notificationStatus);
},
error: function(xhr, status, error) {
console.error('알림 상태 조회 실패:', error);
}
});
}
// 알림 버튼 업데이트
function updateNotificationButton(isNotificationOn) {
const $notificationBtn = $('.eventAtt__btnContainer .btn.outline.full');
const $iconElement = $notificationBtn.find('i.ico_alarm');
if (isNotificationOn) {
$notificationBtn.contents().filter(function() {
return this.nodeType === 3; // Text nodes
}).replaceWith('알림 신청 완료');
$notificationBtn.data('action', 'cancel');
} else {
$notificationBtn.contents().filter(function() {
return this.nodeType === 3; // Text nodes
}).replaceWith('알림 신청');
$notificationBtn.data('action', 'apply');
}
// 아이콘 요소가 없으면 추가
if ($iconElement.length === 0) {
$notificationBtn.prepend('<i class="ico_alarm"></i>');
}
}
// 알림 신청/취소 처리
function handleNotification(action) {
const url = action === 'apply' ? '/sopmal/bnft/applyNotification' : '/sopmal/bnft/cancelNotification';
$.ajax({
url: url,
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({ bnfInnb: screenInfo.bnfInnb }),
success: function(response) {
if (response.success) {
alert(action === 'apply' ? '알림 신청이 완료되었습니다.' : '알림 취소가 완료되었습니다.');
getNotificationStatus();
} else {
alert(response.message || (action === 'apply' ? '알림 신청에 실패했습니다.' : '알림 취소에 실패했습니다.'));
}
},
error: function(xhr, status, error) {
console.error(action === 'apply' ? '알림 신청 실패:' : '알림 취소 실패:', error);
alert(action === 'apply' ? '알림 신청 중 오류가 발생했습니다.' : '알림 취소 중 오류가 발생했습니다.');
}
});
}
// 초기화 및 이벤트 리스너
document.addEventListener("DOMContentLoaded", function() {
init();
getNotificationStatus();
$(document).on('click', '.eventAtt__btnContainer .btn.outline.full', function(e) {
e.preventDefault();
const action = $(this).data('action');
handleNotification(action);
});
});
// 공개 메서드
return {
getLatestAttendanceInfo: getLatestAttendanceInfo,
getNotificationStatus: getNotificationStatus,
handleNotification: handleNotification
};
})();
// 모달 관련 함수들
function openModal(modalId) {
MicroModal.show(modalId);
}
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 {
document.querySelectorAll('.microModal').forEach(modal => {
MicroModal.close(modal.id);
});
}
document.body.style.overflow = '';
});
// 페이지 로드 시 해시 체크
if (window.location.hash) {
var modalId = window.location.hash.replace('#', '');
openModal(modalId);
}