瀏覽代碼

fix: 对接联调视频详情中答题、答题状态、获取答题积分模块

wenxingxing 2 天之前
父節點
當前提交
0279aef2f1

+ 20 - 0
api/course.js

@@ -316,4 +316,24 @@ let request = new Request().http
  export function addNewCommentApi(data) {
  export function addNewCommentApi(data) {
  	 return request('/store/app/course/comment/addComment',data,'POST','application/json;charset=UTF-8');
  	 return request('/store/app/course/comment/addComment',data,'POST','application/json;charset=UTF-8');
  }
  }
+ 
+//  新版-课程视频详情(含章节答题列表-题库内容)
+ export function newVideoDetailsApi(data) {
+ 	return request('/app/course/videoDetails', data, 'GET');
+ }
+
+//  新版-视频课程答题
+ export function newPublicCourseAnswerApi(data) {
+ 	return request('/app/course/publicCourseAnswer', data, 'POST','application/json;charset=UTF-8');
+ }
+
+//  新版-获取当前视频的答题状态
+ export function publicCourseAnswerStatusApi(data) {
+ 	return request('/app/course/publicCourseAnswer/status', data, 'GET');
+ }
+
+//  新版-答题成功后领取本节答题积分
+ export function publicCourseAnswerClaimIntegralApi(data) {
+ 	return request('/app/course/publicCourseAnswer/claimIntegral', data, 'POST','application/json;charset=UTF-8');
+ }
  
  

+ 2 - 2
common/request.js

