Browse Source

首页实现模板化

ming 1 year ago
parent
commit
dc498db6c2
1 changed files with 37 additions and 9 deletions
  1. 37 9
      assets/js/commonVue.js

+ 37 - 9
assets/js/commonVue.js

@@ -142,9 +142,14 @@ const App = {
 
 
     handleColumnData() {
-      if (window.location.href.indexOf("dup") > 0) {
+     
+      if(window.location.pathname=='/'&&!this.dup){//if 首页模板
+        this.currentPath='/template1/'
+      } else if(window.location.pathname=='/'&&this.dup){ //if 首页复用模板
+        this.currentPath='/template1/?dup='+this.dup
+      }else if (window.location.href.indexOf("dup") > 0) { // if 非首页模板
         this.currentPath = `${window.location.pathname}?dup=` + this.getQuery('dup')
-      } else {
+      } else { //非首页复用模板
         this.currentPath = window.location.pathname;
       }
 
@@ -163,7 +168,6 @@ const App = {
         // 获取反馈弹框类型数据
         if ( _this.columnList[i].categoryStyle == '2'&& _this.columnList[i].sname == '') {
           _this.dialogDataArray = (_this.columnList[i].children)
-          console.log( _this.dialogDataArray)
           _this.ruleForm.platName = _this.dialogDataArray[0].categoryName;
         }
 
@@ -172,11 +176,15 @@ const App = {
 
         //进入首页
         if (_this.columnList[i].categoryStyle == '1' && (window.location.pathname == '/' || window.location.pathname == '' || window.location.pathname == '/index.html')) {
-          getSeoCommon()
+          if ( '/?dup=' + _this.columnList[i].sname == `${window.location.pathname}?dup=` + this.getQuery('dup')) {
+            console.log('首页复用模板')
+            getSeoCommon()
+            var objData = _this.columnList.filter(obj =>obj.categoryStyle==1? '/?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;
+
 
-          this.requestParams.categoryid = this.columnList[0].id
-          _this.modelType = _this.columnList[0].modelType;
-          _this.columnImage = _this.columnList[0].imagePath;
           setTimeout(() => {
             if (_this.modelType == 2) {
               document.getElementById("videoPlay").src = _this.columnImage; //url为你需要播放的视频地址
@@ -184,14 +192,34 @@ const App = {
             }
           }, 100)
           _this.getArticalData(_this.requestParams)
+
+
+          }
+          if(window.location.href.indexOf("dup") == -1&& !_this.columnList[i].sname  ){
+            console.log('首页模板')
+            getSeoCommon()
+            this.requestParams.categoryid = this.columnList[0].id
+            _this.modelType = _this.columnList[0].modelType;
+            _this.columnImage = _this.columnList[0].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.getArticalData(_this.requestParams)
+          }
+         
+         
+        
+
+          
         }
 
 
 
         //进入其他栏目页
         if (('/template' + _this.columnList[i].categoryStyle + '/' == window.location.pathname) || (_this.columnList[i].categoryStyle == window.location.pathname.replace('index.html', ''))) {
-         
-
           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) {
               _this.columnTypes = _this.columnList[i].children