qiushang 10 月之前
父节点
当前提交
feb9c09c50
共有 2 个文件被更改,包括 41 次插入3 次删除
  1. 2 1
      app/Http/Home/HelpController.php
  2. 39 2
      resources/views/home/http/newslist.blade.php

+ 2 - 1
app/Http/Home/HelpController.php

@@ -83,8 +83,9 @@ class HelpController extends HttpBaseController
             ->orderBy('created_at', 'desc')
             ->limit($size);
         $list = $find->get();
+        $total = DB::table('news')->where('category_id', $categoryInfo->id)->count();
 
-        return view('home/http/newslist', ['category' => $category, 'list' => $list]);
+        return view('home/http/newslist', ['category' => $category, 'list' => $list, 'total' => $total]);
     }
 
     public function detail($mid = '')

+ 39 - 2
resources/views/home/http/newslist.blade.php

@@ -4,6 +4,9 @@
 <head>
     <title>文章教程-帮助中心-星优办公软件</title>
     @include('home.http.common.head')
+    <link href="/static/css/jquery.page.css" rel="stylesheet" type="text/css">
+    <script src="/static/js/jquery.js"></script>
+    <script src="/static/js/jquery.page.js"></script>
 </head>
 
 <body>
@@ -12,7 +15,6 @@
     </div>
     <div style="height: 68px;"></div>
     <div id="app">
-
         <!--- 解决方案 --->
         <div class="index-about" style="padding-top: 40px;">
             <div class="width-1200">
@@ -37,13 +39,15 @@
                                 </div>
                             </div>
                         @endforeach
+
+                        <div id="page"></div>
                     </div>
                     <div class="about-detail">
                         <div class="about-area">
                             <div class="about-title">文章分类</div>
                             @foreach ($category as $item)
                                 <div class="news-item">
-                                    <a href="{{ url('/news/category/' . $item->mid) }}"
+                                    <a href="{{ url('/news/category/' . $item->mid . '?page=1') }}"
                                         target="_blank">{{ $item->name }}</a>
                                 </div>
                             @endforeach
@@ -57,5 +61,38 @@
         @include('home.http.common.footer')
     </div>
 </body>
+<script>
+    let total = Number ({{ $total }});
+    let totalPage =  Math.ceil(total / 15);
+    let currentUrl = window.location.href;
+    let url = new URL(currentUrl);
+    let currentPage = url.searchParams.get("page");
+    setTimeout(function() {
+        $("#page").Page({
+            totalPages: totalPage, //total Pages
+            liNums: 7, //the li numbers(advice use odd)
+            activeClass: 'activP', //active class style
+            firstPage: '首', //first button name
+            lastPage: '末', //last button name
+            prv: '<', //prev button name
+            next: '>', //next button name
+            hasFirstPage: true, //whether has first button
+            hasLastPage: true, //whether has last button
+            hasPrv: true, //whether has prev button
+            hasNext: true, //whether has next button
+            callBack: function(_page) {
+                url.searchParams.set('page', _page);
+                window.location.href = url.href;
+            }
+        });
 
+        $('.pagingUl li a').each((index, item) => {
+            $(item).removeClass('activP');
+            let num = $(item).text();
+            if(num == currentPage){
+                $(item).addClass('activP');
+            }
+        })
+    }, 100)
+</script>
 </html>