Sfoglia il codice sorgente

优化接口调用

aaa 4 anni fa
parent
commit
0f693e46d7

+ 11 - 9
src/views/home/learn/page-learn-child.vue

@@ -48,7 +48,7 @@
                 <div class="contentItemDescriptionTime">
                   {{
                     formateDateTimeFun(contentItem.createdTime) ||
-                      contentItem.createdTime
+                    contentItem.createdTime
                   }}
                 </div>
                 <div>
@@ -86,7 +86,7 @@ export default {
   data() {
     return {
       active: 0,
-      choosedChildIndex: 0,
+      choosedChildIndex: null,
       titleStyle: {
         fontSize: "10px"
       },
@@ -96,20 +96,21 @@ export default {
     };
   },
   computed: {},
-  created() {},
+  created() {
+    console.log("---");
+  },
   mounted() {},
   watch: {
     //   第一次加载内容
-    "learnChildList.length": {
+    learnChildList: {
       handler(newValue, oldValue) {
-        if (oldValue === 0 && newValue !== 0) {
-          this.getContentList();
+        if (this.choosedChildIndex === null) {
+          this.choosedChildIndex = 0;
         }
       }
     },
-    active(val, oldVal) {
-      console.log(val, oldVal);
-      if (val !== oldVal) {
+    choosedChildIndex(newValue, oldValue) {
+      if (newValue !== oldValue) {
         this.getContentList();
       }
     }
@@ -133,6 +134,7 @@ export default {
           )
         )
         .then(res => {
+          console.log("--ContentList----ed-");
           this.contentList = res.data;
           this.finished = true;
         })

+ 2 - 5
src/views/home/learn/page-learn.vue

@@ -38,10 +38,9 @@ export default {
   computed: {},
   created() {
     this.getSwiperListDataFun();
-  },
-  mounted() {
     this.getLearnRootList();
   },
+  mounted() {},
   methods: {
     // 查询轮播图数据列表
     getSwiperListDataFun() {
@@ -67,16 +66,14 @@ export default {
     },
     //   查询子目录
     getChildList() {
-      this.learnChildList = [];
       let path = {
         categoryId: this.learnRootList[this.choosedRootIndex].id
       };
       this.$_http
         .get(this.$pathParams(this.$_API.JTXT_GET_CATEGORIES_CATEGROYID, path))
         .then(res => {
+          res.data.shift();
           this.learnChildList = res.data;
-          //   移除第一个根目录
-          this.learnChildList.shift();
         })
         .catch(() => {
           this.$store.commit("toggleLoading", false);