ソースを参照

学习页添加科目刷选和直播课的课程切换

xuqiaoying 3 年 前
コミット
5e61edf176
4 ファイル変更158 行追加66 行削除
  1. 2 3
      pages2/exam/exam_appointment.vue
  2. 95 42
      pages3/live/detail.vue
  3. 29 2
      pages3/polyv/css/detail.scss
  4. 32 19
      pages3/polyv/detail.vue

+ 2 - 3
pages2/exam/exam_appointment.vue

@@ -217,13 +217,13 @@ export default {
 		if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
 			return;
 		}
+		this.setSystemTime()
 		if (String(this.paramCount)) {
 			console.log('公众号', this.paramCount)
 			this.current = +this.paramCount
 			this.change(+this.paramCount)
 			return
 		}
-		this.setSystemTime()
 		this.$api.getApplylist({ subscribeStatus: 1, exceedExamExpend: 2 }).then(res => {
 			if (res.data.code === 200) {
 				this.listData = res.data.rows;
@@ -352,8 +352,7 @@ export default {
 			// apply/list
 			this.$api.getApplylist(data).then(res => {
 				if (res.data.code === 200) {
-					// this.listData = res.data.rows;
-					this.listData = [1,2]
+					this.listData = res.data.rows;
 				}
 			});
 		}

+ 95 - 42
pages3/live/detail.vue

@@ -26,12 +26,14 @@
         ></image>
       </view>
       <view v-else>
+        <!-- v-if="playVID" -->
         <view
           class="video_box"
           style="width: 100%; height: 421rpx"
-          v-if="playVID"
+          
         >
           <polyv-player
+            v-if="playVID"
             id="playerVideo"
             playerId="playerVideo"
             height="421rpx"
@@ -92,8 +94,8 @@
             <view v-if="courseTotal > 1" class="toggle_course" @click="changeCourses()">
               <image class="img" src="/pages3/static/imgs/toggle.png"></image>
               <view class="toggle_name">切换课程</view>
+              <view class="numbers">共{{ courseTotal }}门</view>
             </view>
-            <view v-if="courseTotal > 1" class="numbers">共{{ courseTotal }}门</view>
         </view>
         <!-- <u-row>
           <u-col span="10">
@@ -563,10 +565,19 @@
 					    <u-icon name="close" color="#9C9C9C" size="40" @click="closePop()"></u-icon>
             </view>
             <view class="coruse_num">共{{ courseTotal }}门</view>
+            <view class="menuSel">
+              <scroll-view class="sub_sliper" scroll-x="true" >
+                <view v-for="(item,index) in subList" :key="index" style="margin-right: 50rpx;display:inline-block">
+                  <view class="r_t1" :class="{'nactive': subIndex == index}" @click="cMenu(item, index)">
+                    {{item.subjectName}}
+                  </view>
+                </view>
+              </scroll-view>
+            </view>
 				</view>
 				<view class="check_con">
 					<scroll-view scroll-y="true" style="height: 700rpx;">
-						<view class="course_items"  v-for="(item, index) in courseList" :key="index">
+						<view class="course_items"  v-for="(item, index) in s_courseList" :key="index">
                 <view class="course_lefts">
                   <view class="course_title">{{ item.courseName }}</view>
                   <!-- <view class="course_pros">
@@ -723,6 +734,9 @@ export default {
       courseTotal: 0,
       options: {},
       reStart: false, // 是否显示模块/章/节
+      s_courseList: [], // 筛选后的
+      subList: [],
+      subIndex: 0,
     };
   },
   computed: {
@@ -757,33 +771,7 @@ export default {
 		// this.getbaseprofiletplists();    
   },
   onUnload() {
-    if (this.playSectionId > 0 && this.hasStart) {
-      //退出提交记录
-      this.postStudyRecord();
-    }
-    //清除正在播放的节ID
-		// this.$store.commit('setPlayObj',null)
-    this.$store.commit("setPlaySectionId", { playSectionId: 0 });
-    this.$store.commit("setPlayChannelId", { playChannelId: 0 });
-    this.$store.commit("setPlayVID", { playVID: null });
-    this.closePlv();
-    // console.log("onUnload");
-    //移除所有的事件监听器
-    uni.$off();
-    clearInterval(this.answerTimer);
-    if (this.timer) {
-      clearInterval(this.timer);
-    }
-    // console.log(this.lockTimer, "this.lockTimer");
-    if (this.lockTimer) {
-      clearInterval(this.lockTimer);
-      this.$api
-        .lockDelLock({
-          action: "jxjy",
-        })
-        .then((res) => {});
-    }
-    // websocket.sendMsg("delAction");
+    this.originUnload()
   },
   mounted() {
   },
@@ -800,9 +788,17 @@ export default {
           console.log('埋点')
         }
       })
+    },
+     // 点击课程目录
+    cMenu(item, index) {
+      this.subIndex = index
+      if (item.subjectId != 0) {
+        this.s_courseList = this.courseList.filter((e) => e.subjectId == item.subjectId)
+      } else {
+        this.s_courseList = this.courseList
+      }
     },
     courseCourseList() {
-      console.log('ahhhhhhh直播hhhhhh')
       this.courseList = []
       this.$api.courseCourseList({
         pageNum: 1,
@@ -814,10 +810,22 @@ export default {
         if (res.data.code == 200) {
           this.courseList.push.apply(this.courseList, res.data.rows)
           this.courseTotal = res.data.total || 0
+
+          this.s_courseList = this.courseList
+          let allItem = [{ subjectId: 0, subjectName: '所有'}]
+          let ids = []
+          const newArr = []
+          this.courseList.forEach(item => {
+            if (ids.indexOf(item.subjectId) == -1) {
+              ids.push(item.subjectId)
+              newArr.push(item)
+            }
+          })
+					this.subList = [...allItem, ...newArr]
+
           if(res.data.total > 1) {
             this.getUserWatchLast()
           } else if(res.data.total == 1) {
-            console.log('111->this.courseId', this.courseId)
             this.originOnShow()
             this.originOnMount()
           }
@@ -845,6 +853,7 @@ export default {
         }
       })
     },
+    // 原来onshow里面的内容
     originOnShow() {
       this.updateLiveLast(null)
       this.courseDetail();
@@ -867,7 +876,7 @@ export default {
         let playNextId = `moduleId${option.moduleId}chapterId${
           option.chapterId
         }sectionId${option.sectionId}${option.isRebuild ? "isRebuild" : ""}`;
-        this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId });
+        this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId || item.menuId });
         this.$store.commit("setPlayVID", { playVID: item.recordingUrl });
         this.$store.commit("updatePlayNextId", playNextId);
         // console.log("this.playNoteVideo");
