wangguoyu hai 4 meses
pai
achega
2484088046
Modificáronse 2 ficheiros con 65 adicións e 21 borrados
  1. 35 21
      pages/study/lookShipin.vue
  2. 30 0
      utils/cacheManager.js

+ 35 - 21
pages/study/lookShipin.vue

@@ -24,7 +24,7 @@
 		</view>
 		<uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
 			mask-background-color="rgba(255, 255, 255, 0.6);">
-			<view class="course-score-dialog">
+			<view :class="courseClass">
 				<view class="text-score">{{credit}}</view>
 				<view class="course-btn-box">
 					<view @click="goBack" class="return-btn"></view>
@@ -76,14 +76,16 @@
 				zhangId: '',
 				seekTime: '',
 				jieId: '',
+				courseClass: '',
 				shipinTitle: '',
 				cacheZhangInfo: {},
-				cacheCurrentZhangIndex:'',
+				cacheCurrentZhangIndex: '',
 				YouKeContent: '您当前是游客身份,登录后才能浏览内容,现在去登录?'
 			}
 		},
 		components: {
-			tipMiddleDialog,svipDialog
+			tipMiddleDialog,
+			svipDialog
 		},
 		onLoad(options) {
 			if (!cacheManager.get('auth')) {
@@ -116,9 +118,9 @@
 					toast('数据错误,缓存丢失/ jieId丢失')
 					return false
 				}
-				this.cacheCurrentZhangIndex =  cacheManager.get('auth').currentZhang
+				this.cacheCurrentZhangIndex = cacheManager.get('auth').currentZhang
 				this.cacheZhangInfo = cacheManager.get('zhangInfo')
-			
+
 				// let zhang = this.cacheZhangInfo.zhangList.find(zhang => zhang.zhangId == this.zhangId);
 				// if (!zhang) {
 				// 	return
@@ -134,18 +136,18 @@
 				this.videoId = this.pageData.videoId
 				this.jieName = this.pageData.jieName
 				this.credit = this.pageData.credit
-				this.progressMarkers = this.pageData.jiedianList||[]
+				this.progressMarkers = this.pageData.jiedianList || []
 				this.getLive(); //获取播放凭证
 			},
 			goNextZhang() {
 				let that = this
 				cacheManager.updateObject('auth', {
-					currentZhang:this.cacheCurrentZhangIndex+1
+					currentZhang: this.cacheCurrentZhangIndex + 1
 				})
 				this.cacheZhangInfo = cacheManager.get('zhangInfo')
-				let zhang = this.cacheZhangInfo.zhangList[this.cacheCurrentZhangIndex+1]
+				let zhang = this.cacheZhangInfo.zhangList[this.cacheCurrentZhangIndex + 1]
 				uni.redirectTo({
-					url: '/pages/study/lookShipin?jieId=' +  zhang.jieList[0].jieId
+					url: '/pages/study/lookShipin?jieId=' + zhang.jieList[0].jieId
 				})
 			},
 			playEnd(data) {
@@ -154,15 +156,24 @@
 				if (AuthCode == 'Visitor') {
 					return false
 				} else {
-					this.$refs.popupRef.open();
-					let req = {
-						credit: this.credit,
-						jieId: this.jieId,
 
-					}
-					videoWancheng(req).then(res => {
+					let currentJieData = cacheManager.getCurrentJieData('zhangInfo', this.cacheCurrentZhangIndex, this.jieId)
+					if (currentJieData.studyFlag == 1) {
+						// 学完一遍
+						this.courseClass = 'course-finish-dialog'
+						this.$refs.popupRef.open();
+					} else {
+						cacheManager.updateJieStatus('zhangInfo', this.cacheCurrentZhangIndex, this.jieId)
+						this.courseClass = 'course-score-dialog'
+						this.$refs.popupRef.open();
+						let req = {
+							credit: this.credit,
+							jieId: this.jieId,
+						}
+						videoWancheng(req).then(res => {
 
-					})
+						})
+					}
 				}
 
 			},
@@ -184,7 +195,8 @@
 					}
 					//	debugger
 					Number(this.jieId++)
-					let currentObject =this.cacheZhangInfo.zhangList[this.cacheCurrentZhangIndex].jieList.find(item => item.jieId == this.jieId);
+					let currentObject = this.cacheZhangInfo.zhangList[this.cacheCurrentZhangIndex].jieList.find(item =>
+						item.jieId == this.jieId);
 					this.pageData = {
 						...currentObject
 					}
@@ -238,12 +250,14 @@
 
 					})
 				}
-				
-		
+
+
 
 			},
-			svipConfirm(){
-				uni.redirectTo({ url: '/pages/pay/svip' })
+			svipConfirm() {
+				uni.redirectTo({
+					url: '/pages/pay/svip'
+				})
 			},
 			ykConfirm() {
 				uni.redirectTo({

+ 30 - 0
utils/cacheManager.js

@@ -42,6 +42,34 @@ const cacheManager = (function() {
 		  }
 		set(key, obj);
 	}
+	// 用于视频已经看完 修改状态
+	function updateJieStatus(key, index,currentJieId) {
+		let obj = get(key) || {};
+		// console.log('obj',obj);
+		// console.log('index',index);
+		// console.log('currentJieId',currentJieId);
+		for(let jie of obj.zhangList[index].jieList){
+			if(jie.jieId ==currentJieId){
+		//		console.log('jie',jie);
+				jie.studyFlag = 1
+				break
+			}
+		}
+		set(key, obj);
+	}
+	// 获得当前jie参数
+	function getCurrentJieData(key, index,currentJieId) {
+		let obj = get(key) || {};
+		// console.log('obj',obj);
+		// console.log('index',index);
+		// console.log('currentJieId',currentJieId);
+		for(let jie of obj.zhangList[index].jieList){
+			if(jie.jieId ==currentJieId){
+				return jie
+				break
+			}
+		}
+	}
 	function clearAll() {
 		const keys = uni.getStorageInfoSync().keys;
 		keys.forEach(key => {
@@ -88,6 +116,8 @@ const cacheManager = (function() {
 		set,
 		get,
 		remove,
+		updateJieStatus,
+		getCurrentJieData,
 		updateObject,
 		findArrayInObject,
 		clearAll