浏览代码

章节增加状态

谢杰标 2 年之前
父节点
当前提交
c96fd38278
共有 3 个文件被更改,包括 122 次插入22 次删除
  1. 61 8
      components/course/courseChapter.vue
  2. 49 5
      components/course/courseModule.vue
  3. 12 9
      pages3/polyv/detail.vue

+ 61 - 8
components/course/courseChapter.vue

@@ -1,9 +1,18 @@
 <template>
   <view>
     <view class="title" @click="openChapter(menuItem)">
-      <u-icon name="arrow-down" color="#999" size="24" v-if="!down"></u-icon>
-      <u-icon name="arrow-right" color="#999" size="24" v-if="down"></u-icon>
-      <text class="menu_name">{{ menuItem.name }}</text>
+      <view>
+        <u-icon name="arrow-down" color="#999" size="24" v-if="!down"></u-icon>
+        <u-icon name="arrow-right" color="#999" size="24" v-if="down"></u-icon>
+        <text class="menu_name">{{ menuItem.name }}</text>
+      </view>
+
+      <view
+        class="title_status"
+        :class="['gre', 'blue', 'grey'][this.learnStatus + 1]"
+      >
+        {{ ["待学习", "学习中", "已学完"][this.learnStatus + 1] }}
+      </view>
     </view>
     <view v-show="!down">
       <view v-for="(itemM, indexM) in list" :key="indexM">
@@ -139,10 +148,11 @@ export default {
       type: Array,
       default: () => [],
     },
-    // sectionItem: { // 用户最后一次看的录播的信息
-    // 	type: Object,
-    // 	default: () => {}
-    // },
+    sectionItem: {
+      // 用户最后一次看的录播的信息
+      type: Object,
+      default: () => {},
+    },
   },
   components: {
     courseSection,
@@ -705,7 +715,32 @@ export default {
         });
     },
   },
-  computed: { ...mapGetters(["goodsAuditionConfigIdList", "chapterOpen"]) },
+  computed: {
+    ...mapGetters(["goodsAuditionConfigIdList", "chapterOpen"]),
+    learnStatus() {
+      // console.log(this.menuItem, "this.menuItem");
+      let { id, courseId, moduleId } = this.menuItem;
+      // console.log(this.menuItem, id, courseId, moduleId, "this.menuItem");
+      // console.log(this.sectionItem,)
+      if (
+        this.sectionItem.courseId == courseId &&
+        this.sectionItem.moduleId == (moduleId || 0) &&
+        this.sectionItem.chapterId == id
+      ) {
+        return 0;
+      }
+      const list = this.menuAllList.filter(
+        (e) =>
+          e.courseId == courseId &&
+          e.moduleId == (moduleId || 0) &&
+          e.chapterId == id
+      );
+      const isAllLearn = list.every((item) => {
+        return item.studyStatus == 1;
+      });
+      return isAllLearn ? 1 : -1;
+    },
+  },
 };
 </script>
 
@@ -759,6 +794,7 @@ export default {
   // margin-bottom: 30rpx;
   height: 78rpx;
   display: flex;
+  justify-content: space-between;
   align-items: center;
   border-bottom: 1rpx solid #eeeeee;
   .menu_name {
@@ -771,5 +807,22 @@ export default {
     text-overflow: ellipsis;
     margin-left: 8rpx;
   }
+  .title_status {
+    width: 80rpx;
+    height: 28rpx;
+    border-radius: 8rpx;
+    font-size: 20rpx;
+    color: #ffffff;
+    text-align: center;
+  }
+  .gre {
+    background: #34c759;
+  }
+  .blue {
+    background: #409eff;
+  }
+  .grey {
+    background: #909399;
+  }
 }
 </style>

+ 49 - 5
components/course/courseModule.vue

@@ -2,10 +2,18 @@
   <!-- style="margin: 20rpx 0;" -->
   <view>
     <view class="title" @click="openModule(menuItem)">
-      <text class="title_name" style="margin-left: 10rpx">{{
-        menuItem.name
-      }}</text>
-      <view>
+      <text class="title_name" style="margin-left: 10rpx"
+        >{{ menuItem.name }}
+      </text>
+
+      <view class="fl">
+        <view
+          class="title_status"
+          :class="['gre', 'blue', 'grey'][this.learnStatus + 1]"
+          style="margin-right: 20rpx"
+        >
+          {{ ["待学习", "学习中", "已学完"][this.learnStatus + 1] }}
+        </view>
         <image src="/static/icon/up.png" class="icon_up" v-if="down"></image>
         <image src="/static/icon/down.png" class="icon_up" v-if="!down"></image>
       </view>
@@ -31,6 +39,7 @@
           :menuItem="itemM"
           :levelId="levelId + '-' + itemM.chapterId"
           :menuAllList="menuAllList"
+          :sectionItem="sectionItem"
         >
         </courseChapter>
         <u-line v-if="indexM < list.length - 1"></u-line>
@@ -293,7 +302,25 @@ export default {
       }
     },
   },
