浏览代码

文章seo

chao 4 年之前
父节点
当前提交
0b6e8bef74

+ 9 - 6
src/main/java/com/caimei/www/controller/unlimited/ArticleController.java

@@ -36,12 +36,13 @@ public class ArticleController extends BaseController {
     /**
     /**
      * 文章列表【旧center】
      * 文章列表【旧center】
      */
      */
-    @GetMapping("/info/center-{id}-1.html")
-    public String toArticleList(@PathVariable("id") Integer id, final Model model) {
+    @GetMapping("/info/center-{id}-{pageNum}.html")
+    public String toArticleList(@PathVariable("id") Integer id, @PathVariable("id") Integer pageNum, final Model model) {
         List<BaseLink> typeList = articleService.getArticleTypes();
         List<BaseLink> typeList = articleService.getArticleTypes();
         model.addAttribute("articleType", typeList);
         model.addAttribute("articleType", typeList);
         model.addAttribute("typeId", id);
         model.addAttribute("typeId", id);
         model.addAttribute("labelId", 0);
         model.addAttribute("labelId", 0);
+        model.addAttribute("pageNum", pageNum);
         //model.addAttribute("pagePath", String.format("/info/center-%s-1.html", id));
         //model.addAttribute("pagePath", String.format("/info/center-%s-1.html", id));
         return ARTICLE_LIST_PATH;
         return ARTICLE_LIST_PATH;
     }
     }
@@ -49,12 +50,13 @@ public class ArticleController extends BaseController {
     /**
     /**
      * 文章列表【旧label】
      * 文章列表【旧label】
      */
      */
-    @GetMapping("/info/label-{id}-1.html")
-    public String toArticleLabel(@PathVariable("id") Integer id, final Model model) {
+    @GetMapping("/info/label-{id}-{pageNum}.html")
+    public String toArticleLabel(@PathVariable("id") Integer id, @PathVariable("id") Integer pageNum, final Model model) {
         List<BaseLink> typeList = articleService.getArticleTypes();
         List<BaseLink> typeList = articleService.getArticleTypes();
         model.addAttribute("articleType", typeList);
         model.addAttribute("articleType", typeList);
         model.addAttribute("typeId", 0);
         model.addAttribute("typeId", 0);
         model.addAttribute("labelId", id);
         model.addAttribute("labelId", id);
+        model.addAttribute("pageNum", pageNum);
         //model.addAttribute("pagePath", String.format("/info/label-%s-1.html", id));
         //model.addAttribute("pagePath", String.format("/info/label-%s-1.html", id));
         return ARTICLE_LIST_PATH;
         return ARTICLE_LIST_PATH;
     }
     }
@@ -62,12 +64,13 @@ public class ArticleController extends BaseController {
     /**
     /**
      * 文章搜索结果
      * 文章搜索结果
      */
      */
-    @GetMapping("/info/search.html")
-    public String toArticleSearch(final Model model) {
+    @GetMapping("/info/search-{pageNum}.html")
+    public String toArticleSearch(@PathVariable("id") Integer pageNum, final Model model) {
         List<BaseLink> typeList = articleService.getArticleTypes();
         List<BaseLink> typeList = articleService.getArticleTypes();
         model.addAttribute("articleType", typeList);
         model.addAttribute("articleType", typeList);
         model.addAttribute("typeId", 0);
         model.addAttribute("typeId", 0);
         model.addAttribute("labelId", 0);
         model.addAttribute("labelId", 0);
+        model.addAttribute("pageNum", pageNum);
         //model.addAttribute("pagePath", "/info/search.html");
         //model.addAttribute("pagePath", "/info/search.html");
         return ARTICLE_LIST_PATH;
         return ARTICLE_LIST_PATH;
     }
     }

+ 15 - 1
src/main/resources/static/js/article/list.js

@@ -14,7 +14,7 @@ var articleList = new Vue({
         },
         },
         listData: [],
         listData: [],
         listRecord: 0,
         listRecord: 0,
-        pageInput: ''
+        pageInput: '1'
     },
     },
     computed: {
     computed: {
         pageTotal: function () {
         pageTotal: function () {
@@ -43,6 +43,20 @@ var articleList = new Vue({
                 window.location.href = updateUrlParam(params);
                 window.location.href = updateUrlParam(params);
             }
             }
         },
         },
+        paginationUrl: function(pageNum) {
+             var path = window.location.href;
+             var paramsArr = window.location.pathname.split(".")[0].split("-");
+             var pageId =  paramsArr.length>=1 ? paramsArr[1] : '';
+             if (paramsArr[0].indexOf('/info/search') >= 0) {
+                var search = window.location.search;
+                path = '/info/search-'+pageNum+'.html'+search;
+             }else if (paramsArr[0].indexOf('/info/center') >= 0) {
+                path = '/info/center-'+pageId+'-'+pageNum+'.html';
+            } else if (paramsArr[0].indexOf('/info/label') >= 0) {
+                path = '/info/label-'+pageId+'-'+pageNum+'.html';
+            }
+            return path;
+        },
         checkNum: function () {
         checkNum: function () {
             if (this.pageInput > this.pageTotal) {
             if (this.pageInput > this.pageTotal) {
                 this.pageInput = this.pageTotal;
                 this.pageInput = this.pageTotal;

+ 1 - 1
src/main/resources/static/js/base.js

@@ -376,7 +376,7 @@ $(function(){
             window.location.href = '/equipment/list.html?keyword=' + encodeURIComponent(keyword);
             window.location.href = '/equipment/list.html?keyword=' + encodeURIComponent(keyword);
         } else{
         } else{
             // 文章
             // 文章
-            window.location.href = '/info/search.html?keyword=' + encodeURIComponent(keyword);
+            window.location.href = '/info/search-1.html?keyword=' + encodeURIComponent(keyword);
         }
         }
     }).on('keyup', '.keyword', function(event) {
     }).on('keyup', '.keyword', function(event) {
         // 搜索输入框 按回车键搜索
         // 搜索输入框 按回车键搜索

+ 17 - 5
src/main/resources/templates/article/list.html

@@ -64,20 +64,32 @@
             </div>
             </div>
             <!--分页-->
             <!--分页-->
             <div v-if="(!isPC) && noMore" class="noMore">---- 没有更多了 ----</div>
             <div v-if="(!isPC) && noMore" class="noMore">---- 没有更多了 ----</div>
+<!--            <div v-if="isPC && pageTotal>1" class="pageWrap clear">-->
+<!--                <a v-if="params.num>1" class="prev" @click="toPagination(params.num*1-1)" href="javascript:void(0);"></a>-->
+<!--                <template v-for="n in showPageBtn">-->
+<!--                    <a v-if="n" :class="{'on':(n==params.num)}" @click="toPagination(n)" href="javascript:void(0);" v-text="n"></a>-->
+<!--                    <span v-else>···</span>-->
+<!--                </template>-->
+<!--                <a v-if="params.num<pageTotal" class="next" @click="toPagination(params.num*1+1)" href="javascript:void(0);"></a>-->
+<!--                <span>共<b v-text="pageTotal>1?pageTotal:1"></b>页</span>-->
+<!--                <span>跳至</span>-->
+<!--                <input v-model="pageInput" @blur="checkNum()"/>-->
+<!--                <span>页</span>&nbsp;-->
+<!--                <a class="btn" href="javascript:void(0);" @click="toPagination(pageInput)">点击跳转</a>-->
+<!--            </div>-->
             <div v-if="isPC && pageTotal>1" class="pageWrap clear">
             <div v-if="isPC && pageTotal>1" class="pageWrap clear">
-                <a v-if="params.num>1" class="prev" @click="toPagination(params.num*1-1)" href="javascript:void(0);"></a>
+                <a v-if="params.num>1" class="prev" :href="paginationUrl(params.num*1-1)"></a>
                 <template v-for="n in showPageBtn">
                 <template v-for="n in showPageBtn">
-                    <a v-if="n" :class="{'on':(n==params.num)}" @click="toPagination(n)" href="javascript:void(0);" v-text="n"></a>
+                    <a v-if="n" :class="{'on':(n==params.num)}" :href="paginationUrl(n)" v-text="n"></a>
                     <span v-else>···</span>
                     <span v-else>···</span>
                 </template>
                 </template>
-                <a v-if="params.num<pageTotal" class="next" @click="toPagination(params.num*1+1)" href="javascript:void(0);"></a>
+                <a v-if="params.num<pageTotal" class="next" :href="paginationUrl(params.num*1+1)"></a>
                 <span>共<b v-text="pageTotal>1?pageTotal:1"></b>页</span>
                 <span>共<b v-text="pageTotal>1?pageTotal:1"></b>页</span>
                 <span>跳至</span>
                 <span>跳至</span>
                 <input v-model="pageInput" @blur="checkNum()"/>
                 <input v-model="pageInput" @blur="checkNum()"/>
                 <span>页</span>&nbsp;
                 <span>页</span>&nbsp;
-                <a class="btn" href="javascript:void(0);" @click="toPagination(pageInput)">点击跳转</a>
+                <a class="btn" :href="paginationUrl(pageInput)">点击跳转</a>
             </div>
             </div>
-
         </div>
         </div>
     </div>
     </div>
     <!--侧边栏-->
     <!--侧边栏-->

+ 1 - 1
src/main/resources/templates/components/footer.html

@@ -57,7 +57,7 @@
             </div>
             </div>
             <div class="cellNumber">
             <div class="cellNumber">
                 <span>周一至周五 09:00-18:00</span>
                 <span>周一至周五 09:00-18:00</span>
-                <span>座机:<a href="tel:075522907771">0755-22907771</a></span>/<span>手机:<a href="tel:15338851365">153-3885-1365</a></span>
+                <span>座机:<a href="tel:075522907771" rel="nofollow">0755-22907771</a></span>/<span>手机:<a href="tel:15338851365" rel="nofollow">153-3885-1365</a></span>
             </div>
             </div>
         </div>
         </div>
         <!--copyright-->
         <!--copyright-->