Browse Source

seo模板化,相关跳转逻辑完善 底部重复模板跳转更改

ming 1 year ago
parent
commit
003c7b6289
5 changed files with 28 additions and 23 deletions
  1. 20 17
      assets/js/commonVue.js
  2. 5 3
      assets/js/component/footerCom.js
  3. 1 1
      template2/read.html
  4. 1 1
      template3/read.html
  5. 1 1
      template4/read.html

+ 20 - 17
assets/js/commonVue.js

@@ -166,7 +166,7 @@ const App = {
           console.log( _this.dialogDataArray)
           console.log( _this.dialogDataArray)
           _this.ruleForm.platName = _this.dialogDataArray[0].categoryName;
           _this.ruleForm.platName = _this.dialogDataArray[0].categoryName;
         }
         }
-        
+
 
 
         //栏目处理  
         //栏目处理  
 
 
@@ -190,7 +190,7 @@ const App = {
 
 
         //进入其他栏目页
         //进入其他栏目页
         if (('/template' + _this.columnList[i].categoryStyle + '/' == window.location.pathname) || (_this.columnList[i].categoryStyle == window.location.pathname.replace('index.html', ''))) {
         if (('/template' + _this.columnList[i].categoryStyle + '/' == window.location.pathname) || (_this.columnList[i].categoryStyle == window.location.pathname.replace('index.html', ''))) {
-          getSeoCommon()
+         
 
 
           if (window.location.href.indexOf("dup") && ('/template' + _this.columnList[i].categoryStyle + '/?dup=' + _this.columnList[i].sname == `${window.location.pathname}?dup=` + this.getQuery('dup'))) {
           if (window.location.href.indexOf("dup") && ('/template' + _this.columnList[i].categoryStyle + '/?dup=' + _this.columnList[i].sname == `${window.location.pathname}?dup=` + this.getQuery('dup'))) {
             if (_this.columnList[i].children.length > 0) {
             if (_this.columnList[i].children.length > 0) {
@@ -204,6 +204,7 @@ const App = {
               _this.getArticalData(_this.requestParams)
               _this.getArticalData(_this.requestParams)
               _this.columnImage = _this.columnList[i].imagePath;
               _this.columnImage = _this.columnList[i].imagePath;
             }
             }
+            getSeoCommon()
 
 
           }
           }
           if (window.location.href.indexOf("dup") == -1 && !_this.columnList[i].sname && ('/template' + _this.columnList[i].categoryStyle + '/' == window.location.pathname)) {
           if (window.location.href.indexOf("dup") == -1 && !_this.columnList[i].sname && ('/template' + _this.columnList[i].categoryStyle + '/' == window.location.pathname)) {
@@ -218,6 +219,7 @@ const App = {
               _this.getArticalData(_this.requestParams)
               _this.getArticalData(_this.requestParams)
               _this.columnImage = _this.columnList[i].imagePath;
               _this.columnImage = _this.columnList[i].imagePath;
             }
             }
+            getSeoCommon()
             
             
           }
           }
 
 
@@ -236,7 +238,6 @@ const App = {
           // 进入详情页
           // 进入详情页
           if ('/template' + _this.columnList[i].categoryStyle + '/read.html' == window.location.pathname) {
           if ('/template' + _this.columnList[i].categoryStyle + '/read.html' == window.location.pathname) {
             getDetailCommon()
             getDetailCommon()
-            getSeoCommon()
           }
           }
 
 
           function getDetailCommon() {
           function getDetailCommon() {
@@ -252,11 +253,13 @@ const App = {
             //产品详情时栏目高亮
             //产品详情时栏目高亮
             if(window.location.href.indexOf("dup") && ('/template' + _this.columnList[i].categoryStyle+ '/read.html' + '?dup=' + _this.columnList[i].sname == `${window.location.pathname}?dup=` + _this.getQuery('dup'))){
             if(window.location.href.indexOf("dup") && ('/template' + _this.columnList[i].categoryStyle+ '/read.html' + '?dup=' + _this.columnList[i].sname == `${window.location.pathname}?dup=` + _this.getQuery('dup'))){
               _this.currentPath = `/template${ _this.columnList[i].categoryStyle}/?dup=` + _this.getQuery('dup')
               _this.currentPath = `/template${ _this.columnList[i].categoryStyle}/?dup=` + _this.getQuery('dup')
+              getSeoCommon()
             }
             }
            
            
             if (window.location.href.indexOf("dup") == -1 && !_this.columnList[i].sname && ('/template' + _this.columnList[i].categoryStyle +  '/read.html' == window.location.pathname)) {
             if (window.location.href.indexOf("dup") == -1 && !_this.columnList[i].sname && ('/template' + _this.columnList[i].categoryStyle +  '/read.html' == window.location.pathname)) {
               
               
               _this.currentPath = `/template${ _this.columnList[i].categoryStyle}/`
               _this.currentPath = `/template${ _this.columnList[i].categoryStyle}/`
+              getSeoCommon()
             }
             }
 
 
             _this.modelType = _this.columnList[i].modelType; //栏目图片获取
             _this.modelType = _this.columnList[i].modelType; //栏目图片获取
@@ -275,10 +278,6 @@ const App = {
           $('meta[name="description"]').attr('content', _this.columnList[i].metadescription);
           $('meta[name="description"]').attr('content', _this.columnList[i].metadescription);
           $('meta[name="keywords"]').attr('content', _this.columnList[i].metakeywords);
           $('meta[name="keywords"]').attr('content', _this.columnList[i].metakeywords);
         }
         }
-
-
-
-        
       }
       }
     },
     },
 
 
@@ -363,17 +362,21 @@ const App = {
         window.addEventListener('scroll', lazyLoad)
         window.addEventListener('scroll', lazyLoad)
         // 3 定义页面滚动的处理函数
         // 3 定义页面滚动的处理函数
         function lazyLoad() {
         function lazyLoad() {
-          for (let i = 0; i < images.length; i++) {
-            // isVisible是否该图片位于可视区域 返回true 或false
-            if (isVisible(images[i])) {
-              // 将元素的自定义属性 data-src 赋值给元素的 src 属性 
-              // dataset.src 此为元素的自定义属性 data-src
-              images[i].src = images[i].dataset.src // 等价于:img.setAttribute('src', img.getAttribute('data-src'))
-              // 防止重复被遍历 加载完之后 删除元素不再加载
-              images.splice(i, 1)
-              i--
+            for (let i = 0; i < images.length; i++) {
+              // isVisible是否该图片位于可视区域 返回true 或false
+              if (isVisible(images[i])) {
+                // 将元素的自定义属性 data-src 赋值给元素的 src 属性 
+                // dataset.src 此为元素的自定义属性 data-src
+                if(images[i].dataset.src){
+                  images[i].src = images[i].dataset.src // 等价于:img.setAttribute('src', img.getAttribute('data-src'))
+                }
+                // 防止重复被遍历 加载完之后 删除元素不再加载
+                images.splice(i, 1)
+                i--
+              }
             }
             }
-          }
+
+          
         }
         }
         lazyLoad()
         lazyLoad()
         // 4 可视区域判断函数
         // 4 可视区域判断函数

+ 5 - 3
assets/js/component/footerCom.js

@@ -17,12 +17,14 @@ export default {
                           <div class="footerNone" style="width:15% !important;" v-for="item in todo" :key="item.id">
                           <div class="footerNone" style="width:15% !important;" v-for="item in todo" :key="item.id">
                               <div class="widget nav-widget d-flex justify-content-center ">
                               <div class="widget nav-widget d-flex justify-content-center ">
                                   <div>
                                   <div>
-                                      <h5 class="widget-title"><a  :href="item.categoryStyle==1?'/':'/template'+item.categoryStyle+'/'"
-                                              >{{item.categoryName}}</a>
+                                      <h5 class="widget-title">
+                                        <a  v-if="item.sname" :href="item.categoryStyle==1?'/?dup='+item.sname:'/template'+item.categoryStyle+'/?dup='+item.sname">{{item.categoryName}}</a>
+                                        <a  v-else :href="item.categoryStyle==1?'/':'/template'+item.categoryStyle+'/'">{{item.categoryName}}</a>
                                       </h5>
                                       </h5>
                                       <ul>
                                       <ul>
                                           <li v-if="item.children" v-for="r in item.children" :key="r.id">
                                           <li v-if="item.children" v-for="r in item.children" :key="r.id">
-                                              <a :href="'/template'+item.categoryStyle+'/?categoryid='+r.id+'&isUrlId=1'"> {{r.sname}}</a>
+                                              <a :href="item.sname?'/template'+item.categoryStyle+'/?dup='+item.sname+'&categoryid='+r.id+'&isUrlId=1'  : '/template'+item.categoryStyle+'/?categoryid='+r.id+'&isUrlId=1'"> <span
+                                              > {{r.sname}}</a>
                                           </li>
                                           </li>
                                       </ul>
                                       </ul>
                                   </div>
                                   </div>

+ 1 - 1
template2/read.html

@@ -103,7 +103,7 @@
                             <div v-if="articalArrayRelated.length>0">
                             <div v-if="articalArrayRelated.length>0">
                                 <div class="title-tag2">相关推荐</div>
                                 <div class="title-tag2">相关推荐</div>
                                 <div class="relNewBox container ">
                                 <div class="relNewBox container ">
-                                    <a class="ustify-content-between d-flex relNewsList" :href="'./read.html?categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1'" v-for="item in articalArrayRelated" :key="item.id">
+                                    <a class="ustify-content-between d-flex relNewsList" :href="dup?'./read.html?dup='+dup+'&categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1':'./read.html?categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1'" v-for="item in articalArrayRelated" :key="item.id">
                                         <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
                                         <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
                                         <div> {{timeFormatSeconds(item.modifydate?item.modifydate:'')}}</div>
                                         <div> {{timeFormatSeconds(item.modifydate?item.modifydate:'')}}</div>
                                     </a>
                                     </a>

+ 1 - 1
template3/read.html

@@ -108,7 +108,7 @@
                             <div v-if="articalArrayRelated.length>0">
                             <div v-if="articalArrayRelated.length>0">
                                 <div class="title-tag2 ">相关产品</div>
                                 <div class="title-tag2 ">相关产品</div>
                                 <div class="relNewBox container ">
                                 <div class="relNewBox container ">
-                                    <a class="ustify-content-between d-flex relNewsList" :href="'./read.html?categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1'" v-for="item in articalArrayRelated" :key="item.id">
+                                    <a class="ustify-content-between d-flex relNewsList" :href="dup?'./read.html?dup='+dup+'&categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1':'./read.html?categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1'" v-for="item in articalArrayRelated" :key="item.id">
                                         <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
                                         <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
                                         <div> {{timeFormatSeconds(item.modifydate?item.modifydate:'')}}</div>
                                         <div> {{timeFormatSeconds(item.modifydate?item.modifydate:'')}}</div>
                                     </a>
                                     </a>

+ 1 - 1
template4/read.html

@@ -108,7 +108,7 @@
                             <div v-if="!loading&&articalArrayRelated.length>0">
                             <div v-if="!loading&&articalArrayRelated.length>0">
                                 <div class="title-tag2">相关新闻</div>
                                 <div class="title-tag2">相关新闻</div>
                                 <div class="relNewBox container ">
                                 <div class="relNewBox container ">
-                                    <a class="ustify-content-between d-flex relNewsList" :href="'./read.html?categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1'" v-for="item in articalArrayRelated" :key="item.id">
+                                    <a class="ustify-content-between d-flex relNewsList" :href="dup?'./read.html?dup='+dup+'&categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1':'./read.html?categoryid='+item.categoryid+'&id='+item.id+'&isUrlId=1'" v-for="item in articalArrayRelated" :key="item.id">
                                         <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
                                         <div><img width="18" height="18" src="../assets/img/news/arrowT.svg"> {{item.title}} </div>
                                         <div> {{timeFormatSeconds(articalArray[0].createdate)}}</div>
                                         <div> {{timeFormatSeconds(articalArray[0].createdate)}}</div>
                                     </a>
                                     </a>