@@ -3,8 +3,8 @@ export default class Request {
 	http(router, data = {}, method, contentType) {
 	http(router, data = {}, method, contentType) {
 		let that = this;
 		let that = this;
 		// let path2 = 'https://userapp.klbycp.com'; //百域承品
 		// let path2 = 'https://userapp.klbycp.com'; //百域承品
-	    let path = 'https://userapp.klbycp.com'; //百域承品
-	    // let path = 'http://vab6e976.natappfree.cc'; //百域承品
+	    // let path = 'https://userapp.klbycp.com'; //百域承品
+	    let path = 'http://vab6e976.natappfree.cc'; //百域承品
 		// let path2 = 'https://userapp.zkhj6.com';
 		// let path2 = 'https://userapp.zkhj6.com';
 		// let path = 'https://userapp.zkhj6.com';
 		// let path = 'https://userapp.zkhj6.com';
 		let token = uni.getStorageSync('AppToken');
 		let token = uni.getStorageSync('AppToken');

+ 3 - 2
pages/course/components/answerFloatBox.vue

@@ -16,7 +16,7 @@
 				<text>
 				<text>
 					<text v-if="remainSeconds > 0">再观看{{ formatTime(remainSeconds) }}\n</text>答题得奖励
 					<text v-if="remainSeconds > 0">再观看{{ formatTime(remainSeconds) }}\n</text>答题得奖励
 				</text>
 				</text>
-				<view v-if="remainSeconds <= 0" class="answerBtnClass" @tap="handleShowAnswerMethods">答题</view>
+				<view class="answerBtnClass" @tap="handleShowAnswerMethods">答题</view>
 			</view>
 			</view>
 		</view>
 		</view>
 	</view>
 	</view>
@@ -31,7 +31,7 @@ export default {
 		},
 		},
 		pointsNum: {
 		pointsNum: {
 			type: Number,
 			type: Number,
-			default: 20, //已得积分数量
+			default: 0, //已得积分数量
 		},
 		},
 		// 父组件传:剩余秒数
 		// 父组件传:剩余秒数
 		remainSeconds: {
 		remainSeconds: {
@@ -108,6 +108,7 @@ export default {
 }
 }
 
 
 .pointsOkTowTextClass {
 .pointsOkTowTextClass {
+	@include u-flex(column, center, center);
 	font-weight: 600;
 	font-weight: 600;
 	font-size: 32rpx;
 	font-size: 32rpx;
 	color: #FF2E3F;
 	color: #FF2E3F;

+ 96 - 92
pages/course/components/answerPromptPopup.vue

@@ -4,7 +4,7 @@
 			<template v-if="~~typeStatus === 1">
 			<template v-if="~~typeStatus === 1">
 				<view class="dialog-title">恭喜你,回答正确</view>
 				<view class="dialog-title">恭喜你,回答正确</view>
 				<view class="points-text">
 				<view class="points-text">
-					获得<text class="red-num">20</text>积分,自动到账
+					获得<text class="red-num">{{ pointsNum }}</text>积分,自动到账
 				</view>
 				</view>
 			</template>
 			</template>
 			<template v-if="~~typeStatus === 2">
 			<template v-if="~~typeStatus === 2">
@@ -23,110 +23,114 @@
 </template>
 </template>
 
 
 <script>
 <script>
-	export default {
-		props: {
-			isShow: {
-				type: Boolean,
-				default: false
-			},
-			typeStatus: {
-				type: Number,
-				default: 1, //提示类型:1、回答正确,2、回答错误,3、答题次数用完
-			}
+export default {
+	props: {
+		isShow: {
+			type: Boolean,
+			default: false
 		},
 		},
-		data() {
-			return {
-				showPopup: false,
-			}
+		typeStatus: {
+			type: Number,
+			default: 1, //提示类型:1、回答正确,2、回答错误,3、答题次数用完
 		},
 		},
-		watch: {
-			isShow(newVal) {
-				this.showPopup = newVal
-			}
-		},
-
-		methods: {
-			// 关闭弹框
-			close() {
-				this.$emit('closeMethod')
-			},
+		pointsNum: {
+			type: Number,
+			default: 0, // 积分数量
+		}
+	},
+	data() {
+		return {
+			showPopup: false,
+		}
+	},
+	watch: {
+		isShow(newVal) {
+			this.showPopup = newVal
 		}
 		}
+	},
+
+	methods: {
+		// 关闭弹框
+		close() {
+			this.$emit('closeMethod')
+		},
 	}
 	}
+}
 </script>
 </script>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>
-	@mixin u-flex($flexD, $alignI, $justifyC) {
-		display: flex;
-		flex-direction: $flexD;
-		align-items: $alignI;
-		justify-content: $justifyC;
-	}
+@mixin u-flex($flexD, $alignI, $justifyC) {
+	display: flex;
+	flex-direction: $flexD;
+	align-items: $alignI;
+	justify-content: $justifyC;
+}
 
 
-	.dialog-box {
-		width: calc(100vw - 160rpx);
-		min-height: 440rpx;
-		background: #ffffff;
-		border-radius: 30rpx;
-		padding: 40rpx 40rpx 60rpx;
-		box-sizing: border-box;
-		@include u-flex(column, center, center);
-	}
+.dialog-box {
+	width: calc(100vw - 160rpx);
+	min-height: 440rpx;
+	background: #ffffff;
+	border-radius: 30rpx;
+	padding: 40rpx 40rpx 60rpx;
+	box-sizing: border-box;
+	@include u-flex(column, center, center);
+}
 
 
-	/* 标题文字 */
-	.dialog-title {
-		font-weight: 600;
-		font-size: 40rpx;
-		color: #000000;
-		margin-bottom: 40rpx;
-	}
+/* 标题文字 */
+.dialog-title {
+	font-weight: 600;
+	font-size: 40rpx;
+	color: #000000;
+	margin-bottom: 40rpx;
+}
 
 
-	/* 积分文字行 */
-	.points-text {
-		font-weight: 600;
-		font-size: 36rpx;
-		color: rgba(0, 0, 0, 0.85);
-		line-height: 50rpx;
-		margin-bottom: 36rpx;
-	}
+/* 积分文字行 */
+.points-text {
+	font-weight: 600;
+	font-size: 36rpx;
+	color: rgba(0, 0, 0, 0.85);
+	line-height: 50rpx;
+	margin-bottom: 36rpx;
+}
 
 
-	/* 红色积分数字 */
-	.red-num {
-		font-weight: 600;
-		font-size: 56rpx;
-		color: #FF233C;
-	}
+/* 红色积分数字 */
+.red-num {
+	font-weight: 600;
+	font-size: 56rpx;
+	color: #FF233C;
+}
 
 
-	/* 底部灰色小字 */
-	.tips-text {
-		font-weight: 400;
-		font-size: 32rpx;
-		color: rgba(0, 0, 0, 0.65);
-		margin-bottom: 40rpx;
-	}
+/* 底部灰色小字 */
+.tips-text {
+	font-weight: 400;
+	font-size: 32rpx;
+	color: rgba(0, 0, 0, 0.65);
+	margin-bottom: 40rpx;
+}
 
 
-	/* 按钮通用样式 */
-	.btn {
-		width: 390rpx;
-		height: 84rpx;
-		line-height: 78rpx;
-		text-align: center;
-		font-size: 32rpx;
-		border-radius: 42rpx;
-		margin-bottom: 32rpx;
-		font-weight: 600;
-	}
+/* 按钮通用样式 */
+.btn {
+	width: 390rpx;
+	height: 84rpx;
+	line-height: 78rpx;
+	text-align: center;
+	font-size: 32rpx;
+	border-radius: 42rpx;
+	margin-bottom: 32rpx;
+	font-weight: 600;
+}
 
 
-	/* 红色实心主按钮 */
-	.primary-btn {
-		background: linear-gradient(135deg, #FF5267 0%, #FF233C 100%);
-		color: #ffffff;
-	}
+/* 红色实心主按钮 */
+.primary-btn {
+	background: linear-gradient(135deg, #FF5267 0%, #FF233C 100%);
+	color: #ffffff;
+}
 
 
-	/* 红色边框空心按钮 */
-	.outline-btn {
-		border: 2rpx solid #FF233C;
-		color: #FF233CFF;
-		background: transparent;
-		margin-bottom: 0;
-	}
+/* 红色边框空心按钮 */
+.outline-btn {
+	border: 2rpx solid #FF233C;
+	color: #FF233CFF;
+	background: transparent;
+	margin-bottom: 0;
+}
 </style>
 </style>

+ 224 - 208
pages/course/components/questionsPopup.vue

@@ -11,262 +11,278 @@
 				</view>
 				</view>
 			</view>
 			</view>
 			<scroll-view class="scroll-y" scroll-y>
 			<scroll-view class="scroll-y" scroll-y>
-				<view class="dataItemViewClass" v-for="(item,index) in quesList" :key="index">
+				<view class="dataItemViewClass" v-for="(item, index) in quesList" :key="index">
 					<view class="ques-title">
 					<view class="ques-title">
-						<text>{{index + 1}}.</text>
+						<text>{{ index + 1 }}.</text>
 						<!-- <view class="ques-type" v-show="item.type == 1 || item.type == 2">
 						<!-- <view class="ques-type" v-show="item.type == 1 || item.type == 2">
 						{{item.type == 1 ? '单选' : item.type == 2 ? '多选' : ''}}
 						{{item.type == 1 ? '单选' : item.type == 2 ? '多选' : ''}}
 					</view> -->
 					</view> -->
-						<text>{{item.title}}</text>
+						<text>{{ item.title }}</text>
 					</view>
 					</view>
-					<view :class="isAnswer(item,option.name) ?'ques-option ques-option-active':'ques-option'"
-						v-for="(option,idx) in item.questionOption" :key="idx" @tap="handleSelectAnswer(item,option)">
+					<view :class="isAnswer(item, option.name) ? 'ques-option ques-option-active' : 'ques-option'"
+						v-for="(option, idx) in item.question" :key="idx" @tap="handleSelectAnswer(item, option)">
 						<view>
 						<view>
-							{{numberToLetter(idx)}}.
+							{{ numberToLetter(idx) }}.
 						</view>
 						</view>
-						<view>{{option.name}}</view>
+						<view>{{ option.name }}</view>
 					</view>
 					</view>
 				</view>
 				</view>
-				<view class="empty" v-if="quesList.length==0">暂未设置题目~</view>
+				<view class="empty" v-if="quesList.length == 0">暂未设置题目~</view>
 			</scroll-view>
 			</scroll-view>
-			<view class="bottomBtnViewClass">
-				<view v-if="~~typeStatus === 1" :class="isOkAnswer ?'btnViewClass btnViewClass-active':'btnViewClass'"
-					@tap="isOkAnswer ? confirmAnswer():null">
+			<view v-if="quesList.length > 0" class="bottomBtnViewClass">
+				<view v-if="~~remainSeconds > 0" class="btnViewClass" @tap.stop="close">再观看{{ formatTime(remainSeconds)
+					}}可答题</view>
+				<view v-else :class="isOkAnswer ? 'btnViewClass btnViewClass-active' : 'btnViewClass'"
+					@tap="isOkAnswer ? confirmAnswer() : null">
 					提交答案</view>
 					提交答案</view>
-				<view v-if="~~typeStatus === 2" class="btnViewClass">再观看1分30秒可答题</view>
 			</view>
 			</view>
 		</view>
 		</view>
 	</u-popup>
 	</u-popup>
 </template>
 </template>
 
 
 <script>
 <script>
-	export default {
-		props: {
-			isShow: {
-				type: Boolean,
-				default: false
-			},
-			typeStatus: {
-				type: Number,
-				default: 1, //提交类型:1、可以提交答案,2、需再观看视频
-			}
+import {
+	newVideoDetailsApi
+} from '@/api/course'
+export default {
+	props: {
+		isShow: {
+			type: Boolean,
+			default: false
 		},
 		},
-		data() {
-			return {
-				showPopup: false,
-				quesList: [{
-					type: 1,
-					title: '《大美国医》药王级鹿茸粉单选特价供应货源还剩下不足多少盒?',
-					answer: '',
-					questionOption: [{
-							name: '800 盒'
-						},
-						{
-							name: '500 盒'
-						},
-						{
-							name: '1000 盒'
-						},
-						{
-							name: '1500 盒'
-						}
-					]
-				}],
-			}
+		typeStatus: {
+			type: Number,
+			default: 1, //提交类型:1、可以提交答案,2、需再观看视频
+		},
+		// 父组件传:剩余秒数
+		remainSeconds: {
+			type: Number,
+			default: 0
+		},
+		videoId: {
+			type: Number,
+			default: ''
 		},
 		},
-		computed: {
-			isOkAnswer() {
-				let newData = false
-				newData = !(this.quesList.map(item => item.answer).some(itemOne => itemOne == null || itemOne === ''))
-				return newData
-			},
-			isAnswer() {
-				return (item, name) => {
-					if (item.type == 1) {
-						return item.answer == name
-					} else if (item.type == 2) {
-						const array = item.answer.split(',')
-						return array.some(i => i == name)
-					} else {
-						return false
-					}
+	},
+	data() {
+		return {
+			showPopup: false,
+			quesList: [],
+		}
+	},
+	computed: {
+		isOkAnswer() {
+			let newData = false
+			newData = !(this.quesList.map(item => item.answer).some(itemOne => itemOne == null || itemOne === ''))
+			return newData
+		},
+		isAnswer() {
+			return (item, name) => {
+				if (item.type == 1) {
+					return item.answer == name
+				} else if (item.type == 2) {
+					const array = item.answer.split(',')
+					return array.some(i => i == name)
+				} else {
+					return false
 				}
 				}
 			}
 			}
+		}
+	},
+	watch: {
+		isShow(newVal) {
+			this.showPopup = newVal
+			if (newVal) {
+				this.getNewQuestionsList()
+			}
+		}
+	},
+
+	methods: {
+		// 获取新视频详情
+		async getNewQuestionsList() {
+			let res = await newVideoDetailsApi({
+				videoId: this.videoId
+			})
+			if (res.code == 200) {
+				this.quesList = res.data.questionBankList.length > 0 ? res.data.questionBankList.map(item => ({ ...item, question: JSON.parse(item.question) })) : []
+			}
 		},
 		},
-		watch: {
-			isShow(newVal) {
-				this.showPopup = newVal
+		// 秒数 → 分:秒 格式
+		formatTime(seconds) {
+			if (seconds <= 0) {
+				return '00分00秒'
 			}
 			}
+			const m = Math.floor(seconds / 60)
+			const s = seconds % 60
+			return `${m.toString().padStart(2, '0')}分${s.toString().padStart(2, '0')}秒`
 		},
 		},
-
-		methods: {
-			numberToLetter(num) {
-				// 将数字转换为字母的 ASCII 码
-				let letterCode = num + 65;
-				// 将 ASCII 码转换为大写字母
-				let letter = String.fromCharCode(letterCode);
-				return letter;
-			},
-			// 点击选择答案
-			handleSelectAnswer(item, option) {
-				if (item.type == 1) {
-					// 单选option
-					if (item.answer === option.name) {
-						item.answer = ''
-					} else {
-						item.answer = option.name
-					}
-				} else if (item.type == 2) {
-					// 多选
-					let answer = item.answer ? item.answer.split(',') : []
-					if (answer.indexOf(option.name) === -1) {
-						answer.push(option.name)
-						item.answer = answer.join(',')
-					} else {
-						answer.splice(answer.indexOf(option.name), 1)
-						item.answer = answer.join(',')
-					}
+		numberToLetter(num) {
+			// 将数字转换为字母的 ASCII 码
+			let letterCode = num + 65;
+			// 将 ASCII 码转换为大写字母
+			let letter = String.fromCharCode(letterCode);
+			return letter;
+		},
+		// 点击选择答案
+		handleSelectAnswer(item, option) {
+			if (item.type == 1) {
+				// 单选option
+				if (item.answer === option.name) {
+					item.answer = ''
+				} else {
+					item.answer = option.name
+				}
+			} else if (item.type == 2) {
+				// 多选
+				let answer = item.answer ? item.answer.split(',') : []
+				if (answer.indexOf(option.name) === -1) {
+					answer.push(option.name)
+					item.answer = answer.join(',')
+				} else {
+					answer.splice(answer.indexOf(option.name), 1)
+					item.answer = answer.join(',')
 				}
 				}
-			},
+			}
+		},
 
 
-			// 提交答案
-			confirmAnswer() {
-				this.$emit('submitAnswer', this.quesList)
-				this.close()
-			},
-			// 关闭弹框
-			close() {
-				this.$emit('closeMethod')
-			},
+		// 提交答案
+		confirmAnswer() {
+			this.$emit('submitAnswer', this.quesList)
 		},
 		},
-	}
+		// 关闭弹框
+		close() {
+			this.$emit('closeMethod')
+		},
+	},
+}
 </script>
 </script>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>
-	@mixin u-flex($flexD, $alignI, $justifyC) {
-		display: flex;
-		flex-direction: $flexD;
-		align-items: $alignI;
-		justify-content: $justifyC;
-	}
+@mixin u-flex($flexD, $alignI, $justifyC) {
+	display: flex;
+	flex-direction: $flexD;
+	align-items: $alignI;
+	justify-content: $justifyC;
+}
 
 
-	.empty {
-		@include u-flex(row, center, center);
-		padding: 24rpx 50rpx;
-		color: #999999;
-	}
+.empty {
+	@include u-flex(row, center, center);
+	padding: 24rpx 50rpx;
+	color: #999999;
+}
 
 
-	.scroll-y {
-		width: 100%;
-		height: calc(60vh - 300rpx)
-	}
+.scroll-y {
+	width: 100%;
+	height: calc(60vh - 300rpx)
+}
 
 
-	.quesTitleViewClass {
-		@include u-flex(row, center, space-between);
-		padding-bottom: 26rpx;
-		border-bottom: 2rpx solid #D8D8D8;
-		margin-bottom: 24rpx;
+.quesTitleViewClass {
+	@include u-flex(row, center, space-between);
+	padding-bottom: 26rpx;
+	border-bottom: 2rpx solid #D8D8D8;
+	margin-bottom: 24rpx;
 
 
-		.quesTitleLeftClass {
-			@include u-flex(row, center, center);
+	.quesTitleLeftClass {
+		@include u-flex(row, center, center);
 
 
-			image {
-				width: 28rpx;
-				height: 28rpx;
-				margin-right: 10rpx;
-			}
+		image {
+			width: 28rpx;
+			height: 28rpx;
+			margin-right: 10rpx;
+		}
 
 
-			.quesTitleTextClass {
-				font-weight: 600;
-				font-size: 36rpx;
-				color: #222222;
-			}
+		.quesTitleTextClass {
+			font-weight: 600;
+			font-size: 36rpx;
+			color: #222222;
 		}
 		}
 	}
 	}
+}
 
 
-	.ques-content {
-		width: 100vw;
-		height: 60vh;
-		background-color: #fff;
-		padding: 24rpx 24rpx 20rpx 32rpx;
-		box-sizing: border-box;
-		background: #FFFFFF;
-		border-radius: 30rpx 30rpx 0rpx 0rpx;
-		font-weight: 400;
-		font-size: 28rpx;
-		color: #222222;
-	}
+.ques-content {
+	width: 100vw;
+	height: 60vh;
+	background-color: #fff;
+	padding: 24rpx 24rpx 20rpx 32rpx;
+	box-sizing: border-box;
+	background: #FFFFFF;
+	border-radius: 30rpx 30rpx 0rpx 0rpx;
+	font-weight: 400;
+	font-size: 28rpx;
+	color: #222222;
+}
 
 
-	.dataItemViewClass {
-		width: 100%;
-		margin-bottom: 25rpx;
-	}
+.dataItemViewClass {
+	width: 100%;
+	margin-bottom: 25rpx;
+}
 
 
-	.ques-title {
-		font-weight: 600;
-		font-size: 40rpx;
-		margin-bottom: 24rpx;
-		color: rgba(0, 0, 0, 0.85);
-		white-space: normal;
-	}
+.ques-title {
+	font-weight: 600;
+	font-size: 40rpx;
+	margin-bottom: 24rpx;
+	color: rgba(0, 0, 0, 0.85);
+	white-space: normal;
+}
 
 
-	.ques-type {
-		flex-shrink: 0;
-		min-width: 72rpx;
-		min-height: 40rpx;
-		padding: 0 12rpx;
-		margin: 0 12rpx;
-		box-sizing: border-box;
-		background: #FF5C03;
-		border-radius: 8rpx 8rpx 8rpx 8rpx;
-		line-height: 40rpx;
-		text-align: center;
-		font-family: PingFang SC, PingFang SC;
-		font-weight: 400;
-		font-size: 24rpx;
-		color: #FFFFFF;
-		display: inline-block;
-	}
+.ques-type {
+	flex-shrink: 0;
+	min-width: 72rpx;
+	min-height: 40rpx;
+	padding: 0 12rpx;
+	margin: 0 12rpx;
+	box-sizing: border-box;
+	background: #FF5C03;
+	border-radius: 8rpx 8rpx 8rpx 8rpx;
+	line-height: 40rpx;
+	text-align: center;
+	font-family: PingFang SC, PingFang SC;
+	font-weight: 400;
+	font-size: 24rpx;
+	color: #FFFFFF;
+	display: inline-block;
+}
 
 
-	.ques-option {
-		min-height: 104rpx;
-		padding: 24rpx;
-		box-sizing: border-box;
-		margin-bottom: 24rpx;
-		background: #F5F7FAFF;
-		border-radius: 20rpx;
-		display: flex;
-		align-items: center;
-		font-weight: 400;
-		font-size: 40rpx;
-		color: rgba(0, 0, 0, 0.85);
+.ques-option {
+	min-height: 104rpx;
+	padding: 24rpx;
+	box-sizing: border-box;
+	margin-bottom: 24rpx;
+	background: #F5F7FAFF;
+	border-radius: 20rpx;
+	display: flex;
+	align-items: center;
+	font-weight: 400;
+	font-size: 40rpx;
+	color: rgba(0, 0, 0, 0.85);
 
 
-		&-active {
-			color: #FF233CFF !important;
-			background: #FFF0F1FF !important;
-		}
+	&-active {
+		color: #FF233CFF !important;
+		background: #FFF0F1FF !important;
 	}
 	}
+}
 
 
-	.bottomBtnViewClass {
-		width: 100%;
-		height: 160rpx;
-		@include u-flex(row, center, center);
+.bottomBtnViewClass {
+	width: 100%;
+	height: 160rpx;
+	@include u-flex(row, center, center);
 
 
-		.btnViewClass {
-			width: 630rpx;
-			height: 96rpx;
-			background: #00000040;
-			border-radius: 48rpx;
-			font-family: PingFangSC, PingFang SC;
-			font-weight: 600;
-			font-size: 40rpx;
-			color: #FFFFFF;
-			line-height: 90rpx;
-			text-align: center;
+	.btnViewClass {
+		width: 630rpx;
+		height: 96rpx;
+		background: #00000040;
+		border-radius: 48rpx;
+		font-family: PingFangSC, PingFang SC;
+		font-weight: 600;
+		font-size: 40rpx;
+		color: #FFFFFF;
+		line-height: 90rpx;
+		text-align: center;
 
 
-			&-active {
-				background: linear-gradient(135deg, #FF5267 0%, #FF233C 100%);
-			}
+		&-active {
+			background: linear-gradient(135deg, #FF5267 0%, #FF233C 100%);
 		}
 		}
 	}
 	}
+}
 </style>
 </style>

+ 95 - 94
pages/course/info.vue

@@ -291,7 +291,7 @@
 			</view>
 			</view>
 		</view>
 		</view>
 		<!-- h5下载 -->
 		<!-- h5下载 -->
-		<!-- <h5-down-app-tip :pageUrl="pageUrl" :type="'course'" :courseId="courseId" /> -->
+		<h5-down-app-tip :pageUrl="pageUrl" :type="'course'" :courseId="courseId" />
 
 
 		<!-- 分享弹窗 -->
 		<!-- 分享弹窗 -->
 		<u-popup :show="showShare" @close="closeShareAct()">
 		<u-popup :show="showShare" @close="closeShareAct()">
@@ -411,16 +411,18 @@
 		</popupBottom>
 		</popupBottom>
 
 
 		<!-- 右侧悬浮框 -->
 		<!-- 右侧悬浮框 -->
-		<answerFloatBox :typeNum="4" :remainSeconds="pageEntryRequiredTime" @handleShowAnswer="handleAnswerMethods"
-			@showTomorrowTipMethods="handleTomorrowTipMethods" />
+		<answerFloatBox v-if="pickCatalog && pickCatalog.videoId && isShowPageEntryTimer"
+			:typeNum="isShowPageEntryTimer" :pointsNum="answerPointsNum" :remainSeconds="pageEntryRequiredTime"
+			@handleShowAnswer="handleAnswerMethods" @showTomorrowTipMethods="handleTomorrowTipMethods" />
 
 
 		<!-- 答题弹窗 -->
 		<!-- 答题弹窗 -->
-		<questionsPopup :isShow="isShowQuestions" :typeStatus="1" @closeMethod="questionsCloseMethod"
+		<questionsPopup v-if="pickCatalog && pickCatalog.videoId && isShowPageEntryTimer" :isShow="isShowQuestions"
+			:remainSeconds="pageEntryRequiredTime" :videoId="pickCatalog.videoId" @closeMethod="questionsCloseMethod"
 			@submitAnswer="handleSubmitAnswer" />
 			@submitAnswer="handleSubmitAnswer" />
 
 
 		<!-- 答题提示框和明日再来提示框 -->
 		<!-- 答题提示框和明日再来提示框 -->
-		<answerPromptPopup :isShow="isShowAnswerPrompt" :typeStatus="answerPromptType"
-			@closeMethod="isShowAnswerPrompt = false" />
+		<answerPromptPopup v-if="pickCatalog && pickCatalog.videoId" :pointsNum="answerPointsNum"
+			:isShow="isShowAnswerPrompt" :typeStatus="answerPromptType" @closeMethod="isShowAnswerPrompt = false" />
 	</view>
 	</view>
 </template>
 </template>
 
 
@@ -449,7 +451,10 @@ import {
 	getComments,
 	getComments,
 	saveMsg,
 	saveMsg,
 	getNewCommentListApi,
 	getNewCommentListApi,
-	addNewCommentApi
+	addNewCommentApi,
+	newPublicCourseAnswerApi,
+	publicCourseAnswerStatusApi,
+	publicCourseAnswerClaimIntegralApi,
 } from '@/api/course'
 } from '@/api/course'
 import commentList from "./components/commentList.vue";
 import commentList from "./components/commentList.vue";
 import newCommentList from "./components/newCommentList.vue";
 import newCommentList from "./components/newCommentList.vue";
@@ -484,11 +489,12 @@ export default {
 			textHeight: 0, //文本高度
 			textHeight: 0, //文本高度
 			courseId: null,
 			courseId: null,
 			isShare: false,
 			isShare: false,
-			videoId: null,//当前视频(小节)章节ID
+			videoId: null,//当前视频(小节)章节ID(旧的,页面进入时带入的,后面没有更新,需要的话用pickCatalog.videoId来判断)
 			isLearning: false,
 			isLearning: false,
 			isShowQuestions: false,
 			isShowQuestions: false,
 			isShowAnswerPrompt: false,
 			isShowAnswerPrompt: false,
 			answerPromptType: 1,
 			answerPromptType: 1,
+			answerPointsNum: 0, // 答题获得的积分
 			inputComment: '',
 			inputComment: '',
 			newCommentArrList: [],
 			newCommentArrList: [],
 			data: {
 			data: {
@@ -620,7 +626,7 @@ export default {
 			// 页面一进入-答题奖励相关
 			// 页面一进入-答题奖励相关
 			pageEntryTimer: null, // 页面一进入-答题奖励计时器
 			pageEntryTimer: null, // 页面一进入-答题奖励计时器
 			pageEntryRequiredTime: 0, // 页面一进入-答题奖励当前小节后台设定的奖励时间(秒)(倒计时总时长)
 			pageEntryRequiredTime: 0, // 页面一进入-答题奖励当前小节后台设定的奖励时间(秒)(倒计时总时长)
-			hasGotPageEntryReward: false, // 页面一进入-答题奖励当前小节是否已领取奖励
+			hasGotPageEntryReward: 0, // 页面一进入-答题奖励当前小节是否已领取奖励-答题状态:1未答题 2可以答题 3达到上限 4已完成;-1学习缺失 -2无看课 -3未完课
 			isSocketOpen: false,
 			isSocketOpen: false,
 			isSend: true,
 			isSend: true,
 			reOpenSocket: false,
 			reOpenSocket: false,
@@ -635,6 +641,28 @@ export default {
 			},
 			},
 		}
 		}
 	},
 	},
+	computed: {
+		isShowPageEntryTimer() {
+			let newData = 0
+			if (this.hasGotPageEntryReward == 1) {
+				// 未答题
+				newData = 4
+			}
+			if (this.hasGotPageEntryReward == 2) {
+				// 答错了但未达上限- 可以答题
+				newData = 3
+			}
+			if (this.hasGotPageEntryReward == 3) {
+				// 答错了且达上限- 达到上限
+				newData = 2
+			}
+			if (this.hasGotPageEntryReward == 4) {
+				// 答对了获得积分- 已完成
+				newData = 1
+			}
+			return newData
+		}
+	},
 	onLoad(options) {
 	onLoad(options) {
 		this.courseId = options.courseId;
 		this.courseId = options.courseId;
 		this.isShare = options.isShare || false
 		this.isShare = options.isShare || false
@@ -772,15 +800,35 @@ export default {
 			this.isShowQuestions = false
 			this.isShowQuestions = false
 		},
 		},
 		// 点击提交答案后
 		// 点击提交答案后
-		handleSubmitAnswer() {
-			if (true) {
-				// 答对
-				this.answerPromptType = 1
-			} else {
-				// 答错
-				this.answerPromptType = 2
+		handleSubmitAnswer(quesList) {
+			let newData = quesList.map(item => ({ ...item, question: JSON.stringify(item.question) }));
+			let param = {
+				questions: newData,
+				videoId: this.pickCatalog.videoId,
+				courseId: this.courseId
 			}
 			}
-			this.isShowAnswerPrompt = true
+			newPublicCourseAnswerApi(param).then(res => {
+				this.questionsCloseMethod()
+				if (res.code == 200) {
+					if (res.msg == "答题成功") {
+						// 答对
+						this.answerPromptType = 1
+						this.handleClaimIntegralMethods()
+					} else {
+						// 答错
+						this.answerPromptType = 2
+					}
+					this.checkPageEntryStatus();
+					this.isShowAnswerPrompt = true
+				}
+			})
+		},
+
+		// 答题成功后领取本节答题积分
+		handleClaimIntegralMethods() {
+			publicCourseAnswerClaimIntegralApi({
+				videoId: this.pickCatalog.videoId,
+			})
 		},
 		},
 		// 点击提示明日再来
 		// 点击提示明日再来
 		handleTomorrowTipMethods() {
 		handleTomorrowTipMethods() {
@@ -837,92 +885,42 @@ export default {
 			}
 			}
 		},
 		},
 		// 检查章节奖励领取状态
 		// 检查章节奖励领取状态
-		checkPageEntryStatus(videoId) {
+		checkPageEntryStatus() {
+			this.hasGotPageEntryReward = 0;
 			// 检查该章节是否已领取章节奖励
 			// 检查该章节是否已领取章节奖励
-			this.hasGotPageEntryReward = false;
-			// 启动答题奖励计时器(需要先获取当前章节ID)
-			console.log('欧克111',this.pageEntryRequiredTime)
-			if (videoId && !this.hasGotPageEntryReward) {
-				this.startPageEntryTimer();
-			}
+			publicCourseAnswerStatusApi({
+				videoId: this.pickCatalog.videoId,
+				courseId: this.courseId
+			}).then(res => {
+				if (res.code == 200) {
+					this.hasGotPageEntryReward = Number(res.data.status);
+
+					// 启动答题奖励计时器(需要先获取当前章节ID)
+					if (this.pickCatalog.videoId && (this.hasGotPageEntryReward == 1 || this.hasGotPageEntryReward == 2)) {
+						this.startPageEntryTimer();
+					}
+				}
+			})
 		},
 		},
 		// 启动章节奖励计时器
 		// 启动章节奖励计时器
 		startPageEntryTimer() {
 		startPageEntryTimer() {
-			// 如果已领取章节奖励,不再计时
-			if (this.hasGotPageEntryReward) {
-				return;
-			}
-
 			// 启动前或切换章节都先重置计时
 			// 启动前或切换章节都先重置计时
-			this.resetPageEntryTimer();
-
-			// 如果章节奖励计时器已在运行,不再重复启动
-			if (this.pageEntryTimer) {
-				return;
-			}
-			console.log('欧克',this.pageEntryRequiredTime)
+			this.stopPageEntryTimer();
 			// 每秒计时
 			// 每秒计时
 			this.pageEntryTimer = setInterval(() => {
 			this.pageEntryTimer = setInterval(() => {
 				this.pageEntryRequiredTime--;
 				this.pageEntryRequiredTime--;
-				console.log(`当前章节奖励剩余计时: ${this.pageEntryRequiredTime}秒`);
-
-				// 检查是否满足章节奖励条件
-				this.checkPageEntryCondition();
+				if (this.pageEntryRequiredTime <= 0) {
+					this.stopPageEntryTimer();
+				}
 			}, 1000);
 			}, 1000);
 		},
 		},
-		// 检查章节奖励条件
-		checkPageEntryCondition() {
-			if (this.hasGotPageEntryReward) {
-				this.stopPageEntryTimer();
-				return;
-			}
-
-			if (this.pageEntryRequiredTime <= 0) {
-				// 满足条件,领取章节奖励
-				this.getPageEntryReward();
-			}
-		},
-		// 领取章节奖励
-		async getPageEntryReward() {
-			if (this.hasGotPageEntryReward) {
-				return;
-			}
-
-			// TODO: 调用后台领取章节奖励接口
-			try {
-				// const res = await getPageEntryApi({ videoId: this.videoId });
-				// if (res.code === 200) {
-				this.hasGotPageEntryReward = true;
-				this.stopPageEntryTimer();
-				uni.showToast({
-					title: '恭喜获得章节奖励!',
-					icon: 'success'
-				});
-				// } else {
-				//     uni.showToast({
-				//         title: res.msg || '领取失败',
-				//         icon: 'none'
-				//     });
-				// }
-			} catch (error) {
-				uni.showToast({
-					title: '领取失败',
-					icon: 'none'
-				});
-			}
-		},
-		// 停止章节奖励计时器
+		// 重置-停止-清除章节奖励计时器
 		stopPageEntryTimer() {
 		stopPageEntryTimer() {
 			if (this.pageEntryTimer) {
 			if (this.pageEntryTimer) {
 				clearInterval(this.pageEntryTimer);
 				clearInterval(this.pageEntryTimer);
 				this.pageEntryTimer = null;
 				this.pageEntryTimer = null;
 			}
 			}
 		},
 		},
-		// 重置章节奖励计时
-		resetPageEntryTimer() {
-			this.stopPageEntryTimer();
-			this.hasGotPageEntryReward = false;
-		},
 
 
 		getCourseInfo() {
 		getCourseInfo() {
 			this.showDes = false
 			this.showDes = false
@@ -979,6 +977,9 @@ export default {
 						//开始播放计时
 						//开始播放计时
 						if (this.data.isAutoPlay == 1) {
 						if (this.data.isAutoPlay == 1) {
 							this.pickCatalogMethod(this.pickCatalogIdx);
 							this.pickCatalogMethod(this.pickCatalogIdx);
+							setTimeout(() => {
+								this.addStudyCourse();
+							}, 1000);
 						}
 						}
 					}
 					}
 				}
 				}
@@ -1432,13 +1433,13 @@ export default {
 				type: type
 				type: type
 			});
 			});
 			this.pickCatalog = this.catalogueList[index];
 			this.pickCatalog = this.catalogueList[index];
-			console.log(6666, this.pickCatalog)
-			// 获取章节奖励所需时间
-			// this.pageEntryRequiredTime = Number(this.pickCatalog.watchDurationMinutes) * 60;
-			this.pageEntryRequiredTime = Number(0.5) * 60;
-			console.log(`倒计时目标: ${this.pageEntryRequiredTime}秒`)
-			// 同时检查该章节是否已领取章节奖励
-			this.checkPageEntryStatus(this.pickCatalog.videoId);
+
+			// 获取章节看视频答题奖励后所得积分
+			this.answerPointsNum = this.pickCatalog.integralReward;
+			// 获取章节看视频答题奖励所需时间
+			this.pageEntryRequiredTime = Number(this.pickCatalog.watchDurationMinutes) * 60;
+			// 检查该章节是否已领取章节奖励-获取答题状态
+			this.checkPageEntryStatus();
 
 
 			this.pickCatalog.isFast = this.data.isFast
 			this.pickCatalog.isFast = this.data.isFast
 			this.packageJsonList = this.pickCatalog && this.pickCatalog.packageJson ? JSON.parse(this.pickCatalog
 			this.packageJsonList = this.pickCatalog && this.pickCatalog.packageJson ? JSON.parse(this.pickCatalog