@@ -877,6 +886,7 @@ export default {
         this.studyRecordQueryLiveLast();
       }
     },
+    // 原来的mouted内容
     originOnMount() {
       uni.$on("changeSection", (oldSectionId) => {
         // console.log(this.playVID);
@@ -901,7 +911,11 @@ export default {
         this.photoConfig = false;
         this.photoIndex = 0;
         this.sectionItem = item;
+        this.moduleId = item.moduleId || null
+        this.chapterId = item.chapterId || null
         this.$store.commit("setPlayChannelId", { playChannelId: 0 });
+        this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId || item.menuId });
+        console.log('清除直播节点胡:', this.moduleId,this.chapterId, this.playSectionId )
         //获取拍照历史
         this.getPhotoLastRecord();
         this.polyvLiveHistoryChatMsgList();
@@ -917,6 +931,10 @@ export default {
         //清除录播
           this.hasStart = false;
         this.$store.commit("setPlayVID", { playVID: null });
+
+        this.moduleId = item.moduleId
+        this.chapterId = item.chapterId
+        this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId || item.menuId });
         this.getPhotoLastRecord();
         this.playChannel(item);
         this.channelItem = item;
@@ -927,6 +945,36 @@ export default {
       });
       this.updateChapterOpen(true);
     },
+    // 原来onUnload里面的内容
+    originUnload() {
+      if (this.playSectionId > 0 && this.hasStart) {
+        //退出提交记录
+        this.postStudyRecord();
+      }
+      //清除正在播放的节ID
+      // this.$store.commit('setPlayObj',null)
+      this.$store.commit("setPlaySectionId", { playSectionId: 0 });
+      this.$store.commit("setPlayChannelId", { playChannelId: 0 });
+      this.$store.commit("setPlayVID", { playVID: null });
+      this.closePlv();
+      // console.log("onUnload");
+      //移除所有的事件监听器
+      uni.$off();
+      clearInterval(this.answerTimer);
+      if (this.timer) {
+        clearInterval(this.timer);
+      }
+      // console.log(this.lockTimer, "this.lockTimer");
+      if (this.lockTimer) {
+        clearInterval(this.lockTimer);
+        this.$api
+          .lockDelLock({
+            action: "jxjy",
+          })
+          .then((res) => {});
+      }
+      // websocket.sendMsg("delAction");
+    },
     changeCourses() {
       this.toggleCourseShow = true
     },
@@ -934,7 +982,10 @@ export default {
       this.toggleCourseShow = false
     },
     // 进入学习
