Просмотр исходного кода

一级栏目创建模板逻辑更改

ming 1 год назад
Родитель
Сommit
daa38e93db
2 измененных файлов с 63 добавлено и 24 удалено
  1. 59 22
      assets/js/commonVue.js
  2. 4 2
      assets/js/component/headerCom.js

+ 59 - 22
assets/js/commonVue.js

@@ -95,6 +95,9 @@ const App = {
 
   },
   created: function () {
+    // alert(window.location.href)
+    // alert(window.location.pathname)
+  //  alert(this.getQuery('dup'))  
     this.requestParams.categoryid = this.getQuery('categoryid') ? this.getQuery('categoryid') : ''
     this.requestParams.id = this.getQuery('id') ? this.getQuery('id') : ''
     this.requestParams.articleid = this.getQuery('id') ? this.getQuery('id') : ''
@@ -122,7 +125,8 @@ const App = {
             expires
           }));
           _this.loading = false
-          _this.currentPath = window.location.pathname;
+      
+         
           _this.handleColumnData()
         })
       } else {
@@ -139,7 +143,12 @@ const App = {
 
 
     handleColumnData() {
-            this.currentPath = window.location.pathname;
+      if(window.location.href.indexOf("dup")>0){
+        this.currentPath = `${window.location.pathname}?dup=` + this.getQuery('dup')
+      }else{
+        this.currentPath = window.location.pathname;
+      }
+
       this.columnList = JSON.parse(localStorage.getItem('storeColumnList')).data;
 
       // 读取并检查是否过期
@@ -171,29 +180,49 @@ const App = {
           _this.getArticalData(_this.requestParams)
         }
 
-        //进入其他栏目页
-        
         
+
+          //进入其他栏目页
           if (('/template'+_this.columnList[i].categoryStyle+'/' == window.location.pathname)||(_this.columnList[i].categoryStyle == window.location.pathname.replace('index.html', ''))) {
-          getSeoCommon()
-          _this.columnTypes = _this.columnList[i].children
-          _this.colL = _this.columnTypes.childten;
-          if (_this.columnList[i].children.length > 0) {
-            _this.requestParams.categoryid = (_this.getQuery('isUrlId') == 1) ? _this.getQuery('categoryid') : _this.columnTypes[0].id;
-          } else {
-            var objData = _this.columnList.filter(obj => '/template'+obj.categoryStyle+'/' == window.location.pathname.replace('index.html', ''));
-            _this.requestParams.categoryid = objData[0].id
+            getSeoCommon()
+            _this.columnTypes = _this.columnList[i].children
+            _this.colL = _this.columnTypes.childten;
+
+
+            if (_this.columnList[i].children.length > 0) {
+              _this.requestParams.categoryid = (_this.getQuery('isUrlId') == 1) ? _this.getQuery('categoryid') : _this.columnTypes[0].id;
+              _this.columnImage = _this.columnList[i].imagePath;
+              _this.getArticalData(_this.requestParams)
+
+            } else {
+
+              
+              if (window.location.href.indexOf("dup")&&('/template'+_this.columnList[i].categoryStyle+'/?dup='+_this.columnList[i].sname == `${window.location.pathname}?dup=` + this.getQuery('dup'))) {
+                console.log('是重复模板')
+                var objData = _this.columnList.filter(obj => '/template'+obj.categoryStyle+'/?dup='+obj.sname == `${window.location.pathname}?dup=` + _this.getQuery('dup'));
+                _this.requestParams.categoryid = objData[0].id
+                _this.getArticalData(_this.requestParams)
+                _this.columnImage = _this.columnList[i].imagePath;
+              }
+              if (window.location.href.indexOf("dup")==-1&&!_this.columnList[i].sname&&('/template'+_this.columnList[i].categoryStyle+'/' == window.location.pathname)){
+                console.log('不是重复模板')
+                var objData = _this.columnList.filter(obj => '/template'+obj.categoryStyle+'/' == window.location.pathname.replace('index.html', ''));
+                _this.requestParams.categoryid = objData[0].id
+                _this.getArticalData(_this.requestParams)
+                _this.columnImage = _this.columnList[i].imagePath;
+              }
+             
 
-          }
-                    _this.getArticalData(_this.requestParams)
-          _this.modelType = _this.columnList[i].modelType;
-          _this.columnImage = _this.columnList[i].imagePath;
-          setTimeout(() => {
-            if (_this.modelType == 2) {
-              document.getElementById("videoPlay").src = _this.columnImage; //url为你需要播放的视频地址
-              document.getElementById("videoPlay").setAttribute('poster', '/assets/img/banner/poster.jpg');
             }
-          }, 100)
+            
+            _this.modelType = _this.columnList[i].modelType;
+            
+            setTimeout(() => {
+              if (_this.modelType == 2) {
+                document.getElementById("videoPlay").src = _this.columnImage; //url为你需要播放的视频地址
+                document.getElementById("videoPlay").setAttribute('poster', '/assets/img/banner/poster.jpg');
+              }
+            }, 100)
 
 
 
@@ -214,7 +243,15 @@ const App = {
               _this.requestParams.articleid = ''
               _this.getArticalData(_this.requestParams, 1)
             }, 100)
-            _this.currentPath = _this.columnList[i].categoryStyle //产品详情时栏目高亮
+            
+            //产品详情时栏目高亮
+            if(window.location.href.indexOf("dup")>0){
+              // _this.currentPath = `${window.location.pathname}?dup=` + _this.getQuery('dup')
+            }else{
+            _this.currentPath =`/template${ _this.columnList[i].categoryStyle}/` 
+          }
+
+
             _this.modelType = _this.columnList[i].modelType; //栏目图片获取
             _this.columnImage = _this.columnList[i].imagePath; //栏目图片获取
             setTimeout(() => {

+ 4 - 2
assets/js/component/headerCom.js

@@ -15,8 +15,10 @@ export default {
 
                             <div class="menu-items">
                                 <ul v-if="todo">
-                                    <li v-for="item in todo" :key="item.id" :class="
-                                    currentone=='/template'+item.categoryStyle+'/'? 'active':''">
+                                    <li v-for="item in todo" :key="item.id" 
+                                    :class="!item.sname ? currentone=='/template'+item.categoryStyle+'/' ? 'active' : '' : currentone == '/template'+item.categoryStyle+'/?dup=' + item.sname ? 'active' : ''" 
+                                    
+                                    >
                                         <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>
                                         <ul class="submenu">