-  computed: { ...mapGetters(["chapterOpen"]) },
+  computed: {
+    ...mapGetters(["chapterOpen"]),
+    learnStatus() {
+      let { id, courseId } = this.menuItem;
+      if (
+        this.sectionItem.courseId == courseId &&
+        this.sectionItem.moduleId == id
+      ) {
+        return 0;
+      }
+      const list = this.menuAllList.filter(
+        (e) => e.courseId == courseId && e.moduleId == id
+      );
+      const isAllLearn = list.every((item) => {
+        return item.studyStatus == 1;
+      });
+      return isAllLearn ? 1 : -1;
+    },
+  },
 };
 </script>
 
@@ -316,6 +343,23 @@ export default {
     width: 24rpx;
     height: 24rpx;
   }
+  .title_status {
+    width: 80rpx;
+    height: 28rpx;
+    border-radius: 8rpx;
+    font-size: 20rpx;
+    color: #ffffff;
+    text-align: center;
+  }
+  .gre {
+    background: #34c759;
+  }
+  .blue {
+    background: #409eff;
+  }
+  .grey {
+    background: #909399;
+  }
 }
 
 .examBox {

+ 12 - 9
pages3/polyv/detail.vue

@@ -188,7 +188,7 @@
                   :needOpen="sectionItem.moduleId == item.menuId"
                   :courseId="courseId"
                   :preItem="menuList[index - 1]"
-                  :learningOrder="businessData.goodsLearningOrder"
+                  :learningOrder="orderNum"
                   :goodsId="goodsId"
                   :gradeId="gradeId"
                   :isBuy="true"
@@ -209,7 +209,7 @@
                   :courseId="courseId"
                   :preItem="menuList[index - 1]"
                   @playEnd="sectionPlayEnd($event, index)"
-                  :learningOrder="businessData.goodsLearningOrder"
+                  :learningOrder="orderNum"
                   :goodsId="goodsId"
                   :gradeId="gradeId"
                   :isBuy="true"
@@ -217,6 +217,7 @@
                   :levelId="'0-' + item.menuId"
                   :goodsType="1"
                   :menuAllList="menuAllList"
+                  :sectionItem="sectionItem"
                 ></courseChapter
               ></view>
               <!--节 -->
@@ -229,7 +230,7 @@
                   @playEnd="sectionPlayEnd($event, index)"
                   :courseId="courseId"
                   :preItem="menuList[index - 1]"
-                  :learningOrder="businessData.goodsLearningOrder"
+                  :learningOrder="orderNum"
                   :goodsId="goodsId"
                   :gradeId="gradeId"
                   :isBuy="true"
@@ -367,7 +368,7 @@
                 :orderGoodsId="orderGoodsId"
                 :sectionMaxNum="goodsData.sectionMaxNum"
                 :courseId="courseId"
-                :learningOrder="businessData.goodsLearningOrder"
+                :learningOrder="orderNum"
                 :goodsId="goodsId"
                 :gradeId="gradeId"
                 :isRebuild="true"
@@ -384,7 +385,7 @@
               <courseChapter
                 :orderGoodsId="orderGoodsId"
                 :courseId="courseId"
-                :learningOrder="businessData.goodsLearningOrder"
+                :learningOrder="orderNum"
                 :sectionMaxNum="goodsData.sectionMaxNum"
                 @playEnd="sectionPlayEnd($event, index)"
                 :gradeId="gradeId"
@@ -402,7 +403,7 @@
               <courseSection
                 :orderGoodsId="orderGoodsId"
                 :courseId="courseId"
-                :learningOrder="businessData.goodsLearningOrder"
+                :learningOrder="orderNum"
                 :sectionMaxNum="goodsData.sectionMaxNum"
                 @playEnd="sectionPlayEnd($event, index)"
                 :gradeId="gradeId"
@@ -922,6 +923,9 @@ export default {
     playSecIsLearn() {
       return this.sectionItem.learning != 1;
     },
+    orderNum(){
+      return this.businessData.goodsLearningOrder
+    }
   },
   watch: {
     showSet(n) {
@@ -1414,7 +1418,7 @@ export default {
           }
         });
       } else {
-        if (this.businessData.goodsLearningOrder == 2) {
+        if (this.orderNum == 2) {
           //学习顺序是从头到尾学习,没学完上一课不能学习下一课
           let prevItem = this.courseList[index - 1]; //上一课
           if (prevItem.stuAllNum == prevItem.secAllNum) {
@@ -1703,13 +1707,12 @@ export default {
           } else {
             // if (
             //   data.learning == 1 &&
-            //   this.businessData.goodsLearningOrder == 2
+            //   this.orderNum == 2
             // ) {
             //   let next = this.menuAllList.find((e) => e.studyStatus != 1);
             //   next && (data = next);
             // }
           }
-          console.log(data,789)
           this.initPlayVideo(data);
           // if (res.data.data) {
           //   this.moduleId = res.data.data.moduleId;