he2802 3 years ago
parent
commit
e1a4b215ec

+ 2 - 0
common/api.js

@@ -18,6 +18,7 @@ import study from './httpList/study.js'
 import profileTp from './httpList/profileTp.js'
 import answer from './httpList/answer.js'
 import note from './httpList/note.js'
+import exam from './httpList/exam.js'
 export default {
 	...login,
 	...polyvVideo,
@@ -39,4 +40,5 @@ export default {
 	...profileTp,
 	...answer,
 	...note,
+	...exam
 }

+ 7 - 0
common/httpList/course.js

@@ -2,6 +2,13 @@ import {
 	myRequest
 } from '../request.js'
 export default {
+	menuExamList(data) {
+		return myRequest({
+			url: '/course/menu/exam/list',
+			method: 'get',
+			data: data
+		})
+	},
 	reSectionList(data) {
 		return myRequest({
 			url: '/course/sectionList',

+ 13 - 0
common/httpList/exam.js

@@ -0,0 +1,13 @@
+import {
+	myRequest
+} from '../request.js'
+export default {
+
+	getExamDetail(data) {
+		return myRequest({
+			url: '/bank/exam/'+data,
+			method: 'get',
+			data: data
+		})
+	}
+}

+ 41 - 1
components/course/courseChapter.vue

@@ -10,6 +10,11 @@
 				<courseSection :isBuy="isBuy" :isRebuild="isRebuild" :gradeId="gradeId" :menuItem="itemM" :levelId="levelId+'-'+itemM.sectionId"></courseSection>
 				<u-line v-if="indexM<list.length-1"></u-line>
 			</view>
+			<u-line v-if="examList.length>0"></u-line>
+			<view class="exam" v-if="examList.length>0" @click="toDo(examList[0].examId)">
+				<view class="eTag">{{examList[0].doType==1?'练习':'考试'}}</view>
+				<view style="margin-left: 15rpx;">{{examList[0].examName}}</view>
+			</view>
 		</view>
 	</view>
 </template>
@@ -47,7 +52,9 @@ export default {
 	data() {
 		return {
 			down:true,
-			list:[]
+			list:[],
+			examList:{}
+			
 	
 		};
 	},
@@ -58,6 +65,15 @@ export default {
 	mounted() {
 	},
 	methods: {
+		/**
+		 * 去做题
+		 */
+		async toDo(id,goodsId =0,moduleId = 0, chapterId = 0) {
+			
+			uni.navigateTo({
+				url:'/pages2/bank/questionBank?id='+id+'&goodsid='+goodsId+'&moduleId='+moduleId+'&chapterId='+chapterId+''
+			})
+		},
 		openChapter(item){
 			this.down = !this.down
 			if(!this.down&&this.list.length==0){
@@ -67,6 +83,7 @@ export default {
 						this.getReSectionList(item.id,item.courseId,item.moduleId)
 					}else{
 						this.getBuySectionList(item.id,item.courseId,item.moduleId)
+						this.getMenuExamList(item.id,item.courseId,item.moduleId)
 					}
 				}else{
 					this.getSectionList(item.id)
@@ -74,6 +91,14 @@ export default {
 				
 			}
 		},
+		getMenuExamList(chapterId,courseId,moduleId) {
+			let self = this
+			this.$api.menuExamList({chapterId:chapterId,courseId:courseId,moduleId:moduleId}).then(res => {
+				if(res.data.code==200){
+					self.examList = res.data.rows
+				}
+			});
+		},
 		getSectionList(chapterId) {
 			let self = this
 			this.$api.sectionList(chapterId).then(res => {
@@ -130,6 +155,21 @@ export default {
 </script>
 
 <style scoped>
+	.eTag{
+		width: 56rpx;
+		height: 28rpx;
+		background: #007AFF;
+		border-radius: 8rpx;
+		color: #FFFFFF;
+		font-size: 20rpx;
+		text-align: center;
+		line-height: 20rpx;
+	}
+	.exam{
+		display: flex;
+		align-items: center;
+		margin: 20rpx 0;
+	}
 	.icon_up{
 		width: 24rpx;
 		height: 24rpx;

+ 18 - 10
pages2/bank/question_detail.vue

@@ -151,15 +151,13 @@ export default {
 		 */
 		async toDo(id,goodsId,moduleId = 0, chapterId = 0) {
 			
-			if(this.goodsData.examConfigList) {
-				let count = await this.examRecordCount(id);
-				//超过答题次数
-				if(count >= this.goodsData.examConfigList) {
-					uni.showToast({
-						title:'该试卷只能答题'+this.goodsData.examConfigList+'次!'
-					})
-					return
-				}
+			let count = await this.examRecordCount(id);
+			let answerNum = await this.getExamDetail(id);
+			//超过答题次数
+			
+			if(answerNum>0&&count >= answerNum) {
+				this.$u.toast('该试卷只能答题'+answerNum+'次!');
+				return
 			}
 			
 			uni.navigateTo({
@@ -182,7 +180,17 @@ export default {
 				})
 			})
 		},
-		
+		/**
+		 * @param {Object} exam_id
+		 * 获取试卷可以做的次数
+		 */
+		getExamDetail(exam_id){
+			return new Promise(resolve => {
+			this.$api.getExamDetail(exam_id).then(res => {
+				resolve(res.data.data.answerNum)
+			})
+			})
+		},
 		/**
 		 * 获取用户商品统计数据
 		 */