<?php
/**
 * 芋头CMS
 * ============================================================================
 * 版权所有 2016-2028 沅陵县乌托邦网络服务有限公司，并保留所有权利。
 * 网站地址: http://www.yutoucms.cn
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷。
 * ============================================================================
 * Author: 芋头 <mxgsf@qq.com>
 * Date: 2026-6-1
 */
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($site['site_name'] ?? '企业网站'); ?></title>
<meta name="keywords" content="<?php echo htmlspecialchars($site['site_keywords'] ?? ''); ?>">
<meta name="description" content="<?php echo htmlspecialchars($site['site_description'] ?? ''); ?>">
<link rel="stylesheet" href="<?php echo $site['template_dir']; ?>css/style.css">
</head>
<body>

<!-- Top Bar -->
<div class="topbar">
<div class="container">
<div class="topbar-inner">
<div class="topbar-left">
<span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>
您好！欢迎访问 <?php echo htmlspecialchars($site['site_name'] ?? ''); ?> 官网！
</span>
</div>
<div class="topbar-right">
<a href="<?php echo getUrl('channel', 3); ?>">关于我们</a>
<span>|</span>
<a href="<?php echo getUrl('guestbook'); ?>">联系我们</a>
</div>
</div>
</div>
</div>

<!-- Header -->
<header class="header">
<div class="container">
<div class="header-inner">
<a href="/" class="logo">
<?php if(!empty($site['site_logo'])): ?>
<img src="<?php echo htmlspecialchars($site['site_logo']); ?>" alt="<?php echo htmlspecialchars($site['site_name'] ?? ''); ?>" style="height:40px;">
<?php else: ?>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="3" width="20" height="14" rx="2"/>
<line x1="8" y1="21" x2="16" y2="21"/>
<line x1="12" y1="17" x2="12" y2="21"/>
</svg>
<span><?php echo htmlspecialchars($site['site_name'] ?? '企业网站'); ?></span>
<?php endif; ?>
</a>
<nav class="nav">
<?php
foreach($channels as $ch):
    $children = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [$ch['id']]);
?>
<div class="nav-item">
<a href="<?php echo getUrl('channel', $ch['id']); ?>">
<?php echo htmlspecialchars($ch['channel_name']); ?>
<?php if(!empty($children)): ?>
<svg class="arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
<?php endif; ?>
</a>
<?php if(!empty($children)): ?>
<div class="nav-dropdown">
<?php foreach($children as $child): ?>
<a href="<?php echo getUrl('channel', $child['id']); ?>"><?php echo htmlspecialchars($child['channel_name']); ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<div class="nav-item">
<a href="<?php echo getUrl('guestbook'); ?>">联系我们</a>
</div>
</nav>
<div class="header-right">
<div class="header-phone">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/></svg>
<span><?php echo htmlspecialchars($site['site_phone'] ?? '400-888-8888'); ?></span>
</div>
</div>
</div>
</div>
</header>

<!-- Banner -->
<section class="banner">
<div class="banner-slider" id="bannerSlider">
<?php if(!empty($slides)): foreach($slides as $i => $slide): ?>
<div class="banner-slide" style="background-image: url('<?php echo htmlspecialchars($slide['litpic']); ?>')">
<div class="banner-content">
<h2><?php echo htmlspecialchars($slide['title']); ?></h2>
<p><?php echo htmlspecialchars($slide['link'] ?? ''); ?></p>
<?php if(!empty($slide['link'])): ?>
<a href="<?php echo htmlspecialchars($slide['link']); ?>" class="banner-btn">了解更多</a>
<?php endif; ?>
</div>
</div>
<?php endforeach; else: ?>
<div class="banner-slide" style="background-image: url('<?php echo $site['template_dir']; ?>images/banner.jpg')">
<div class="banner-content">
<h2>专业的POS机服务商</h2>
<p>安全、便捷、高效的支付解决方案</p>
<a href="#" class="banner-btn">了解更多</a>
</div>
</div>
<?php endif; ?>
</div>
<?php if(count($slides) > 1): ?>
<div class="banner-dots" id="bannerDots">
<?php foreach($slides as $i => $slide): ?>
<span class="banner-dot <?php echo $i === 0 ? 'active' : ''; ?>" data-index="<?php echo $i; ?>"></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>

<!-- Products Section -->
<section class="products">
<div class="container">
<div class="section-header">
<p class="en">PRODUCTS</p>
<h2>产品中心</h2>
<p>为您提供优质的POS机产品和服务</p>
</div>
<div class="product-grid">
<?php if(!empty($latestProducts)): foreach($latestProducts as $p): ?>
<?php $img = $p['litpic'] ?: $site['template_dir'].'images/nopic.jpg'; ?>
<div class="product-card">
<a href="<?php echo getUrl('product', $p['id']); ?>" class="product-img">
<img src="<?php echo htmlspecialchars($img); ?>" alt="<?php echo htmlspecialchars($p['title']); ?>">
</a>
<div class="product-info">
<p class="p-title" style="display:block!important;font-size:16px!important;font-weight:700!important;color:#222!important;margin-bottom:10px!important;line-height:1.5!important;"><a href="<?php echo getUrl('product', $p['id']); ?>" style="color:#222!important;"><?php echo htmlspecialchars($p['title']); ?></a></p>
<?php if(!empty($p['price']) && $p['price'] > 0): ?>
<p class="price">¥<?php echo htmlspecialchars($p['price']); ?></p>
<?php endif; ?>
</div>
</div>
<?php endforeach; else: ?>
<?php for($i=0;$i<4;$i++): ?>
<div class="product-card">
<a href="#" class="product-img"><img src="<?php echo $site['template_dir']; ?>images/nopic.jpg" alt="产品"></a>
<div class="product-info"><h3>POS机产品</h3><span class="en">POS machine</span><a href="#">查看详情 &gt;</a></div>
</div>
<?php endfor; endif; ?>
</div>
</div>
<div class="container">
<div class="section-more">
<a href="<?php echo getUrl('channel', 1); ?>">MORE &gt;</a>
</div>
</div>
</section>

