aaa hace 4 años
padre
commit
d8b4d2e7b9
Se han modificado 2 ficheros con 10 adiciones y 15 borrados
  1. 3 1
      src/api/modules/learn.js
  2. 7 14
      src/views/home/learn/page-learn-recommend.vue

+ 3 - 1
src/api/modules/learn.js

@@ -17,6 +17,8 @@ export default {
     // 校验是否可以阅读文章
     JTXT_GET_MATERIALS_READ: "materials/{materialId}/read",
     // 阅读文章
-    JTXT_POST_MATERIALS_READ: "materials/{materialId}/read"
+    JTXT_POST_MATERIALS_READ: "materials/{materialId}/read",
+    // 阅读文章
+    JTXT_GET_NEWSFEED: "newsfeed"
   }
 };

+ 7 - 14
src/views/home/learn/page-learn-recommend.vue

@@ -24,7 +24,7 @@
         :key="contentIndex"
         @click="chooseContent(contentIndex)"
       >
-        <div slot="default" class="contentItemDiv">
+        <div slot="default" class="contentItemDiv" v-if="contentItem">
           <div class="contentItemTitleTitleRow">
             <div class="contentItemTitle">{{ contentItem.name }}</div>
             <div v-if="contentItem.isNeedStudyToday" class="contentItemstates">
@@ -67,7 +67,7 @@ export default {
   },
   computed: {},
   created() {
-    this.getContentList();
+    this.getNewsfeed();
     this.checkTodabTag();
   },
   mounted() {},
@@ -79,18 +79,12 @@ export default {
       console.log(todayStr);
     },
     //   查询子目录
-    getContentList() {
-      let path = {
-        categoryId: "6083ece7a05c7856f139a001"
-      };
+    getNewsfeed() {
       this.$_http
-        .get(
-          this.$pathParams(
-            this.$_API.JTXT_GET_CATEGORIES_CATEGROYID_MATERIALS,
-            path
-          )
-        )
+        .get(this.$_API.JTXT_GET_NEWSFEED)
         .then(res => {
+          console.log("--newsfeed-");
+          console.log(res);
           this.formatNeedStudyTodayFun(res.data);
           this.finished = true;
         })
@@ -100,9 +94,8 @@ export default {
     },
     // 判断是否今日必学
     formatNeedStudyTodayFun(datas) {
-      console.log("222222", datas);
       datas.forEach(item => {
-        if (item.tags.length > 0) {
+        if (item && item.tags.length > 0) {
           item.isNeedStudyToday = true;
         }
       });