모바일 리스트 페이지 더보기 안됩니다
kmall
5년 전
조회 2,411
리스트페이지에서 더보기 버튼이 작동을 안합니다 무한 로딩만
~~ 소스에는 이상이 없는거 같은데 ㅜㅜ
고수님의 조언 부탁드립니다!
mobile/shop/list.php
</p>
<p><?php
include_once('./_common.php');</p>
<p>if($g5['is_db_trans'] && file_exists($g5['locale_path'].'/include/ml/mobile/shop'.'/list.ml.php')) { include_once $g5['locale_path'].'/include/ml/mobile/shop'.'/list.ml.php'; return; }</p>
<p>if((defined('G5_USE_NEW_CODE') && G5_USE_NEW_CODE) or (defined('G5_USE_MOBILE_NEW_CODE') && G5_USE_MOBILE_NEW_CODE)) { /// new code</p>
<p>// 상품 리스트에서 다른 필드로 정렬을 하려면 아래의 배열 코드에서 해당 필드를 추가하세요.
if( isset($sort) && ! in_array($sort, array('it_sum_qty', 'it_price', 'it_use_avg', 'it_use_cnt', 'it_update_time')) ){
$sort='';
}</p>
<p>$sql = " select *
from {$g5['g5_shop_category_table']}
where ca_id = '$ca_id'
and ca_use = '1' ";
$ca = sql_fetch($sql);
if (!$ca['ca_id'])
alert(_t('등록된 분류가 없습니다.'), G5_SHOP_URL);</p>
<p>// 테마미리보기 스킨 등의 변수 재설정
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true) {
$ca['ca_mobile_skin'] = (isset($tconfig['ca_mobile_skin']) && $tconfig['ca_mobile_skin']) ? $tconfig['ca_mobile_skin'] : $ca['ca_mobile_skin'];
$ca['ca_mobile_img_width'] = (isset($tconfig['ca_mobile_img_width']) && $tconfig['ca_mobile_img_width']) ? $tconfig['ca_mobile_img_width'] : $ca['ca_mobile_img_width'];
$ca['ca_mobile_img_height'] = (isset($tconfig['ca_mobile_img_height']) && $tconfig['ca_mobile_img_height']) ? $tconfig['ca_mobile_img_height'] : $ca['ca_mobile_img_height'];
$ca['ca_mobile_list_mod'] = (isset($tconfig['ca_mobile_list_mod']) && $tconfig['ca_mobile_list_mod']) ? $tconfig['ca_mobile_list_mod'] : $ca['ca_mobile_list_mod'];
$ca['ca_mobile_list_row'] = (isset($tconfig['ca_mobile_list_row']) && $tconfig['ca_mobile_list_row']) ? $tconfig['ca_mobile_list_row'] : $ca['ca_mobile_list_row'];
}</p>
<p>/// 쇼핑몰 템플릿별 분류 설정 지원. 2019.08.10
if(is_array($config2w_theme_config)) {
$f = array_filter(array_keys($config2w_theme_config), 'ca_match');
$config2w_theme_ca_config = array_intersect_key($config2w_theme_config, array_flip($f));
if(is_array($config2w_theme_ca_config)) $ca = array_merge($ca, array_filter(array_map('trim', $config2w_theme_ca_config)));
}</p>
<p>// 본인인증, 성인인증체크
if(!$is_admin) {
$msg = shop_member_cert_check($ca_id, 'list');
if($msg)
alert($msg, G5_SHOP_URL);
}</p>
<p>$g5['title'] = _t($ca['ca_name']);</p>
<p>include_once(G5_MSHOP_PATH.'/_head.php');</p>
<p>// 스킨경로
$skin_dir = G5_MSHOP_SKIN_PATH;</p>
<p>if($ca['ca_mobile_skin_dir']) {
if(preg_match('#^theme/(.+)$#', $ca['ca_mobile_skin_dir'], $match))
$skin_dir = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/shop/'.$match[1];
else
$skin_dir = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/shop/'.$ca['ca_mobile_skin_dir'];</p>
<p> if(is_dir($skin_dir)) {
$skin_file = $skin_dir.'/'.$ca['ca_mobile_skin'];</p>
<p> if(!is_file($skin_file))
$skin_dir = G5_MSHOP_SKIN_PATH;
} else {
$skin_dir = G5_MSHOP_SKIN_PATH;
}
}</p>
<p>define('G5_SHOP_CSS_URL', str_replace(G5_PATH, G5_URL, $skin_dir));
?></p>
<p><script>
var g5_shop_url = "<?php echo G5_SHOP_URL; ?>";
</script>
<script src="<?php echo G5_JS_URL; ?>/shop.mobile.list.js"></script></p>
<p><div id="sct"></p>
<p> <?php
// 상단 HTML
echo '<div id="sct_hhtml">'.conv_content($ca['ca_mobile_head_html'], 1).'</div>';</p>
<p> $cate_skin = $skin_dir.'/listcategory.skin.php';
if(!is_file($cate_skin))
$cate_skin = G5_MSHOP_SKIN_PATH.'/listcategory.skin.php';
include $cate_skin;</p>
<p> // 테마미리보기 베스트상품 재설정
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true) {
if(isset($theme_config['ca_mobile_list_best_mod']))
$theme_config['ca_mobile_list_best_mod'] = (isset($tconfig['ca_mobile_list_best_mod']) && $tconfig['ca_mobile_list_best_mod']) ? $tconfig['ca_mobile_list_best_mod'] : 0;
if(isset($theme_config['ca_mobile_list_best_row']))
$theme_config['ca_mobile_list_best_row'] = (isset($tconfig['ca_mobile_list_best_row']) && $tconfig['ca_mobile_list_best_row']) ? $tconfig['ca_mobile_list_best_row'] : 0;
}</p>
<p> // 분류 Best Item
$list_mod = (isset($theme_config['ca_mobile_list_best_mod']) && $theme_config['ca_mobile_list_best_mod']) ? (int)$theme_config['ca_mobile_list_best_mod'] : $ca['ca_mobile_list_mod'];
$list_row = (isset($theme_config['ca_mobile_list_best_row']) && $theme_config['ca_mobile_list_best_row']) ? (int)$theme_config['ca_mobile_list_best_row'] : $ca['ca_mobile_list_row'];
$limit = $list_mod * $list_row;
$best_skin = G5_MSHOP_SKIN_PATH.'/list.best.10.skin.php';</p>
<p> $sql = " select *
from {$g5['g5_shop_item_table']}
where ( ca_id like '$ca_id%' or ca_id2 like '$ca_id%' or ca_id3 like '$ca_id%' )
and it_use = '1'
and it_type4 = '1'
order by it_order, it_id desc
limit 0, $limit ";</p>
<p> $list = new item_list($best_skin, $list_mod, $list_row, $ca['ca_mobile_img_width'], $ca['ca_mobile_img_height']);
$list->set_query($sql);
$list->set_mobile(true);
$list->set_view('it_img', true);
$list->set_view('it_id', false);
$list->set_view('it_name', true);
$list->set_view('it_cust_price', true);
$list->set_view('it_price', true);
$list->set_view('sns', false);
echo $list->run();</p>
<p> // 상품 출력순서가 있다면
if ($sort != "")
$order_by = $sort.' '.$sortodr.' , it_order, it_id desc';
else
$order_by = 'it_order, it_id desc';</p>
<p> $error = '<p class="sct_noitem">'._t('등록된 상품이 없습니다.').'</p>';</p>
<p> // 리스트 스킨
$skin_file = is_include_path_check($skin_dir.'/'.$ca['ca_mobile_skin']) ? $skin_dir.'/'.$ca['ca_mobile_skin'] : $skin_dir.'/list.10.skin.php';</p>
<p> if (file_exists($skin_file)) {</p>
<p> echo '<div id="sct_sortlst">';</p>
<p> $sort_skin = $skin_dir.'/list.sort.skin.php';
if(!is_file($sort_skin))
$sort_skin = G5_MSHOP_SKIN_PATH.'/list.sort.skin.php';
include $sort_skin;
// 상품 보기 타입 변경 버튼
//$sub_skin = $skin_dir.'/list.sub.skin.php';
//if(!is_file($sub_skin))
// $sub_skin = G5_MSHOP_SKIN_PATH.'/list.sub.skin.php';</p>
<p> //if(is_file($sub_skin)){
// include $sub_skin;
//}</p>
<p> echo '</div>';</p>
<p> // 총몇개
$items = $ca['ca_mobile_list_mod'] * $ca['ca_mobile_list_row'];
// 페이지가 없으면 첫 페이지 (1 페이지)
if ($page < 1) $page = 1;
// 시작 레코드 구함
$from_record = ($page - 1) * $items;</p>
<p> $list = new item_list($skin_file, $ca['ca_mobile_list_mod'], $ca['ca_mobile_list_row'], $ca['ca_mobile_img_width'], $ca['ca_mobile_img_height']);
$list->set_category($ca['ca_id'], 1);
$list->set_category($ca['ca_id'], 2);
$list->set_category($ca['ca_id'], 3);
$list->set_is_page(true);
$list->set_mobile(true);
$list->set_order_by($order_by);
$list->set_from_record($from_record);
$list->set_view('it_img', true);
$list->set_view('it_id', false);
$list->set_view('it_name', true);
$list->set_view('it_cust_price', true);
$list->set_view('it_price', true);
$list->set_view('sns', false);
echo $list->run();</p>
<p> // where 된 전체 상품수
$total_count = $list->total_count;
}
else
{
echo '<div class="sct_nofile">'.str_replace(G5_PATH.'/', '', $skin_file).' '._t('파일을 찾을 수 없습니다.').'
'._t('관리자에게 알려주시면 감사하겠습니다.').'</div>';
}
?></p>
<p> <?php
if($i > 0 && $total_count > $items) {
$qstr1 .= 'ca_id='.$ca_id;
$qstr1 .='&sort='.$sort.'&sortodr='.$sortodr;
$ajax_url = G5_SHOP_URL.'/ajax.list.php?'.$qstr1.'&use_sns=1';
?>
<div class="li_more">
<p id="item_load_msg"><img src="<?php echo G5_SHOP_CSS_URL; ?>/img/loading.gif" alt="<?php echo _t('로딩이미지'); ?>" >
<?php echo _t('잠시만 기다려주세요.'); ?></p>
<div class="li_more_btn">
<button type="button" id="btn_more_item" data-url="<?php echo $ajax_url; ?>" data-page="<?php echo $page; ?>"><?php echo _t('더보기'); ?> +</button>
</div>
</div>
</p>
<p> <?php } ?></p>
<p> <?php
// 하단 HTML
echo '<div id="sct_thtml">'.conv_content($ca['ca_mobile_tail_html'], 1).'</div>';
?>
</div></p>
<p><?php
} else { /// if new code</p>
<p>$sql = " select *
from {$g5['g5_shop_category_table']}
where ca_id = '$ca_id'
and ca_use = '1' ";
$ca = sql_fetch($sql);
if (!$ca['ca_id'])
alert(_t('등록된 분류가 없습니다.'), G5_SHOP_URL);</p>
<p>// 테마미리보기 스킨 등의 변수 재설정
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true) {
$ca['ca_mobile_skin'] = (isset($tconfig['ca_mobile_skin']) && $tconfig['ca_mobile_skin']) ? $tconfig['ca_mobile_skin'] : $ca['ca_mobile_skin'];
$ca['ca_mobile_img_width'] = (isset($tconfig['ca_mobile_img_width']) && $tconfig['ca_mobile_img_width']) ? $tconfig['ca_mobile_img_width'] : $ca['ca_mobile_img_width'];
$ca['ca_mobile_img_height'] = (isset($tconfig['ca_mobile_img_height']) && $tconfig['ca_mobile_img_height']) ? $tconfig['ca_mobile_img_height'] : $ca['ca_mobile_img_height'];
$ca['ca_mobile_list_mod'] = (isset($tconfig['ca_mobile_list_mod']) && $tconfig['ca_mobile_list_mod']) ? $tconfig['ca_mobile_list_mod'] : $ca['ca_mobile_list_mod'];
$ca['ca_mobile_list_row'] = (isset($tconfig['ca_mobile_list_row']) && $tconfig['ca_mobile_list_row']) ? $tconfig['ca_mobile_list_row'] : $ca['ca_mobile_list_row'];
}</p>
<p>/// 쇼핑몰 템플릿별 분류 설정 지원. 2019.08.10
if(is_array($config2w_theme_config)) {
$f = array_filter(array_keys($config2w_theme_config), 'ca_match');
$config2w_theme_ca_config = array_intersect_key($config2w_theme_config, array_flip($f));
if(is_array($config2w_theme_ca_config)) $ca = array_merge($ca, array_filter(array_map('trim', $config2w_theme_ca_config)));
}</p>
<p>// 본인인증, 성인인증체크
if(!$is_admin) {
$msg = shop_member_cert_check($ca_id, 'list');
if($msg)
alert($msg, G5_SHOP_URL);
}</p>
<p>$g5['title'] = _t($ca['ca_name']);</p>
<p>include_once(G5_MSHOP_PATH.'/_head.php');</p>
<p>// 스킨경로
$skin_dir = G5_MSHOP_SKIN_PATH;</p>
<p>if($ca['ca_mobile_skin_dir']) {
if(preg_match('#^theme/(.+)$#', $ca['ca_mobile_skin_dir'], $match))
$skin_dir = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/shop/'.$match[1];
else
$skin_dir = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/shop/'.$ca['ca_mobile_skin_dir'];</p>
<p> if(is_dir($skin_dir)) {
$skin_file = $skin_dir.'/'.$ca['ca_mobile_skin'];</p>
<p> if(!is_file($skin_file))
$skin_dir = G5_MSHOP_SKIN_PATH;
} else {
$skin_dir = G5_MSHOP_SKIN_PATH;
}
}</p>
<p>define('G5_SHOP_CSS_URL', str_replace(G5_PATH, G5_URL, $skin_dir));
?></p>
<p><script>
var g5_shop_url = "<?php echo G5_SHOP_URL; ?>";
</script>
<script src="<?php echo G5_JS_URL; ?>/shop.mobile.list.js"></script></p>
<p><div id="sct"></p>
<p> <?php
// 상단 HTML
echo '<div id="sct_hhtml">'.conv_content($ca['ca_mobile_head_html'], 1).'</div>';</p>
<p> $cate_skin = $skin_dir.'/listcategory.skin.php';
if(!is_file($cate_skin))
$cate_skin = G5_MSHOP_SKIN_PATH.'/listcategory.skin.php';
include $cate_skin;</p>
<p> // 테마미리보기 베스트상품 재설정
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true) {
if(isset($theme_config['ca_mobile_list_best_mod']))
$theme_config['ca_mobile_list_best_mod'] = (isset($tconfig['ca_mobile_list_best_mod']) && $tconfig['ca_mobile_list_best_mod']) ? $tconfig['ca_mobile_list_best_mod'] : 0;
if(isset($theme_config['ca_mobile_list_best_row']))
$theme_config['ca_mobile_list_best_row'] = (isset($tconfig['ca_mobile_list_best_row']) && $tconfig['ca_mobile_list_best_row']) ? $tconfig['ca_mobile_list_best_row'] : 0;
}</p>
<p> // 분류 Best Item
$list_mod = (isset($theme_config['ca_mobile_list_best_mod']) && $theme_config['ca_mobile_list_best_mod']) ? (int)$theme_config['ca_mobile_list_best_mod'] : $ca['ca_mobile_list_mod'];
$list_row = (isset($theme_config['ca_mobile_list_best_row']) && $theme_config['ca_mobile_list_best_row']) ? (int)$theme_config['ca_mobile_list_best_row'] : $ca['ca_mobile_list_row'];
$limit = $list_mod * $list_row;
$best_skin = G5_MSHOP_SKIN_PATH.'/list.best.10.skin.php';</p>
<p> $sql = " select *
from {$g5['g5_shop_item_table']}
where ( ca_id like '$ca_id%' or ca_id2 like '$ca_id%' or ca_id3 like '$ca_id%' )
and it_use = '1'
and it_type4 = '1'
order by it_order, it_id desc
limit 0, $limit ";</p>
<p> $list = new item_list($best_skin, $list_mod, $list_row, $ca['ca_mobile_img_width'], $ca['ca_mobile_img_height']);
$list->set_query($sql);
$list->set_mobile(true);
$list->set_view('it_img', true);
$list->set_view('it_id', false);
$list->set_view('it_name', true);
$list->set_view('it_price', true);
echo $list->run();</p>
<p> // 상품 출력순서가 있다면
if ($sort != "")
$order_by = $sort.' '.$sortodr.' , it_order, it_id desc';
else
$order_by = 'it_order, it_id desc';</p>
<p> $error = '<p class="sct_noitem">'._t('등록된 상품이 없습니다.').'</p>';</p>
<p> // 리스트 스킨
$skin_file = is_include_path_check($skin_dir.'/'.$ca['ca_mobile_skin']) ? $skin_dir.'/'.$ca['ca_mobile_skin'] : $skin_dir.'/list.10.skin.php';</p>
<p> if (file_exists($skin_file)) {
$sort_skin = $skin_dir.'/list.sort.skin.php';
if(!is_file($sort_skin))
$sort_skin = G5_MSHOP_SKIN_PATH.'/list.sort.skin.php';
include $sort_skin;</p>
<p> // 총몇개
$items = $ca['ca_mobile_list_mod'] * $ca['ca_mobile_list_row'];
// 페이지가 없으면 첫 페이지 (1 페이지)
if ($page < 1) $page = 1;
// 시작 레코드 구함
$from_record = ($page - 1) * $items;</p>
<p> $list = new item_list($skin_file, $ca['ca_mobile_list_mod'], $ca['ca_mobile_list_row'], $ca['ca_mobile_img_width'], $ca['ca_mobile_img_height']);
$list->set_category($ca['ca_id'], 1);
$list->set_category($ca['ca_id'], 2);
$list->set_category($ca['ca_id'], 3);
$list->set_is_page(true);
$list->set_mobile(true);
$list->set_order_by($order_by);
$list->set_from_record($from_record);
$list->set_view('it_img', true);
$list->set_view('it_id', false);
$list->set_view('it_name', true);
$list->set_view('it_price', true);
echo $list->run();</p>
<p> // where 된 전체 상품수
$total_count = $list->total_count;
}
else
{
echo '<div class="sct_nofile">'.str_replace(G5_PATH.'/', '', $skin_file).' '._t('파일을 찾을 수 없습니다.').'
'._t('관리자에게 알려주시면 감사하겠습니다.').'</div>';
}
?></p>
<p> <?php
if($i > 0 && $total_count > $items) {
$qstr1 .= 'ca_id='.$ca_id;
$qstr1 .='&sort='.$sort.'&sortodr='.$sortodr;
$ajax_url = G5_SHOP_URL.'/ajax.list.php?'.$qstr1;
?>
<div class="li_more">
<p id="item_load_msg"><img src="<?php echo G5_SHOP_CSS_URL; ?>/img/loading.gif" alt="<?php echo _t('로딩이미지'); ?>" >
<?php echo _t('잠시만 기다려주세요.'); ?></p>
<div class="li_more_btn">
<button type="button" id="btn_more_item" data-url="<?php echo $ajax_url; ?>" data-page="<?php echo $page; ?>">MORE ITEM +</button>
</div>
</div>
<?php } ?></p>
<p> <?php
// 하단 HTML
echo '<div id="sct_thtml">'.conv_content($ca['ca_mobile_tail_html'], 1).'</div>';
?>
</div></p>
<p><?php
} /// if new code
?>
<?php
include_once(G5_MSHOP_PATH.'/_tail.php');</p>
<p>echo "\n<!-- {$ca['ca_mobile_skin']} -->\n";
?>
/js/shop.mobile.list.js 파일
</p>
<p>$(function() {
$("#btn_more_item").on("click", function() {
var $this = $(this);
var url = $this.data("url");
var page = $this.data("page");
var $msg = $("#item_load_msg");</p>
<p> if($msg.is(":visible"))
return false;</p>
<p> if($this.hasClass("no_more_item")) {
///alert("등록된 상품이 더 이상없습니다.");
alert(g5_msg_no_more_item);
return false;
}</p>
<p> $msg.css("display", "block");</p>
<p> $.ajax({
type: "POST",
data: { page: page },
url: url,
cache: false,
async: true,
dataType: "json",
success: function(data) {
if(data.error != "") {
alert(data.error);
return false;
}</p>
<p> var $items = $(data.item).find("li");
var cnt = $items.size();</p>
<p> if(cnt < 1) {
///alert("등록된 상품이 더 이상없습니다.");
alert(g5_msg_no_more_item);
$msg.css("display", "none");
$this.addClass("no_more_item");
return false;
}</p>
<p> $("#sct_wrap").append($items);
$this.data("page", data.page);
$msg.css("display", "none");
}
});
});
});
</p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인