<!-- Cases Section -->
<section class="cases">
<div class="container">
<div class="section-header">
<p class="en">CASE</p>
<h2>案例展示</h2>
<p>成功案例展示，品质见证</p>
</div>
<div class="case-grid">
<?php
$caseProducts = $db->fetchAll("SELECT * FROM {$db->table('image')} WHERE status = 1 ORDER BY create_time DESC LIMIT 4");
?>
<?php if(!empty($caseProducts)): foreach($caseProducts as $p): ?>
<?php $img = $p['litpic'] ?: $site['template_dir'].'images/nopic.jpg'; ?>
<div class="case-card">
<a href="<?php echo getUrl('image', $p['id']); ?>" class="case-img">
<img src="<?php echo htmlspecialchars($img); ?>" alt="<?php echo htmlspecialchars($p['title']); ?>">
</a>
<div class="case-info" style="padding:15px;">
<h3 style="font-size:16px!important;font-weight:700!important;color:#222!important;line-height:1.5!important;margin:0!important;"><a href="<?php echo getUrl('image', $p['id']); ?>" style="color:#222!important;"><?php echo htmlspecialchars($p['title']); ?></a></h3>
</div>
</div>
<?php endforeach; else: ?>
<?php for($i=0;$i<4;$i++): ?>
<div class="case-card">
<div class="case-img"><img src="<?php echo $site['template_dir']; ?>images/nopic.jpg" alt="案例"></div>
<div class="case-info"><h3>案例展示</h3></div>
</div>
<?php endfor; endif; ?>
</div>
</div>
<div class="container">
<div class="section-more">
<a href="<?php echo getUrl('channel', 2); ?>">MORE &gt;</a>
</div>
</div>
</section>

<!-- About Section -->
<section class="about">
<div class="container">
<div class="section-header">
<p class="en">ABOUT US</p>
<h2>关于我们</h2>
<p>专业团队，优质服务</p>
</div>
<div class="about-content">
<div class="about-text">
<?php
$aboutArticle = $db->fetch("SELECT * FROM {$db->table('page')} WHERE channel_id = 3 AND status = 1 ORDER BY id DESC LIMIT 1");
$aboutContent = $aboutArticle ? $aboutArticle['content'] : '';
?>
<p><?php echo htmlspecialchars(mb_substr(strip_tags($aboutContent), 0, 500)); ?></p>
<div class="about-features">
<div class="about-feature">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>
<span>安全合规</span>
</div>
<div class="about-feature">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>
<span>稳定高效</span>
</div>
<div class="about-feature">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>
<span>售后无忧</span>
</div>
<div class="about-feature">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>
<span>技术领先</span>
</div>
</div>
</div>
<div class="about-img">
<img src="<?php echo $site['template_dir']; ?>images/about.jpg" alt="关于我们">
</div>
</div>
</div>
</section>

<!-- News Section -->
<section class="news">
<div class="container">
<div class="section-header">
<p class="en">NEWS</p>
<h2>新闻资讯</h2>
<p>最新资讯，了解行业动态</p>
</div>
<div class="news-list">
<?php if(!empty($latestArticles)): foreach($latestArticles as $a): ?>
<div class="news-list-item">
<a href="<?php echo getUrl('article', $a['id']); ?>" class="news-list-img">
<img src="<?php echo htmlspecialchars($a['litpic'] ?: $site['template_dir'].'images/nopic.jpg'); ?>" alt="<?php echo htmlspecialchars($a['title']); ?>">
</a>
<div class="news-list-body">
<div class="news-list-date"><?php echo date('Y-m-d', strtotime($a['create_time'])); ?></div>
<h3><a href="<?php echo getUrl('article', $a['id']); ?>"><?php echo htmlspecialchars($a['title']); ?></a></h3>
<p><?php echo htmlspecialchars(mb_substr(strip_tags($a['content'] ?? ''), 0, 120)); ?></p>
<a href="<?php echo getUrl('article', $a['id']); ?>" class="news-list-more">阅读更多 &gt;</a>
</div>
</div>
<?php endforeach; else: ?>
<?php for($i=0;$i<4;$i++): ?>
<div class="news-list-item">
<div class="news-list-img"><img src="<?php echo $site['template_dir']; ?>images/nopic.jpg" alt="新闻"></div>
<div class="news-list-body">
<div class="news-list-date">2026-06-01</div>
<h3><a href="#">新闻标题</a></h3>
<p>新闻内容摘要...</p>
<a href="#" class="news-list-more">阅读更多 &gt;</a>
</div>
</div>
<?php endfor; endif; ?>
</div>
</div>
<div class="container">
<div class="section-more">
<a href="<?php echo getUrl('channel', 4); ?>">MORE &gt;</a>
</div>
</div>
</section>

<!-- Footer -->
<?php include __DIR__ . '/_footer.php'; ?>

<script>
(function(){
var slides = document.querySelectorAll('.banner-slide');
var dots = document.querySelectorAll('.banner-dot');
if(slides.length <= 1) return;
var current = 0;
function goTo(idx){
slides.forEach(function(s,i){s.style.display=i===idx?'flex':'none';});
dots.forEach(function(d,i){d.classList.toggle('active',i===idx);});
current = idx;
}
dots.forEach(function(dot,i){dot.onclick = function(){goTo(i);};});
setInterval(function(){goTo((current+1)%slides.length);},4000);
})();
</script>
</body>
</html>