-    jump(item, index) {
+    async jump(item, index) {
+      this.vid = ''
+      this.hasStart = true
+      await this.originUnload()
       this.courseId = item.courseId
       this.reStart = false
       this.toggleCourseShow = false
@@ -960,12 +1011,15 @@ export default {
 		 * 获取最后一次看的节
 		 */
 		studyRecordQueryLiveLast() {
+      // /study/record/queryLiveLast
 			this.$api.studyRecordQueryLiveLast({
 				orderGoodsId:this.orderGoodsId,
 				courseId:this.courseId
 			}).then(res => {
 				console.log(res,'couse')
 				if(res.data.data) {
+          this.moduleId = res.data.data.moduleId
+          this.chapterId = res.data.data.chapterId
 					if(res.data.data.sectionType == 1) { //录播
 					this.$store.commit("setPlaySectionId", { playSectionId: res.data.data.sectionId });
 					this.$store.commit("setPlayVID", { playVID: res.data.data.recordingUrl });
@@ -1459,7 +1513,6 @@ export default {
     async playVideo(item) {
       console.log(item);
       if (item.sectionType == 3) { // 回放的不播放
-        console.log('回放的不播放')
         return
       }
       if (this.timer) {
@@ -1476,10 +1529,11 @@ export default {
       }
       this.recordObj = null;
       this.recordObj = await this.getRecordLast();
+      console.log('this.recordObj:', this.recordObj)
       this.needSeek = true; //跳转到播放记录
       this.startStatus = true;
-      console.log('3333333333333')
-
+      // 提交学习记录
+      this.postStudyRecord(0)
       //获取节笔记
       this.getNoteList();
     },
@@ -1508,7 +1562,7 @@ export default {
         console.log("即将跳到笔记位置1");
         this.$u.toast("即将跳到笔记位置");
         this.$store.commit("setPlaySectionId", {
-          playSectionId: item.sectionId,
+          playSectionId: item.sectionId || item.menuId,
         });
         this.$store.commit("setPlayVID", { playVID: item.recordingUrl });
         this.playNoteVideo(item);
@@ -1673,7 +1727,7 @@ export default {
       let data = {
         fromPlat: 1, //来源平台 1小程序 2网站	
         photo: self.ossAvatarUrl,
-        sectionId: parseInt(sectionId),
+        sectionId: sectionId || 0,
         goodsId: parseInt(self.goodsId),
         courseId: parseInt(self.courseId),
 				orderGoodsId: this.orderGoodsId,
@@ -1681,14 +1735,13 @@ export default {
           PlayDuration > 0 ? PlayDuration : self.studyDuration
         ),
         gradeId: parseInt(self.gradeId),
-        chapterId: parseInt(self.chapterId),
-        moduleId: parseInt(self.moduleId),
+        chapterId: this.chapterId || 0,
+        moduleId: this.moduleId || 0,
         videoCurrentTime: parseInt(
           currentTime > 0 ? currentTime : self.studyDuration
         ),
       };
       if (status > 0) {
-        console.log(sectionId, "sectionId");
         data.status = status;
       }
       console.log("提交接口", data);

+ 29 - 2
pages3/polyv/css/detail.scss

@@ -68,7 +68,7 @@
     height: 938rpx;
     padding: 56rpx 56rpx 0rpx;
     .check_head {
-      height: 190rpx;
+      height: 200rpx;
       border-bottom: 2rpx solid #F0F0F0;
     }
     .headers {
@@ -89,10 +89,37 @@
     }
     .menuSel {
       width: 100%;
-      // height: 100rpx;
+      height: 58rpx;
       white-space:nowrap;
       overflow: hidden;
       margin-top: 40rpx;
+      .r_t1 {
+        font-size: 28rpx;
+        font-weight: 400;
+        color: #969696;
+      }
+      .sub_sliper {
+        width: 100%;
+        height: 100%;
+      }
+      .nactive {
+        font-size: 32rpx;
+        font-weight: bold;
+        color: #222222;
+        position: relative;
+        top: 0rpx;
+        left: 0rpx;
+        &::after {
+          content: '';
+          width: 32rpx;
+          height: 8rpx;
+          background: #498AFE;
+          border-radius: 180rpx;
+          position: absolute;
+          bottom: -15rpx;
+          left: 19rpx;
+        }
+      }
     }
     .course_items {
       width: 100%;

+ 32 - 19
pages3/polyv/detail.vue

@@ -550,10 +550,9 @@
             </view>
             <view class="coruse_num">共{{ courseTotal }}门</view>
             <view class="menuSel">
-              <scroll-view class="r_sliper" scroll-x="true" >
-                <view v-for="(item,index) in subList" :key="index" style="margin-right: 20rpx;display:inline-block">
-                  <!-- :class="paramList[0].subjectId==item.id?'r_t1':'r_t2'"@click="cMenu(item.id)" -->
-                  <view class="r_t1" @click="cMenu(item)">
+              <scroll-view class="sub_sliper" scroll-x="true" >
+                <view v-for="(item,index) in subList" :key="index" style="margin-right: 50rpx;display:inline-block">
+                  <view class="r_t1" :class="{'nactive': subIndex == index}" @click="cMenu(item, index)">
                     {{item.subjectName}}
                   </view>
                 </view>
@@ -562,7 +561,7 @@
 				</view>
 				<view class="check_con">
 					<scroll-view scroll-y="true" style="height: 700rpx;">
-						<view class="course_items"  v-for="(item, index) in courseList" :key="index">
+						<view class="course_items"  v-for="(item, index) in s_courseList" :key="index">
                 <view class="course_lefts">
                   <view class="course_title">{{ item.courseName }}</view>
                   <view class="course_pros">
@@ -707,14 +706,15 @@ export default {
       courseList: [], // 课程列表
       courseTotal: 0,
       reStart: false, // 是否显示模块/章/节
-      subList: []
+      s_courseList: [], // 筛选后的
+      subList: [],
+      subIndex: 0,
     };
   },
   computed: {
     ...mapGetters(["userInfo", "playSectionId", "playChannelId", "playVID"]),
   },
   onLoad(option) {
-    console.log('onLoadonLoadonLoadonLoadonLoad-')
     this.courseId = Number(option.id) || '';
     this.goodsId = Number(option.goodsId);
     this.orderGoodsId = Number(option.orderGoodsId) || '';
@@ -731,18 +731,15 @@ export default {
     this.$store.getters.dictObj;
   },
   onShow() {
-    console.log('onShowonShowonShowv')
     if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
       return;
     }
     this.courseCourseList();
   },
   onUnload() {
-    console.log('onUnloadonUnloadonUnload')
     this.originUnload()
   },
   mounted() {
-    console.log('mountedmountedmountedmounted')
   },
   methods: {
     ...mapMutations(["updateChapterOpen","updateLiveLast"]),
@@ -761,8 +758,16 @@ export default {
         }
       })
     },
+    // 点击课程目录
+    cMenu(item, index) {
+      this.subIndex = index
+      if (item.subjectId != 0) {
+        this.s_courseList = this.courseList.filter((e) => e.subjectId == item.subjectId)
+      } else {
+        this.s_courseList = this.courseList
+      }
+    },
     courseCourseList() {
-      console.log('ahhhhh视频hhhhhhhh')
       // /course/courseList查询商品下的课程列表
       this.courseList = []
       this.menuList = []
@@ -775,11 +780,20 @@ export default {
       }).then((res) => {
         if (res.data.code == 200) {
           this.courseList.push.apply(this.courseList, res.data.rows)
-          // this.menuList.push.apply(this.courseList, res.data.rows)
-          let allItem = [{ subjectId: 0, subjectName: '所有'}]
-					this.subList = [...allItem, ...this.courseList]
-          console.log('this.subList:', this.subList)
+          this.s_courseList = this.courseList
           this.courseTotal = res.data.total || 0
+
+          let allItem = [{ subjectId: 0, subjectName: '所有'}]
+          let ids = []
+          const newArr = []
+          this.courseList.forEach(item => {
+            if (ids.indexOf(item.subjectId) == -1) {
+              ids.push(item.subjectId)
+              newArr.push(item)
+            }
+          })
+					this.subList = [...allItem, ...newArr]
+          
           if (res.data.rows.length) {
             this.courseBusiness(res.data.rows[0].businessId)
           }
@@ -864,7 +878,7 @@ export default {
     },
     // 原来的mouted内容
     originMounted() {
-      console.log('originMounted')
+      // console.log('originMounted')
       uni.$on("changeSection", (oldSectionId) => {
         console.log('originMounted->playVID:', this.playVID, oldSectionId);
           this.hasStart = false;
@@ -893,8 +907,7 @@ export default {
         
         this.$store.commit("setPlayChannelId", { playChannelId: 0 });
         this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId || item.menuId });
-        console.log('清除直播节点胡:', this.moduleId,this.chapterId, this.playSectionId )
-        // this.postStudyRecord(0)
+        console.log('清除直播节点胡:', this.moduleId, this.chapterId, this.playSectionId )
         //获取拍照历史
         this.getPhotoLastRecord();
         this.playVideo(item);
@@ -2226,7 +2239,7 @@ export default {
       }
       console.log("提交接口:", data,'sectionId:', sectionId,'chapterId:', self.chapterId,'moduleId:', self.moduleId, 'courseId:', this.courseId);
       this.$api.studyRecord(data).then((res) => {
-        console.log('提交接口的结果:', res)
+        // console.log('提交接口的结果:', res)
         if (res.data.code == 200) {
           if (status > 0) {
             let moduleId = this.moduleId || 0;