You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.5 KiB
91 lines
2.5 KiB
<?php
|
|
/**
|
|
* 產品各層分頁列表
|
|
*/
|
|
require_once('../../conf/ProductEnum.php');
|
|
require_once('../../conf/ParametersException.php');
|
|
require_once('../../db/ProductDAO.php');
|
|
require_once('../../class/Functions.php');
|
|
|
|
try{
|
|
$result = array();
|
|
$dbDao = new ProductDAO();
|
|
$functions = new Functions();
|
|
$dbDao->transaction();
|
|
$level = 3;
|
|
$dataId = NULL;
|
|
$dataTitle = '';
|
|
$page = 1;
|
|
$dataTotalNum = 0;
|
|
$limit = ENUM::PageListNum;
|
|
$listHtml = '';
|
|
$returnArr = array();
|
|
|
|
if ( isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] != 0 ){
|
|
$dataId = trim($_GET['id']);
|
|
}
|
|
if ( is_null($dataId) ){
|
|
throw new ParametersException('無 ID 參數');
|
|
}
|
|
if ( isset($_GET['page']) && is_numeric($_GET['page']) ){
|
|
$page = trim($_GET['page']);
|
|
}
|
|
|
|
$idData = $dbDao->getProdContent($dataId);
|
|
if ( !is_array($idData) || count($idData) != 1 ){
|
|
throw new ParametersException('無此產品資料');
|
|
}
|
|
$dataTitle = $idData[0]['title'];
|
|
$dataTitle = str_replace('標配', '', $dataTitle);
|
|
$dataTitle = str_replace('選配', '', $dataTitle);
|
|
$levelData = $dbDao->getLevelDataById($level, $dataId, $page, $limit);
|
|
$levelDataTotal = $dbDao->getLevelDataByIdTotalNum($level, $dataId);
|
|
if ( is_numeric($levelDataTotal) ){
|
|
$dataTotalNum = $levelDataTotal;
|
|
}
|
|
|
|
foreach( $levelData as $ldv ){
|
|
$listHtml.= '
|
|
<div class="col-lg-4 col-md-6 products-item">
|
|
<div class="card-wrap">
|
|
<div class="card-container">
|
|
<a href="products/p-1.html?id='.$ldv['uuid'].'">
|
|
<div class="products-item-title">
|
|
<h3>'.$ldv['sub_title'].'</h3>
|
|
<h6>'.$ldv['title'].'</h6>
|
|
<h5>'.$dataTitle.'</h5>
|
|
</div>
|
|
<img src="img/products/'. $ldv['image_url'].'" alt="'. $ldv['image_alt'].'" class="img-fluid">
|
|
<!-- <img src="images/products/list/p-1.png" alt="'. $ldv['image_alt'].'" class="img-fluid"> -->
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
';
|
|
}
|
|
|
|
$returnArr['title'] = $idData[0]['title'];
|
|
$returnArr['total'] = $dataTotalNum;
|
|
$returnArr['pageSize'] = $limit;
|
|
$returnArr['content'] = str_replace(array("\r\n", "\r", "\n", "\t"), '', $listHtml);
|
|
$dbDao->commitDB();
|
|
http_response_code(200);
|
|
|
|
} catch ( ParametersException $pe ){
|
|
$returnArr['errMsg'] = $pe->getMessage();
|
|
http_response_code(400);
|
|
|
|
} catch ( Exception $e ){
|
|
$returnArr['errMsg'] = $e->getMessage();
|
|
if($dbDao != null) {
|
|
$dbDao->rollbackDB();
|
|
}
|
|
http_response_code(500);
|
|
} finally {
|
|
echo json_encode($returnArr, JSON_UNESCAPED_UNICODE);
|
|
if($dbDao != null) {
|
|
$dbDao->closeDB();
|
|
}
|
|
}
|
|
|
|
?>
|