Browse Source

我的课程

he2802 3 years ago
parent
commit
1ff58b5dd0

+ 7 - 1
common/httpList/goods.js

@@ -10,13 +10,19 @@ export default {
 			noToken: true
 		})
 	},
-	goodsDetail(data) {
+	commonGoodsDetail(data) {
 		return myRequest({
 			url: '/app/common/goods/'+ data,
 			method: 'get',
 			noToken: true
 		})
 	},
+	goodsDetail(data) {
+		return myRequest({
+			url: '/goods/'+ data,
+			method: 'get'
+		})
+	},
 	goodsCourseList(data) {
 		return myRequest({
 			url: '/app/common/goods/course/list/'+ data,

+ 9 - 1
components/course/courseChapter.vue

@@ -7,7 +7,7 @@
 		</view>
 		<view v-if="!down">
 			<view v-for="(itemM,indexM) in list" >
-				<courseSection :isBuy="isBuy" :menuItem="itemM"></courseSection>
+				<courseSection :isBuy="isBuy" :isRebuild="isRebuild" :menuItem="itemM" :levelId="levelId+'-'+itemM.sectionId"></courseSection>
 				<u-line v-if="indexM<list.length-1"></u-line>
 			</view>
 		</view>
@@ -27,6 +27,14 @@ export default {
 		isBuy: {
 			type: Boolean,
 			default: false
+		},
+		levelId: {
+			type: String,
+			default: ""
+		},
+		isRebuild: {
+			type: Boolean,
+			default: false
 		}
 	},
 	components: {

+ 9 - 1
components/course/courseModule.vue

@@ -7,7 +7,7 @@
 		</view>
 		<view v-if="!down">
 			<view v-for="(itemM,indexM) in list" >
-				<courseChapter :isBuy="isBuy"  :menuItem="itemM"></courseChapter>
+				<courseChapter :isBuy="isBuy" :isRebuild="isRebuild"  :menuItem="itemM" :levelId="levelId+'-'+itemM.chapterId"></courseChapter>
 				<u-line v-if="indexM<list.length-1"></u-line>
 			</view>
 		</view>
@@ -26,6 +26,14 @@ export default {
 		isBuy: {
 			type: Boolean,
 			default: false
+		},
+		levelId: {
+			type: String,
+			default: ""
+		},
+		isRebuild: {
+			type: Boolean,
+			default: false
 		}
 	},
 	components: {

+ 9 - 0
components/course/courseSection.vue

@@ -41,6 +41,14 @@ export default {
 		isBuy: {
 			type: Boolean,
 			default: false
+		},
+		levelId: {
+			type: String,
+			default: ""
+		},
+		isRebuild: {
+			type: Boolean,
+			default: false
 		}
 	},
 	data() {
@@ -81,6 +89,7 @@ export default {
 			this.$store.commit('setPlaySectionId', {playSectionId  :this.newId});
 	//		return
 			eventHub.$emit('getSection', this.menuItem)
+			eventHub.$emit('levelId', this.levelId)
 			
 		}
 	},

+ 4 - 4
pages2/bank/detail.vue

@@ -5,7 +5,7 @@
 				<image :src="$method.splitImgHost(goodsData.coverUrl, true)" style="width: 100%;"></image>
 				<view style="padding:20rpx">
 					<view style="display: flex;margin-top: 13rpx;">
-						<view class="yearTag">{{goodsData.createTime | formatDate}}</view>
+						<view class="yearTag">{{goodsData.year}}</view>
 						<view class="titleTag">{{goodsData.goodsName}}</view>
 					</view>
 					<view style="display: flex;justify-content: space-between;margin-top: 13rpx;">
@@ -93,7 +93,7 @@
 			</view>
 		</view>
 		<view class="bottomBox">
-			<view class="priceTag">¥ 999.00</view>
+			<view class="priceTag">¥ {{goodsData.standPrice}}</view>
 			<view style="display: flex;color: #FFFFFF;align-items: center;">
 				<view class="btn1" @click="addCart">加购物车</view>
 				<view class="btn2" @click="buy">立即购买</view>
@@ -144,7 +144,7 @@ export default {
 	},
 	methods: {
 		getDetail(){
-			this.$api.goodsDetail(this.id).then(res => {
+			this.$api.commonGoodsDetail(this.id).then(res => {
 				console.log(res)
 				this.goodsData = res.data.data;
 				 
@@ -189,7 +189,7 @@ export default {
 			if(this.$method.isGoLogin()){
 				return
 			}
-			this.$navTo.togo('/pages2/order/confirm_list');
+			this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
 		},
 		addCart(){
 			if(this.$method.isGoLogin()){

+ 1 - 1
pages2/bank/question_detail.vue

@@ -135,7 +135,7 @@ export default {
 	},
 	methods: {
 		getDetail(){
-			this.$api.goodsDetail(this.id).then(res => {
+			this.$api.commonGoodsDetail(this.id).then(res => {
 				console.log(res)
 				this.goodsData = res.data.data;
 				 

+ 90 - 48
pages2/class/detail.vue

@@ -33,9 +33,9 @@
 				</u-row>
 			</view>
 			<u-line color="#D6D6DB" />
-			<view>
-				<view style="width: 240px;margin: 0 auto;">
-					<u-tabs :list="list" item-width="150" font-size="24" bar-width="80" :current="current" @change="change" active-color="#007AFF"></u-tabs>
+			<view style="display: flex;justify-content: center;">
+				<view style="width: 280px;">
+					<u-tabs :list="list"  font-size="24" bar-width="80" :current="current" @change="change" active-color="#007AFF"></u-tabs>
 				</view>
 			</view>
 			<u-line color="#D6D6DB" />
@@ -43,17 +43,28 @@
 		<view class="box">
 			<!--目录 -->
 			<view v-show="current == 0">
+				<view class="menuBox" v-for="(item, index) in reMenuList">
+					<!--模块 -->
+					<view v-if="item.type == 1"><courseModule :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
+					<!--章 -->
+					<view v-if="item.type == 2"><courseChapter :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-'+item.menuId"></courseChapter></view>
+					<!--节 -->
+					<view v-if="item.type == 3"><courseSection :isRebuild="true" :isBuy="true" :menuItem="item" :levelId="'0-0-'+item.menuId"></courseSection></view>
+				</view>
+			</view>
+			<!--目录 -->
+			<view v-show="current == 1">
 				<view class="menuBox" v-for="(item, index) in menuList">
 					<!--模块 -->
-					<view v-if="item.type == 1"><courseModule :isBuy="true" :menuItem="item"></courseModule></view>
+					<view v-if="item.type == 1"><courseModule :isBuy="true" :menuItem="item" :levelId="item.menuId"></courseModule></view>
 					<!--章 -->
-					<view v-if="item.type == 2"><courseChapter :isBuy="true" :menuItem="item"></courseChapter></view>
+					<view v-if="item.type == 2"><courseChapter :isBuy="true" :menuItem="item" :levelId="'0-'+item.menuId"></courseChapter></view>
 					<!--节 -->
-					<view v-if="item.type == 3"><courseSection :isBuy="true" :menuItem="item"></courseSection></view>
+					<view v-if="item.type == 3"><courseSection :isBuy="true" :menuItem="item" :levelId="'0-0-'+item.menuId"></courseSection></view>
 				</view>
 			</view>
 			<!--笔记 -->
-			<view v-show="current == 1">
+			<view v-show="current == 2">
 				<view class="inputBottom">
 					<view style="width: 10%;"><image src="/static/icon/note3.png" style="width: 39rpx;height: 39rpx;margin:0 29rpx;"></image></view>
 					<view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;">
@@ -81,7 +92,7 @@
 				</view>
 			</view>
 			<!--答疑 -->
-			<view v-show="current == 2">
+			<view v-show="current == 3">
 				<view class="inputBottom">
 					<view style="width: 73%;height: 88rpx;margin-bottom: 15rpx;margin-left: 10% ;">
 						<u-input height="78" fixed="true" placeholder="您可以在这里输入答疑内容" type="textarea" :custom-style="inputStyle" v-model="value" />
@@ -156,6 +167,9 @@ export default {
 			},
 			playbackRate: [0.5, 0.8, 1.0],
 			list: [
+				{
+					name: '重修目录'
+				},
 				{
 					name: '目录'
 				},
@@ -167,34 +181,8 @@ export default {
 				}
 			],
 			menuList: [
-				{
-					list: [
-						{
-							showChildren: false,
-							children: [1, 2, 3]
-						},
-						{
-							showChildren: false,
-							children: [1]
-						},
-						{
-							showChildren: false,
-							children: [1, 2]
-						}
-					],
-					type: 1
-				},
-				{
-					type: 2,
-					showChildren: false,
-					list: [{}, {}, {}]
-				},
-				{
-					type: 3,
-					list: [{}, {}]
-				}
 			],
-			current: 0,
+			current: 1,
 			vid:'',
 			goodsId:0,
 			goodsData:{},
@@ -211,7 +199,12 @@ export default {
 			currentTime:0,
 			avatarUrl:'',
 			ossAvatarUrl:'',
-			studyDuration:0 // 当前视频时长
+			studyDuration:0, // 当前视频时长
+			gradeId:0,
+			chapterId:0,
+			moduleId:0,
+			reMenuList: [
+			],
 			
 		};
 	},
@@ -223,8 +216,19 @@ export default {
 		this.courseDetail();
 		this.getMenuList();
 		this.getGoodsDetail()
+		
 	},
 	onShow() {},
+	onUnload() {
+		if(this.playSectionId>0){
+			//退出提交记录
+			this.ossAvatarUrl = ""
+			this.postStudyRecord()
+			//清除正在播放的节ID
+			this.$store.commit('setPlaySectionId', {playSectionId  :0});
+		}
+		
+	},
 	mounted() {
 		eventHub.$on('getSection', item => {
 			if(this.timer){
@@ -237,24 +241,34 @@ export default {
 			 }else{
 				 this.vid = item.recordingUrl
 			 }
-			
 			this.startStatus = true
 			this.startTime = 0
 		});
+		eventHub.$on('levelId', item => {
+			let arr = item.split('-')
+			//点击节获取的各层级ID
+			this.moduleId = arr[0]
+			this.chapterId = arr[1]
+			console.log(item,99)
+		});
 	},
 	methods: {
-		postStudyRecord() {
-			console.log("提交接口A")
+		postStudyRecord(status=0) {
 			let self = this;
 			let data = {
 				photo:self.ossAvatarUrl,
-				sectionId:self.playSectionId,
-				goodsId:self.goodsId,
-				courseId:self.courseId,
-				studyDuration:self.studyDuration,
-				status:0
+				sectionId:parseInt(self.playSectionId),
+				goodsId:parseInt(self.goodsId),
+				courseId:parseInt(self.courseId),
+				studyDuration:parseInt(self.studyDuration),
+				gradeId:parseInt(self.gradeId),
+				chapterId:parseInt(self.chapterId),
+				moduleId:parseInt(self.moduleId)
+			}
+			if(status>0){
+				data.status = status
 			}
-			console.log("提交接口")
+			console.log("提交接口",data)
 			this.$api.studyRecord(data).then(res => {
 				console.log(res)
 			});
@@ -357,7 +371,7 @@ export default {
 					}
 					//判断是否需要拍照
 					if(this.intervalTimeList.length>this.intervalTimeIndex){
-						let photoTime = parseInt(this.intervalTimeList[this.intervalTimeIndex]) * 60 //获取拍照秒数
+						let photoTime = Number(this.intervalTimeList[this.intervalTimeIndex]) * 60 //获取拍照秒数
 						if(photoTime<this.playTime){
 							//启动拍照
 							//暂停
@@ -379,9 +393,15 @@ export default {
 				this.timer = setInterval(this.timeEvent, 1500);//定时器
 			}
 			if (newstate.detail.newstate == 'pause') {
-				
+				//暂停提交记录
+				/* this.ossAvatarUrl = ""
+				this.postStudyRecord() */
+			}
+			if (newstate.detail.newstate == 'ended') {
+				this.ossAvatarUrl = ""
+				this.postStudyRecord(1)
 			}
-			console.log(newstate,35)
+			
 			
 		},
 		//拍照
@@ -391,6 +411,11 @@ export default {
 		async submit(){
 			const waitYS = await this.imageInfos();
 			this.postStudyRecord()//提交记录
+			//恢复播放
+			var polyvPlayerContext = this.selectComponent('#playerVideo');
+			if (polyvPlayerContext != null) {
+				polyvPlayerContext.play();
+			}
 			console.log(this.ossAvatarUrl,"拍照完成456")
 		},
 		//确认拍照
@@ -423,6 +448,8 @@ export default {
 			let self = this
 			this.$api.goodsDetail(this.goodsId).then(res => {
 				self.goodsData = res.data.data;
+				self.gradeId = self.goodsData.gradeId
+				self.getReMenuList() //获取重修目录
 				if(self.goodsData.goodsPlayConfig){
 					self.goodsPlayConfig = JSON.parse(self.goodsData.goodsPlayConfig);
 					if(self.goodsPlayConfig.autoPlay>0){
@@ -446,6 +473,20 @@ export default {
 		startVideo() {
 			this.startStatus = true;
 		},
+		getReMenuList() {
+			let self = this;
+			this.$api.menuList({ courseId: this.courseId,rebuild:1,gradeId:this.gradeId }).then(res => {
+				if (res.data.code == 200) {
+					for (let i = 0; i < res.data.rows.length; i++) {
+						let item = res.data.rows[i];
+						item.down = true;
+						item.id = item.menuId;
+						item.name = item.menuName;
+					}
+					self.reMenuList = res.data.rows;
+				}
+			});
+		},
 		getMenuList() {
 			let self = this;
 			this.$api.menuList({ courseId: this.courseId }).then(res => {
@@ -465,6 +506,7 @@ export default {
 			this.$api.courseDetail(this.courseId).then(res => {
 				if (res.data.code == 200) {
 					self.detail = res.data.data;
+					self.gradeId = self.detail.gradeId
 				}
 			});
 		},

+ 1 - 1
pages2/course/detail.vue

@@ -251,7 +251,7 @@ export default {
 		getDetail() {
 			let self = this
 			let sectionIdList = []
-			this.$api.goodsDetail(this.id).then(res => {
+			this.$api.commonGoodsDetail(this.id).then(res => {
 				if(res.data.code==200){
 					if(res.data.data.mobileDetailHtml){
 						res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi,'<img style="max-width:100%;"')

+ 1 - 1
pages2/order/confirm_list.vue

@@ -299,7 +299,7 @@ export default {
 		},
 		getDetail() {
 			let self = this
-			this.$api.goodsDetail(this.id).then(res => {
+			this.$api.commonGoodsDetail(this.id).then(res => {
 				if(res.data.code==200){
 					self.detail = res.data.data
 					self.getExamine(self.detail.projectId)