* Date: 2026-6-2 */ if (!defined('ROOT_PATH')) exit; $product = $id>0 ? $db->fetch("SELECT * FROM {$db->table('product')} WHERE id=".intval($id)." AND status=1") : null; if (!$product) { echo '产品不存在'; return; } $currentChannel = null; if (!empty($product['channel_id'])) { $currentChannel = $db->fetch("SELECT * FROM {$db->table('channel')} WHERE id=".intval($product['channel_id'])); } if (!$currentChannel) { $currentChannel = array('id' => 0, 'parent_id' => 0, 'channel_name' => '产品中心', 'channel_thumb' => ''); } $topId = intval($currentChannel['parent_id'])>0 ? intval($currentChannel['parent_id']) : intval($currentChannel['id']); $topChannel = intval($currentChannel['parent_id'])>0 ? $db->fetch("SELECT * FROM {$db->table('channel')} WHERE id=".$topId) : $currentChannel; if (!$topChannel) { $topChannel = $currentChannel; } $subChannels = !empty($topId) ? $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id=".$topId." AND is_show=1 ORDER BY list_order ASC,id ASC") : array(); $prev = $db->fetch("SELECT id,title FROM {$db->table('product')} WHERE channel_id=".intval($product['channel_id'])." AND id<".intval($product['id'])." AND status=1 ORDER BY id DESC LIMIT 1"); $next = $db->fetch("SELECT id,title FROM {$db->table('product')} WHERE channel_id=".intval($product['channel_id'])." AND id>".intval($product['id'])." AND status=1 ORDER BY id ASC LIMIT 1"); $bannerPic = !empty($slides[0]['slide_pic']) ? $slides[0]['slide_pic'] : (!empty($currentChannel['channel_thumb']) ? $currentChannel['channel_thumb'] : 'https://picsum.photos/1600/500?random='.intval($currentChannel['id'])); $mobileBannerPic = !empty($slides[0]['slide_pic']) ? $slides[0]['slide_pic'] : (!empty($currentChannel['channel_thumb']) ? $currentChannel['channel_thumb'] : 'https://picsum.photos/1200/400?random='.intval($currentChannel['id'])); ?>