ソースを参照

fix:扫码进来没有用户信息和切换课程提交记录

xuqiaoying 3 年 前
コミット
e86d2715ba

+ 4 - 0
components/course/courseChapter.vue

@@ -552,6 +552,7 @@ export default {
             }
           });
           self.list = res.data.data;
+          console.log('=============2', self.list)
         }
       });
     },
@@ -590,6 +591,7 @@ export default {
               }
             });
             self.list = res.data.data;
+            console.log('=============3', self.list)
           }
         });
     },
@@ -627,6 +629,8 @@ export default {
               }
             });
             self.list = res.data.data;
+            console.log('=============1', self.list)
+            this.$emit('sectionList', self.list)
           }
         });
     },

+ 3 - 2
components/course/courseSection.vue

@@ -150,7 +150,7 @@ export default {
 		console.log(this.playSectionId,'this.playSectionId')
 		console.log(this.isRebuild)
 		console.log(this.nextMenuItem,'nextMenuItem')
-		console.log(this.menuItem,'this.menuItem=======>',this.menuItem.liveStartTime, this.nowTime)
+		console.log(this.menuItem,'this.menuItem=======>',this.menuItem.recordingUrl, this.nowTime)
 		let moduleId = this.menuItem.moduleId || 0;
 		let chapterId = this.menuItem.chapterId || 0;
 		let sectionId = this.menuItem.sectionId || this.menuItem.menuId;
@@ -360,7 +360,7 @@ export default {
 			});
 		},
 		async playVideo() {
-			console.log('直播的课程:',this.menuItem)
+			console.log('直播的课程:',this.menuItem,this.menuItem.recordingUrl)
 			if(this.menuItem.sectionType==1 || this.menuItem.sectionType == 3){
 				//1录播 3回放
 				if(!this.isBuy){
@@ -373,6 +373,7 @@ export default {
 						this.$store.commit('setPlaySectionId', {playSectionId  :this.newId});
 						this.$store.commit('setPlayVID', {playVID  :this.menuItem.recordingUrl});
 						this.menuItem.courseId = this.courseId;
+						console.log('-----getSection-')
 						uni.$emit('getSection', this.menuItem)
 						return;
 					}

+ 3 - 1
pages/learn/index.vue

@@ -256,9 +256,11 @@
 								v-if="item.gradeStatus == 1 && item.status == 1 && (item.serviceEndTime > sysTime) && (item.serviceStartTime < sysTime) &&  (item.classEndTime && (item.classEndTime < sysTime)) && (item.periodStatus == 0 || item.periodStatus == -1) && item.studyCount > 0">
 							</template>
 							<view v-else class="exam_btns">
+								<!-- examApplyGoodsList.length -是判断是否关联指定学员 -->
 								<view class="box_appoint" v-if="item.applyStatus === 1 && !( sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime
 									 || (item.classStartTime && sysTime <= item.classStartTime) || (item.classEndTime && sysTime >= item.classEndTime) || 
-									 item.learningStatus == 2 || item.classStatus == 0 || (item.learningStatus == 3 && sysTime < item.learningTimeStart))"
+									 item.learningStatus == 2 || item.classStatus == 0 || (item.learningStatus == 3 && sysTime < item.learningTimeStart) || 
+									 !item.examApplyGoodsList.length)"
 									 @click="appointment(item,appoint)">
 									<view class="exam_word ones">预约考试</view>
 								</view>

+ 19 - 1
pages/webview/index.vue

@@ -62,6 +62,7 @@ export default {
     this.options = option
   },
   onShow() {
+    console.log('userInfo:', this.userInfo, this.$method.isGoLogin())
     if (this.$method.isGoLogin()) { // 扫二维码进来的没登录需要跳到登录页,登录后返回
       return;
     }
@@ -75,7 +76,14 @@ export default {
     }
     // 有a字段是标识是扫二维码进来的
     if (this.optObj.a == 1) {
-      this.getParam()
+      if (!this.userInfo) {
+        console.log('没有userInfo')
+        this.getInfo()
+      } else {
+        console.log('有userInfo')
+        this.getParam()
+      }
+      
     } else {
       this.url = decodeURIComponent(decodeURIComponent(this.options.url))
       console.log('小程序进来的url:', this.url)
@@ -96,6 +104,16 @@ export default {
 		...mapGetters(['userInfo']),
 	},
   methods: {
+    getInfo() {
+			// /app/user/getInfo 登录用户信息 // fromPlat来源平台 1小程序 2PC网站
+			this.$api.getInfo({ fromPlat: 1 }).then(res => {
+				if(res.data.code == 200){
+					this.$store.state.userInfo = res.data.data
+          console.log('this.userInfo', this.userInfo)
+          this.getParam()
+				}
+			})
+		},
     // 获取直播间跳转参数的接口
     getParam() {
       const { cid, gid, sid} = this.optObj

+ 1 - 1
pages2/register/bind.vue

@@ -85,7 +85,7 @@ export default {
 						}
 						
 						this.$method.setUuid(new Date().valueOf() + "")
-						that.$api.getInfo().then(resdata => {
+						that.$api.getInfo({ fromPlat: 1 }).then(resdata => {
 							if(resdata.data.code == 200){
 								that.$store.state.userInfo = resdata.data.data;
 							}

+ 1 - 1
pages2/register/register.vue

@@ -411,7 +411,7 @@ export default {
 													//信息完善,直接进入页面
 													uni.setStorageSync('user_account', res.data.data.user_account);
 													uni.setStorageSync('token', res.data.data.token);
-													that.$api.getInfo().then(resdata => {
+													that.$api.getInfo({ fromPlat: 1 }).then(resdata => {
 														if(resdata.data.code == 200){
 															that.$store.state.userInfo = resdata.data.data;
 															// if (this.scanCode) { // pc扫码进来登录成功

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

@@ -45,7 +45,7 @@
     }
   }
   .toggle_course {
-    width: 156rpx;
+    width: 230rpx;
     height: 56rpx;
     background: #F1F5F8;
     border-radius: 28rpx;
@@ -57,16 +57,11 @@
       height: 32rpx;
       margin-right: 4rpx;
     }
-    .toggle_name {
+    .toggle_name, .numbers {
       color: #4B4B4B;
       font-size: 24rpx;
     }
   }
-  .numbers {
-    color: #4B4B4B;
-    font-size: 24rpx;
-    margin-left: 8rpx;
-  }
 // 切换课程弹窗
 .popup_box {
     width: 100%;

+ 82 - 47
pages3/polyv/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"
@@ -94,8 +96,9 @@
             <view class="toggle_course" v-if="courseTotal > 1" @click="changeCourses()">
               <image class="img" src="/pages3/static/imgs/toggle.png" mode="widthFix"></image>
               <view class="toggle_name">切换课程</view>
+              <view class="numbers">共{{ courseTotal }}门</view>
             </view>
-            <view v-if="courseTotal > 1" class="numbers">共{{ courseTotal }}门</view>
+            
         </view>
       </view>
       <u-line color="#D6D6DB" />
@@ -159,6 +162,7 @@
                 :menuItem="item"
                 :levelId="'0-' + item.menuId"
                 :goodsType='1'
+                @sectionList='sectionList($event, index)'
               ></courseChapter
             ></view>
             <!--节 -->
@@ -718,45 +722,19 @@ export default {
     if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
       return;
     }
-    console.log('onShowonShowonShowonShow', this.courseId,)
     this.courseCourseList();
-    
   },
   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",
-					uuid:this.$method.getUuid()
-        })
-        .then((res) => {});
-    }
-    uni.removeStorageSync('current')
-    // websocket.sendMsg("delAction");
+    console.log('onUnloadonUnloadonUnload')
+    this.originUnload()
   },
   mounted() {
   },
   methods: {
     ...mapMutations(["updateChapterOpen","updateLiveLast"]),
+    sectionList(value) {
+      console.log('返回返回', value)
+    },
     // 新增微信公众号模板消息点击数据
     clickOfficial() {
       this.$http({
@@ -811,13 +789,13 @@ export default {
         url: '/study/record/getUserWatchLast',
         method: 'get',
         data: {
-          goodsId: this.goodsId
+          orderGoodsId: this.orderGoodsId,
         }
       }).then((res) => {
         if (res.data.code == 200) {
-          console.log('res.data', res.data)
           if (res.data.data && Object.keys(res.data.data).length) { //有最后一次看的录播的信息
             this.courseId = res.data.data.courseId
+            console.log('res.data', res.data, this.courseId)
             this.originOnShow()
             this.originMounted()
           } else {
@@ -843,7 +821,7 @@ export default {
           this.getAnswerList();
         }, 5000);
         let noteSecond = Number(this.option.noteSecond);
-        console.log('noteSecondnoteSecond:', noteSecond)
+        console.log('noteSecondnoteSecond:', noteSecond, this.option)
         if (noteSecond > 0) {
           //我的消息跳过来,播放节
           let item = {
@@ -868,9 +846,9 @@ export default {
     },
     // 原来的mouted内容
     originMounted() {
-      console.log('originMounted')
+      // console.log('originMounted')
       uni.$on("changeSection", (oldSectionId) => {
-        console.log(this.playVID);
+        console.log('originMounted->playVID:', this.playVID, oldSectionId);
           this.hasStart = false;
         this.photoConfig = false;
         this.photoIndex = 0;
@@ -885,13 +863,21 @@ export default {
         this.postStudyRecord(0, oldSectionId);
       });
       uni.$on("getSection", (item) => {
+        console.log('清除直播===',item, item.recordingUrl)
         //清除直播
           this.hasStart = false;
         this.isPlayRebuild = item.rebuild;
         this.photoConfig = false;
         this.photoIndex = 0;
         this.sectionItem = item;
+
+        this.moduleId = item.moduleId
+        this.chapterId = item.chapterId
+        
         this.$store.commit("setPlayChannelId", { playChannelId: 0 });
+        this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId });
+        console.log('清除直播节点胡:', this.moduleId,this.chapterId, this.playSectionId )
+        this.postStudyRecord(0)
         //获取拍照历史
         this.getPhotoLastRecord();
         this.playVideo(item);
@@ -903,19 +889,58 @@ export default {
         this.chapterId = arr[1];
       });
       uni.$on("getChannel", (item) => {
+        console.log('--->清除录播录播清除录播录播')
         //清除录播
           this.hasStart = false;
         this.$store.commit("setPlayVID", { playVID: null });
+
+        this.moduleId = item.moduleId
+        this.chapterId = item.chapterId
+        this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId });
         this.getPhotoLastRecord();
         this.playChannel(item);
         this.channelItem = item;
       });
       uni.$on("isRebuild", (item) => {
-        console.log(item);
+        // console.log(item);
         this.isRebuild = item;
       });
       this.updateChapterOpen(true);
     },
+    // 原来onUnload里面的内容
+    originUnload() {
+      console.log('playSectionId', this.playSectionId)
+      if (this.playSectionId > 0 && this.hasStart) {
+        //退出提交记录
+        console.log('退出提交记录sfhasdoufsou敖德萨所多')
+        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",
+            uuid:this.$method.getUuid()
+          })
+          .then((res) => {});
+      }
+      uni.removeStorageSync('current')
+      // websocket.sendMsg("delAction");
+    },
     changeCourses() {
       this.toggleCourseShow = true
     },
@@ -925,11 +950,15 @@ export default {
     // 进入学习
     jump(item, index) {
       console.log('item------>', item, item.goodsId, item.gradeId, item.courseId, item.orderGoodsId)
+      this.vid = ''
+      this.hasStart = true
+      this.originUnload()
+      // return
       this.reStart = false
       this.courseId = item.courseId
       this.gradeId = item.gradeId
       this.toggleCourseShow = false
-      // return
+      
       if (index == 0) {
         if (item.rebuild === 0) {
           //未重修
@@ -1124,21 +1153,25 @@ export default {
 				orderGoodsId:this.orderGoodsId,
 				courseId:this.courseId
 			}).then(res => {
-				console.log(res,'liveres')
 				this.updateLiveLast(res.data.data)
 			})
 		},
 		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) { //录播
           console.log('录播录播录播')
 					this.$store.commit("setPlaySectionId", { playSectionId: res.data.data.sectionId });
 					this.$store.commit("setPlayVID", { playVID: res.data.data.recordingUrl });
+
+          console.log('playVID:', this.playVID, '-', this.playSectionId, this.moduleId, this.chapterId)
 					this.sectionItem = res.data.data;
 						this.playVideo(res.data.data)
 					} else if(res.data.data.sectionType == 2) { //直播
@@ -1878,12 +1911,10 @@ export default {
       });
     },
     studyNotice() {
-      console.log('这里也点击了吗')
       this.noticeShow = true;
     },
     //播放笔记视频
     async playNoteVideo(item) {
-      console.log(item, "noteItem");
       if (this.timer) {
         clearInterval(this.timer);
       }
@@ -1892,6 +1923,7 @@ export default {
         var polyvPlayerContext = this.selectComponent("#playerVideo");
         polyvPlayerContext.changeVid(item.recordingUrl);
       } else {
+        
         this.vid = item.recordingUrl;
       }
       this.recordObj = { videoCurrentTime: item.noteSecond };
@@ -1904,17 +1936,18 @@ export default {
     },
     //正常播放视频
     async playVideo(item) {
-      console.log(item,'222', this.vid);
+      console.log(item.recordingUrl,'22222222', this.vid);
       if (this.timer) {
         clearInterval(this.timer);
       }
       if (this.vid) {
         //切换视频
         var polyvPlayerContext = this.selectComponent("#playerVideo");
-        polyvPlayerContext.changeVid(item.recordingUrl);
+        console.log('polyvPlayerContext', polyvPlayerContext)
+        polyvPlayerContext && polyvPlayerContext.changeVid(item.recordingUrl);
       } else {
         this.vid = item.recordingUrl;
-				
+				console.log('---------vid----', this.vid)
       }
       this.recordObj = null;
       this.recordObj = await this.getRecordLast();
@@ -2170,7 +2203,8 @@ export default {
         console.log(sectionId, "sectionId");
         data.status = status;
       }
-      console.log("提交接口", data);
+      console.log("提交接口", data, sectionId, self.chapterId, self.moduleId);
+      // return
       this.$api.studyRecord(data).then((res) => {
         if (res.data.code == 200) {
           if (status > 0) {
@@ -2388,6 +2422,7 @@ export default {
           this.needSeek = false;
           // 新增用户视频学习日志
           this.studyLog()
+          // 提交学习记录
         }
         //开始播放
         if (this.timer) {

+ 1 - 1
pages4/login/login.vue

@@ -326,7 +326,7 @@ export default {
 						if (res.data.code == 200) {
 							uni.setStorageSync('union_id', res.data.data.union_id);
 							uni.setStorageSync('token', res.data.data.token);
-							that.$api.getInfo().then(resdata => {
+							that.$api.getInfo({ fromPlat: 1 }).then(resdata => {
 								if(resdata.data.code == 200){
 									uni.navigateBack();
 									that.$store.state.userInfo = resdata.data.data;