| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?php
- require_once 'CommonQuery.php';
- // 轮播图数据 - 修改为单张图片
- $carouselItems = [
- [
- "image" => "/uploads/20251013/6af88ead615998ad6c789327b26f7bbe.jpg",
- "alt" => "政策法规"
- ]
- ];
- // 获取URL参数 - 当前页码、选中的分类和搜索关键词
- $currentPage = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 ? intval($_GET['page']) : 1;
- $selectedCategory = isset($_GET['category']) ? $_GET['category'] : '国家法律法规';
- $searchKeyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
- // 每页显示的文章数量
- $pageSize = 12;
- // 使用loadListByChannelNameAndPage函数获取政策法规数据,并传入搜索关键词
- $articleResult = loadListByChannelNameAndPage($pageSize, $selectedCategory, $currentPage, $searchKeyword);
- $policyItems = $articleResult['list'];
- $totalPages = $articleResult['totalPages'];
- ?>
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>厦门市文化遗产保护中心 - 政策法规</title>
- <link rel="stylesheet" href="/css/fonts.css">
- <link rel="stylesheet" href="/css/fontawesome.min.css">
- <link rel="stylesheet" href="/css/bootstrap.min.css">
- <link rel="stylesheet" href="/css/swiper-bundle.min.css">
- <link rel="stylesheet" href="/css/style.css">
- <script src="/js/jquery-3.7.1.js"></script>
- <script src="/js/bootstrap.bundle.js"></script>
- <script src="/js/swiper-bundle.min.js"></script>
- </head>
- <body>
- <?php include __DIR__ . '/components/navbar.php'; ?>
- <!-- 轮播图 -->
- <div class="swiper mySwiper" style="width: 100%; height: 400px;">
- <div class="swiper-wrapper">
- <?php foreach ($carouselItems as $item): ?>
- <div class="swiper-slide">
- <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
- </div>
- <?php endforeach; ?>
- </div>
- <div class="swiper-pagination"></div>
- <div class="swiper-button-prev"></div>
- <div class="swiper-button-next"></div>
- </div>
- <!-- 主要内容 -->
- <div class="main-content">
- <div class="container">
- <div class="row">
- <!-- 右侧内容 -->
- <div class="col-12">
- <div class="content">
- <div class="section-title center large">
- <h2 class="icon">政策法规</h2>
- </div>
-
- <!-- 搜索区域 -->
- <div class="d-flex justify-content-center align-items-center gap-3 mb-4">
- <button
- class="bordered <?php echo $selectedCategory === '国家法律法规' ? 'active' : ''; ?>"
- onclick="location.href='?category=国家法律法规&page=1<?php echo !empty($searchKeyword) ? '&keyword=' . urlencode($searchKeyword) : ''; ?>'"
- >
- 国家法律法规
- </button>
- <button
- class="bordered <?php echo $selectedCategory === '地方政策文件' ? 'active' : ''; ?>"
- onclick="location.href='?category=地方政策文件&page=1<?php echo !empty($searchKeyword) ? '&keyword=' . urlencode($searchKeyword) : ''; ?>'"
- >
- 地方政策文件
- </button>
- <div class="bordered-input">
- <input
- type="text"
- id="search-input"
- placeholder="输入关键字搜索政策法规"
- value="<?php echo htmlspecialchars($searchKeyword); ?>"
- >
- </div>
- <button
- class="bordered active"
- onclick="performSearch()"
- >
- 搜索
- </button>
- </div>
-
- <!-- 文章列表 -->
- <div class="news-list">
- <?php if (!empty($policyItems)): ?>
- <?php foreach ($policyItems as $item): ?>
- <div class="news-item dark">
- <a
- href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : ''; ?>"
- class="title"
- >
- <?php echo isset($item['title']) ? $item['title'] : ''; ?>
- </a>
- <span class="date">
- <?php echo isset($item['createtime']) ? date('Y-m-d', strtotime($item['createtime'])) : ''; ?>
- </span>
- </div>
- <?php endforeach; ?>
- <?php else: ?>
- <div class="no-news text-center">
- <?php echo !empty($searchKeyword) ? '没有找到与"' . htmlspecialchars($searchKeyword) . '"相关的数据' : '暂无相关数据'; ?>
- </div>
- <?php endif; ?>
- </div>
-
- <!-- 分页 -->
- <?php if ($totalPages > 1): ?>
- <nav aria-label="List Page navigation">
- <ul class="pagination mt-4">
- <!-- 上一页 -->
- <li class="page-item <?php echo $currentPage <= 1 ? 'disabled' : ''; ?>">
- <a
- class="page-link"
- href="?category=<?php echo urlencode($selectedCategory); ?>&page=<?php echo $currentPage - 1; ?><?php echo !empty($searchKeyword) ? '&keyword=' . urlencode($searchKeyword) : ''; ?>"
- aria-label="Previous"
- >
- <span aria-hidden="true">«</span>
- </a>
- </li>
-
- <!-- 页码 -->
- <?php for ($i = 1; $i <= $totalPages; $i++): ?>
- <li class="page-item <?php echo $i == $currentPage ? 'active' : ''; ?>">
- <a
- class="page-link"
- href="?category=<?php echo urlencode($selectedCategory); ?>&page=<?php echo $i; ?><?php echo !empty($searchKeyword) ? '&keyword=' . urlencode($searchKeyword) : ''; ?>"
- >
- <?php echo $i; ?>
- </a>
- </li>
- <?php endfor; ?>
-
- <!-- 下一页 -->
- <li class="page-item <?php echo $currentPage >= $totalPages ? 'disabled' : ''; ?>">
- <a
- class="page-link"
- href="?category=<?php echo urlencode($selectedCategory); ?>&page=<?php echo $currentPage + 1; ?><?php echo !empty($searchKeyword) ? '&keyword=' . urlencode($searchKeyword) : ''; ?>"
- aria-label="Next"
- >
- <span aria-hidden="true">»</span>
- </a>
- </li>
- </ul>
- </nav>
- <?php endif; ?>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php include __DIR__ . '/components/footer.php'; ?>
- <script>
- $(document).ready(function() {
- // 初始化 Swiper
- const swiper = new Swiper(".mySwiper", {
- slidesPerView: 1,
- spaceBetween: 30,
- loop: true,
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- navigation: {
- nextEl: ".swiper-button-next",
- prevEl: ".swiper-button-prev",
- },
- autoplay: {
- delay: 5000,
- disableOnInteraction: false,
- },
- });
-
- // 为搜索输入框添加回车事件
- $('#search-input').on('keypress', function(e) {
- if (e.key === 'Enter') {
- performSearch();
- }
- });
- });
-
- // 执行搜索函数
- function performSearch() {
- const keyword = $('#search-input').val().trim();
- const currentCategory = '<?php echo $selectedCategory; ?>';
- location.href = '?category=' + encodeURIComponent(currentCategory) + '&page=1&keyword=' + encodeURIComponent(keyword);
- }
- </script>
- </body>
- </html>
|