//当前位置 $location = sprintf("当前位置 > 产品列表 > <span>%s</span>", $curSort); $page_title = $curSort; $navIndex = 1; ?> <?php //product list paging $query = new Product(9); $query->curPage = $curPage; $query->isPaging = true; //为0查询所有 if ($sortId !== 0) { $query->productType = $sortId; } $rcount = Product::rcount($query); //产品总数 $psize = $query->querySize; //分页大小 $pcount = floor($rcount / $psize) + ($rcount % $psize > 0 ? 1 : 0); //分页总数 $prev = $curPage <= 1 ? 1 : $curPage - 1; //上一页数 $next = $curPage >= $pcount ? $pcount : $curPage + 1; //下一页数 ?> <?php //product list $products = Product::query($query); $productHtml = Util::generateProcuctHtml($products);
$query->querySize = $querySize; $query->curPage = $curPage; try { $data = null; $listJson = ""; if ($dataType == "list") { $data = Product::query($query); if (!empty($data)) { $listJson = json_encode($data, JSON_UNESCAPED_UNICODE); } else { $listJson = "[]"; } Tool::logger(__METHOD__, __LINE__, sprintf("查询产品Json: %s", $listJson), _LOG_ERROR); } else { if ($dataType == "count") { $listJson = Product::rcount($query); Tool::logger(__METHOD__, __LINE__, sprintf("查询产品总数: %s", $listJson), _LOG_ERROR); } } echo "{\"status\":\"true\", \"data\": " . $listJson . "}"; } catch (Exception $e) { echo "{\"status\":\"false\", \"data\": \"" . $e->getMessage() . "\"}"; Tool::logger(__METHOD__, __LINE__, sprintf("查询产品: %s", $e->getMessage()), _LOG_ERROR); } } else { if ($dataType == "detail") { try { $listJson = ""; if (isset($_REQUEST["productId"])) { $productId = $_REQUEST["productId"]; $query = new Product(_NONE);