Browse Source

添加推荐页今日必学

aaa 4 years ago
parent
commit
e76efcbb1a
2 changed files with 14 additions and 33 deletions
  1. 2 27
      src/views/home/learn/page-learn-child.vue
  2. 12 6
      src/views/home/learn/page-learn.vue

+ 2 - 27
src/views/home/learn/page-learn-child.vue

@@ -19,23 +19,6 @@
           finished-text="没有更多了"
           @load="onLoad"
         >
-          <template v-if="isFirstGroup && tabIndex === 0">
-            <van-swipe
-              class="my-swipe"
-              :autoplay="3000"
-              indicator-color="white"
-            >
-              <van-swipe-item v-for="(item, index) in swiperList" :key="index">
-                <van-image
-                  width="100%"
-                  height="100%"
-                  fit="cover"
-                  :src="item.url"
-                  :show-error="true"
-                />
-              </van-swipe-item>
-            </van-swipe>
-          </template>
           <van-cell
             v-for="(contentItem, contentIndex) in contentList"
             :key="contentIndex"
@@ -44,9 +27,8 @@
             <div slot="default" class="contentItemDiv">
               <div class="contentItemTitleTitleRow">
                 <div class="contentItemTitle">{{ contentItem.name }}</div>
-                <!-- contentItem.isNeedStudyToday -->
                 <div
-                  v-if="isFirstGroup && tabIndex === 0"
+                  v-if="contentItem.isNeedStudyToday"
                   class="contentItemstates"
                 >
                   今日必学
@@ -56,7 +38,7 @@
                 <div class="contentItemDescriptionTime">
                   {{
                     formateDatesFun(contentItem.createdTime) ||
-                      contentItem.createdTime
+                    contentItem.createdTime
                   }}
                 </div>
                 <div class="contentItemDescriptionStudyNeedTime">
@@ -78,13 +60,6 @@ export default {
   name: "page-learn-child",
   components: {},
   props: {
-    // 是否第一个分组
-    isFirstGroup: {
-      type: Boolean,
-      default: false
-    },
-    // 轮播图的数据
-    swiperList: null,
     // 分组的数据列表
     learnChildList: {
       type: Array,

+ 12 - 6
src/views/home/learn/page-learn.vue

@@ -7,12 +7,10 @@
         :key="index"
         :title="item.name"
       >
-        <PageLearnChild
-          :isFirstGroup="index === 0"
-          :swiperList="swiperList"
-          :learnChildList="learnChildList"
-        >
+        <PageLearnChild v-if="index !== 0" :learnChildList="learnChildList">
         </PageLearnChild>
+        <PageLearnRecommend v-if="index === 0" :swiperList="swiperList">
+        </PageLearnRecommend>
       </van-tab>
     </van-tabs>
   </div>
@@ -24,6 +22,9 @@ export default {
   components: {
     PageLearnChild: resolve => {
       require(["./page-learn-child"], resolve);
+    },
+    PageLearnRecommend: resolve => {
+      require(["./page-learn-recommend"], resolve);
     }
   },
   data() {
@@ -56,7 +57,9 @@ export default {
       this.$_http
         .get(this.$_API.JTXT_GET_CATEGORIES)
         .then(res => {
-          this.learnRootList = res.data;
+          // 第一个添加推荐
+          this.learnRootList = [{ id: "0", name: "推荐", parentId: null }];
+          this.learnRootList = [...this.learnRootList, ...res.data];
           //   查询子目录
           this.getChildList();
         })
@@ -66,6 +69,9 @@ export default {
     },
     //   查询子目录
     getChildList() {
+      if (this.choosedRootIndex === 0) {
+        return;
+      }
       let path = {
         categoryId: this.learnRootList[this.choosedRootIndex].id
       };