Browse Source

fix:协议

super-yimizi 1 month ago
parent
commit
600998d93d

+ 49 - 0
application/index/controller/Agreement.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace app\index\controller;
+
+use app\common\controller\Frontend;
+use app\common\model\Page as PageModel;
+use app\common\library\Service;
+
+class Agreement extends Frontend
+{
+
+    protected $noNeedLogin = '*';
+    protected $noNeedRight = '*';
+    protected $layout = '';
+
+     // 查询协议
+    public function index(){
+            $keyword = $this->request->param('keyword');
+            if ($keyword && !is_numeric($keyword)) {
+                $page = PageModel::getByDiyname($keyword);
+            } else {
+                $id =  $keyword ? $keyword : $this->request->param('id', '');
+                $page = PageModel::get($id);
+            }
+            
+            // 如果没有指定页面或页面不存在,获取第一个正常状态的页面
+            if (empty($page)) {
+                $page = PageModel::where('status', 'normal')->order('id asc')->find();
+            }
+            
+            if (!empty($page)) {
+                $page->setInc('views');
+                $image = $page->getData('image');
+                $fields = explode(',', 'id,title,content,image,description,status,createtime');
+                $pageData = array_intersect_key($page->toArray(), array_flip($fields));
+                $pageData['content'] = Service::formatSourceTpl($pageData['content']);
+                $pageData['image'] = $image ? cdnurl($image, true) : $image;
+                
+                // 分配变量到模板
+                $this->view->assign('page', $pageData);
+                return $this->view->fetch();
+            } else {
+                $this->error('未找到页面内容');
+            }
+    }
+}
+
+
+

+ 5 - 1
application/index/controller/Index.php

@@ -3,6 +3,8 @@
 namespace app\index\controller;
 
 use app\common\controller\Frontend;
+use app\common\model\Page as PageModel;
+use app\common\library\Service;
 
 class Index extends Frontend
 {
@@ -15,5 +17,7 @@ class Index extends Frontend
     {
         return $this->view->fetch();
     }
-
 }
+
+
+

+ 199 - 0
application/index/view/agreement/index.html

@@ -0,0 +1,199 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    
+    <title>{$page.title|default='协议内容'|htmlentities} - {$site.name|htmlentities}</title>
+    <link rel="shortcut icon" href="__CDN__/assets/img/favicon.ico"/>
+    <link href="__CDN__/assets/css/index.css" rel="stylesheet">
+    <style>
+        body {
+            overflow-x: hidden;
+            overflow-y: auto;
+        }
+        .agreement-container {
+            max-width: 1200px;
+            margin: 0 auto;
+            padding: 20px;
+            background: #fff;
+            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
+            border-radius: 8px;
+            margin-top: 20px;
+            margin-bottom: 20px;
+            overflow: visible;
+        }
+        .agreement-title {
+            font-size: 28px;
+            font-weight: bold;
+            color: #333;
+            text-align: center;
+            margin-bottom: 30px;
+            padding-bottom: 15px;
+            border-bottom: 2px solid #f0f0f0;
+        }
+        .agreement-content {
+            font-size: 16px;
+            line-height: 1.8;
+            color: #555;
+            text-align: justify;
+            overflow: visible;
+            word-wrap: break-word;
+            word-break: break-all;
+        }
+        .agreement-content img {
+            max-width: 100%;
+            height: auto;
+            margin: 10px 0;
+            display: block;
+        }
+        .agreement-content p {
+            margin-bottom: 15px;
+            overflow: visible;
+        }
+        .agreement-content h1,
+        .agreement-content h2,
+        .agreement-content h3,
+        .agreement-content h4,
+        .agreement-content h5,
+        .agreement-content h6 {
+            margin: 20px 0 15px 0;
+            color: #333;
+        }
+        .agreement-content table {
+            width: 100%;
+            border-collapse: collapse;
+            margin: 15px 0;
+        }
+        .agreement-content table td,
+        .agreement-content table th {
+            border: 1px solid #ddd;
+            padding: 8px;
+            text-align: left;
+        }
+        .agreement-content table th {
+            background-color: #f2f2f2;
+        }
+        .agreement-content ul,
+        .agreement-content ol {
+            margin: 15px 0;
+            padding-left: 30px;
+        }
+        .agreement-content li {
+            margin-bottom: 8px;
+        }
+        .agreement-meta {
+            text-align: center;
+            color: #999;
+            font-size: 14px;
+            margin-top: 30px;
+            padding-top: 15px;
+            border-top: 1px solid #f0f0f0;
+        }
+        .back-link {
+            display: inline-block;
+            margin-top: 20px;
+            color: #007bff;
+            text-decoration: none;
+            padding: 8px 20px;
+            border: 1px solid #007bff;
+            border-radius: 4px;
+            transition: all 0.3s;
+        }
+        .back-link:hover {
+            background: #007bff;
+            color: #fff;
+            text-decoration: none;
+        }
+        
+        /* 确保页面可以正常滚动,页脚固定在底部 */
+        html, body {
+            height: 100%;
+            margin: 0;
+            padding: 0;
+            overflow-x: hidden;
+        }
+        
+        body {
+            display: flex;
+            flex-direction: column;
+        }
+        
+        #mainbody {
+            flex: 1;
+            overflow-y: auto;
+            padding-bottom: 20px;
+        }
+        
+        .container {
+            overflow: visible;
+        }
+        
+        .footer {
+            position: fixed;
+            bottom: 0;
+            left: 0;
+            right: 0;
+            background: #f8f9fa;
+            border-top: 1px solid #e9ecef;
+            padding: 15px 0;
+            z-index: 1000;
+        }
+        
+        .footer .container {
+            max-width: 1200px;
+            margin: 0 auto;
+            padding: 0 20px;
+        }
+        
+        .footer p {
+            margin: 0;
+            text-align: center;
+            color: #666;
+            font-size: 14px;
+        }
+    </style>
+</head>
+
+<body>
+
+<div id="mainbody">
+    <div class="container">
+        {if isset($page)}
+        <div class="agreement-container">
+            <h1 class="agreement-title">{$page.title|htmlentities}</h1>
+            
+            <div class="agreement-content">
+                {$page.content}
+            </div>
+            
+            <div class="agreement-meta">
+                {if isset($page.createtime)}
+                <p>发布时间:{$page.createtime|date='Y-m-d H:i:s',###}</p>
+                {/if}
+                <a href="{:url('index/index/index')}" class="back-link">返回首页</a>
+            </div>
+        </div>
+        {else}
+        <div class="agreement-container">
+            <div class="text-center">
+                <h2>暂无内容</h2>
+                <p>抱歉,暂时没有找到相关内容。</p>
+                <a href="{:url('index/index/index')}" class="back-link">返回首页</a>
+            </div>
+        </div>
+        {/if}
+    </div>
+</div>
+
+<div class="footer">
+    <div class="container">
+        <p>Copyright @ {$site.name|htmlentities} {:date('Y',time())} 版权所有 <a href="https://beian.miit.gov.cn" target="_blank">{$site.beian|htmlentities}</a></p>
+    </div>
+</div>
+
+</body>
+
+</html>