/****************************************************************************
* 메인이벤트조회
****************************************************************************/
function fn_selectMainEventList(){
let formData = new FormData();
formData.append("exposedYn", "Y")
$.ajax({
url: encodeURI('/mobilehome/selectListEvent.do'),
data: formData,
dataType: "json",
processData: false,
contentType: false,
type: 'POST',
async: false,
success: function(data){
if('0'==data.msgCode){
if(0 < data.rows.length){
const events = data.rows;
const swiperWrapper = $('.swiper-wrapper');
swiperWrapper.empty(); // 기존 콘텐츠 초기화
events.forEach((event, index) => {
// swiper-slide 클래스를 생성하여 이벤트 정보 삽입
const className = `swiper-slide slide-${index + 1}`;
const slideHTML = `
${event.title}
${event.content}
`;
// swiper-wrapper에 추가
swiperWrapper.append(slideHTML);
const homeSwiper = new Swiper('.homeSwiper', {
loop: true,
autoplay: true,
direction: 'horizontal',
/*pagination: {
el: '.swiper-pagination',
type: 'bullets'
},*/
});
});
}
}
else if(data.msgCode=='-1'){
modalEvent.warning("조회 오류", data.msgDesc);
}
else{
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
}
},
error : function(xhr, status, error) {
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
},
beforeSend:function(){
},
complete:function(){
}
});
}
/****************************************************************************
* 이벤트 리스트 조회
****************************************************************************/
function fn_selectEventList(){
let formData = new FormData();
$.ajax({
url: encodeURI('/mobilehome/selectListEvent.do'),
data: formData,
dataType: "json",
processData: false,
contentType: false,
type: 'POST',
async: false,
success: function(data){
if('0'==data.msgCode){
let innerHTML='';
if(0 < data.rows.length){
const events = data.rows;
// 기존 콘텐츠 초기화
events.forEach((event, index) => {
innerHTML += `
${event.title}
${event.content}
`;
});
}else {
innerHTML = '등록된 이벤트가 없습니다.
'
}
$('#event').empty().html(innerHTML).trigger("create");
} else if (data.msgCode == '-1') {
modalEvent.warning("조회 오류", data.msgDesc);
}
else{
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
}
},
error : function(xhr, status, error) {
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
},
beforeSend:function(){
},
complete:function(){
}
});
}
/****************************************************************************
* 메인컨텐츠 보드조회
****************************************************************************/
function fn_selectMainBoardList(){
let formData = new FormData();
formData.append("exposedYn","Y")
$.ajax({
url: encodeURI('/mobilehome/selectListMedicalBoard.do'),
data: formData,
dataType: "json",
processData: false,
contentType: false,
type: 'POST',
async: false,
success: function(data){
if('0'==data.msgCode){
if (0 < Object.keys(data.rows).length) {
const boards = data.rows;
const boardWrapper = $('#home');
$('.popular_box').remove(); // 기존 콘텐츠 초기화
// 각 boardId에 대해 처리
Object.keys(boards).forEach((boardId) => {
const board = boards[boardId];
const boardDiv = document.createElement('div');
boardDiv.className = 'popular_box';
// 첫 번째 board의 제목과 콘텐츠 추가
boardDiv.innerHTML = `
${board[0].boardTitle}
${board[0].boardContent}
`;
// 각 콘텐츠 항목을 처리
board.forEach((content, index) => {
const contentUl = document.createElement('ul');
contentUl.className = 'list_box';
contentUl.innerHTML = `
${index + 1}
${content.title}
${content.content}
`;
// boardDiv에 contentUl 추가
boardDiv.appendChild(contentUl);
});
// boardWrapper에 boardDiv 추가
boardWrapper.append(boardDiv);
});
}else{
}
} else if (data.msgCode=='-1'){
modalEvent.warning("조회 오류", data.msgDesc);
}
else{
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
}
},
error : function(xhr, status, error) {
modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
},
beforeSend:function(){
},
complete:function(){
}
});
}
/****************************************************************************
* 이벤트 상세페이지 이동
****************************************************************************/
function fn_eventIntro(id){
fn_tapPageMove("home", "event", '/mobileevent/selectEventIntro.do?muAppEventId='+id);
// location.href = '/mobileevent/selectEventIntro.do?muAppEventId='+id;
}
/****************************************************************************
* 시술 상세페이지 이동
****************************************************************************/
function fn_medicalIntro(id){
location.href = '/mobilemedical/selectMedicalIntro.do?muAppContentId='+id;
}
/****************************************************************************
* 페이지 init
****************************************************************************/
function fn_pageInit(){
//메인이벤트조회
fn_selectMainEventList();
// 메인컨텐츠 보드조회
fn_selectMainBoardList();
//main 높이값 - class
if($('.notify_box').hasClass('open')){
$('main').addClass('short');
}else{
$('main').addClass('short2');
}
}
/****************************************************************************
* 페이지 event
****************************************************************************/
function fn_pageEvent(){
$('.nav_box a[aria-controls="event"]').on('click', function(event) {
fn_selectEventList();
});
}
/****************************************************************************
* 페이지 탭 선택
****************************************************************************/
function fn_pageTapSelect(){
$(".navTap").removeClass("active");
$(".tabContent").removeClass("active");
if("home" == referTap){
$("#navTap_home a").click();
}else if("event" == referTap){
$("#navTap_event a").click();
}else{
$("#navTap_home a").click();
}
}
$(function(){
// 페이지 init
fn_pageInit();
// 페이지 event
fn_pageEvent();
// 페이지 탭 선택
fn_pageTapSelect()
});