فهرست منبع

做题记录拆分

chenxiong 3 سال پیش
والد
کامیت
14d96d00d6
8فایلهای تغییر یافته به همراه466 افزوده شده و 51 حذف شده
  1. 8 0
      common/httpList/goods.js
  2. 18 16
      common/socket.js
  3. 12 0
      pages.json
  4. 2 1
      pages/index/index.vue
  5. 52 30
      pages2/bank/question_record.vue
  6. 366 0
      pages2/bank/question_record_list.vue
  7. 2 0
      pages2/wd/question_bank.vue
  8. 6 4
      pages3/polyv/detail.vue

+ 8 - 0
common/httpList/goods.js

@@ -187,6 +187,14 @@ export default {
 		})
 	},
 	
+	examRecordGroupList(data) {
+		return myRequest({
+			url: '/exam/record/group_list',
+			data:data,
+			method: 'GET',
+		})
+	},
+	
 	collectQuestionTypeList(data) {
 		return myRequest({
 			url: '/collect/question/type_list',

+ 18 - 16
common/socket.js

@@ -38,10 +38,10 @@ const sokcet = (sockeUrl) => {
 		console.log('WebSocket打开');
 		clearInterval(againTimer) //断线重连定时器
 		clearInterval(heartbeatInterval);
-		// 10秒发送一次心跳
-		heartbeatInterval = setInterval(() => {
-			sendMsg('心跳ing')
-		}, 10000)
+		// // 30秒发送一次心跳
+		// heartbeatInterval = setInterval(() => {
+		// 	sendMsg('心跳ing')
+		// }, 30000)
 	})
 	// 监听连接失败
 	socketTask.onError((err) => {
@@ -66,17 +66,19 @@ const sokcet = (sockeUrl) => {
 	// 监听收到信息
 	socketTask.onMessage((res) => {
 		console.log(res, 'res监听收到信息')
-		// stop();
-		// uni.setStorageSync('needToLogin','1')
-		// uni.showToast({
-		// 	icon:'none',
-		// 	title:'用户在其他终端登录,强制下线',
-		// 	duration:2000,
-		// })
-		// setTimeout(() => {
-		// 	method.exit();
-		// },2000)
 		
+		if(res.data == 'offLine') {
+			stop();
+			uni.setStorageSync('needToLogin','1')
+			uni.showToast({
+				icon:'none',
+				title:'用户在其他终端登录,强制下线',
+				duration:1000,
+			})
+			setTimeout(() => {
+				method.exit();
+			},1000)
+		}
 	});
 
 
@@ -93,12 +95,12 @@ const reconnect = (url) => {
 	againTimer = setInterval(() => {
 		sokcet(url)
 		console.log('在重新连接中...');
-	}, 30000)
+	}, 20000)
 
 
 }
 
-const sendMsg = (msg) => { //向后端发送命令
+const sendMsg = (msg) => { //向后端发送心跳包
 	console.log(msg)
 	try {
 		//通过 WebSocket 连接发送数据

+ 12 - 0
pages.json

@@ -286,6 +286,18 @@
 					}
 				}
 			},
+			{
+				"path": "bank/question_record_list",
+				"style": {
+					"navigationBarTitleText": "做题记录",
+					"navigationStyle": "custom", // 隐藏系统导航栏
+					"enablePullDownRefresh":true, 
+					"app-plus": {
+						"titleNView": false, //禁用原生导航栏 
+						"bounce": "none"
+					}
+				}
+			},
 			{
 				"path": "bank/detail",
 				"style": {

+ 2 - 1
pages/index/index.vue

@@ -191,7 +191,8 @@ export default {
 		if(this.$method.isLogin()) {
 			try  {
 				await this.getUserInfo()
-				websocket.sokcet(socket_url+this.userInfo.userId+'-'+this.$method.getRandomString(6))
+				// websocket.sokcet(socket_url+this.userInfo.userId+'-'+this.$method.getRandomString(6))
+				websocket.sokcet(socket_url+this.userInfo.userAccount)
 			}catch(err) {
 				
 			}

+ 52 - 30
pages2/bank/question_record.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<nav-bar title="做题记录"></nav-bar>
+		<nav-bar title="做题记录" class="nav"></nav-bar>
 		<view class="tabs">
 			<view class="tab" :class="{ active: index == 1 }" data-index="1" @click="tab">
 				全部题库记录
@@ -11,6 +11,7 @@
 				<u-icon class="icon" :class="index ==2? 'animals':''" name="arrow-down"></u-icon>
 			</view>
 		</view>
+		
 
 		<view class="record">
 			<view class="item" v-for="(record,index) in recordList" :key="index">
@@ -28,29 +29,15 @@
 				</view>
 				<view class="btns">
 					<view class="btn" v-if="record.status == 1" @click="doRepeat(record.examId, record.goodsId, record.moduleExamId, record.chapterExamId,index)">重做</view>
-					<navigator
-						:url="
-							'/pages2/bank/questionBankExplain?id=' +
-								record.examId +
-								'&goodsid=' +
-								record.goodsId +
-								'&moduleId=' +
-								record.moduleExamId +
-								'&chapterId=' +
-								record.chapterExamId +
-								''
-						"
-					>
-						<view class="btn" v-if="record.status == 1">解析</view>
-					</navigator>
-					<navigator  hover-class="none" :url="'/pages2/bank/question_report?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId+'&examId='+record.examId+'&id=' + record.recordId"><view class="btn" v-if="record.status == 1">报告</view></navigator>
-
+					<view class="btn" @click="questionBankExplain(record)" v-if="record.status == 1">解析</view>
+					<view class="btn" @click="questionReport(record)" v-if="record.status == 1">报告</view>
 					<view class="btn continue" @click="doContinue(record,index)" v-if="record.status == 0 && record.historyExamJson">继续答题</view>
+					<view class="btn continue" @click="moreRecord(record,index)" >更多记录</view>
 				</view>
 			</view>
 		</view>
 
-		<view class="modal" v-if="index == 1">
+		<view class="modal" :style="{top:modalTop+'px'}" v-if="index == 1">
 			<view class="content">
 				<view class="top" :class="activeIndex === 0 ? 'activesty' : ''" @click="testClick(3)">全部题库记录</view>
 				<view class="list">
@@ -61,8 +48,8 @@
 			</view>
 			<view class="modal_wrap" @click="index = 0"></view>
 		</view>
-
-		<view class="modal" v-if="index == 2">
+		
+		<view class="modal" :style="{top:modalTop+'px'}" v-if="index == 2">
 			<view class="content">
 				<view class="top" :class="typeIndex === 0 ? 'activesty' : ''" @click="paperClick(3)">全部试卷类型</view>
 				<view class="list">
@@ -91,13 +78,29 @@ export default {
 			total: 0,
 			activeIndex: 0,
 			typeIndex:0,
-			itemIndex:''
+			itemIndex:'',
+			modalTop:0,
 		};
 	},
 	onLoad(option) {
 		this.listGoodsUserQuestion();
 		this.examaperList();
 		this.getExamRecordList();
+		
+		uni.getSystemInfo({
+			success:(e) => {
+				let info = uni.createSelectorQuery().select(".nav");
+				info.boundingClientRect((navData) => { //data - 各种参数
+				
+					let info = uni.createSelectorQuery().select(".tabs");
+					info.boundingClientRect((tabData) => { //data - 各种参数
+						this.modalTop = navData.height + tabData.height
+						console.log(navData) // 获取元素宽度
+						console.log(tabData) // 获取元素宽度
+					}).exec()
+				}).exec()
+			}
+		})
 	},
 	onPullDownRefresh() {
 		let that = this;
@@ -127,6 +130,25 @@ export default {
 		
 	},
 	methods: {
+		questionBankExplain(record) {
+			uni.navigateTo({
+				url:'/pages2/bank/questionBankExplain?id='+record.examId +'&goodsid='+record.goodsId+'&moduleId='+record.moduleExamId+'&chapterId='+record.chapterExamId
+				
+			})
+		},
+		questionReport(record) {
+			uni.navigateTo({
+				url:'/pages2/bank/question_report?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId+'&examId='+record.examId+'&id=' + record.recordId
+			})
+		},
+		/**
+		 * 更多记录
+		 */
+		moreRecord(record) {
+			uni.navigateTo({
+				url:'/pages2/bank/question_record_list?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId+'&examId='+record.examId+'&id=' + record.recordId
+			})
+		},
 		addRecord() {
 			this.$api.examRecordList({
 				pageNum: 1,
@@ -137,7 +159,7 @@ export default {
 			this.isRepeat = false;
 		},
 		refreshByIndex() {
-			this.$api.examRecordList({
+			this.$api.examRecordGroupList({
 				pageNum: this.itemIndex+1,
 				pageSize: 1
 			}).then(res => {
@@ -149,7 +171,7 @@ export default {
 			if (this.param.pageNum == 1) {
 				this.recordList = [];
 			}
-			this.$api.examRecordList(this.param).then(res => {
+			this.$api.examRecordGroupList(this.param).then(res => {
 				this.recordList.push.apply(this.recordList, res.data.rows);
 				this.total = res.data.total;
 			});
@@ -372,8 +394,10 @@ page {
 			margin-top: 26rpx;
 			display: flex;
 			justify-content: space-around;
+			flex-wrap: wrap;
 			.btn {
-				width: 100rpx;
+				margin:5rpx 0;
+				width:150rpx;
 				height: 48rpx;
 				line-height: 48rpx;
 				text-align: center;
@@ -382,20 +406,17 @@ page {
 				border: 1rpx solid #007aff;
 				border-radius: 16rpx;
 				
-				&.continue {
-					width:317rpx;
-				}
 			}
 		}
 	}
 }
 
 .modal {
+	bottom:0;
+	z-index: 199999999;
 	position: fixed;
 	left: 0;
 	width: 100%;
-	top: 80rpx;
-	bottom: 0;
 
 	.content {
 		position: relative;
@@ -418,6 +439,7 @@ page {
 		}
 
 		.list {
+			width:100%;
 			margin-top: 16rpx;
 			display: flex;
 			flex-wrap: wrap;

+ 366 - 0
pages2/bank/question_record_list.vue

@@ -0,0 +1,366 @@
+<template>
+	<view>
+		<nav-bar title="做题记录" class="nav"></nav-bar>
+		
+		<view class="record">
+			<view class="item" v-for="(record,index) in recordList" :key="index">
+				<view class="note">{{ record.paperName }}</view>
+				<view class="title">{{ record.examName }}</view>
+				<view class="desc">
+					<view>
+						<image src="/static/icon/wk_icon2.png"></image>
+						<text>{{ $method.timestampToTime(record.updateTime, false) }}</text>
+					</view>
+					<view>
+						<image src="/static/icon/wk_icon2.png"></image>
+						<text>总共 {{ record.totalQuestionNum }} 题 做对 {{ record.rightQuestionNum }} 题</text>
+					</view>
+				</view>
+				<view class="btns">
+					<view class="btn" v-if="record.status == 1" @click="doRepeat(record.examId, record.goodsId, record.moduleExamId, record.chapterExamId,index)">重做</view>
+					<view class="btn" @click="questionBankExplain(record)" v-if="record.status == 1">解析</view>
+					<view class="btn" @click="questionReport(record)" v-if="record.status == 1">报告</view>
+					<view class="btn continue" @click="doContinue(record,index)" v-if="record.status == 0 && record.historyExamJson">继续答题</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+export default {
+	data() {
+		return {
+			index: 0,
+			list: [],
+			list1: [],
+			recordList: [],
+			goodsData: {},
+			param: {
+				moduleExamId:0,
+				chapterId:0,
+				examId:0,
+				goodsId:0,
+				pageNum: 1,
+				pageSize: 10
+			},
+			isRepeat:false,
+			total: 0,
+			activeIndex: 0,
+			typeIndex:0,
+			itemIndex:'',
+		};
+	},
+	onLoad(option) {
+		
+		this.param.moduleExamId = option.moduleId,
+		this.param.chapterExamId = option.chapterId,
+		this.param.examId = option.examId,
+		this.param.goodsId = option.goodsId,
+		this.getExamRecordList();
+	},
+	onPullDownRefresh() {
+		let that = this;
+		this.param = {
+			moduleExamId:this.param.moduleId,
+			chapterExamId:this.param.chapterId,
+			examId:this.param.examId,
+			goodsId:this.param.goodsId,
+			pageNum: 1,
+			pageSize: 10
+		};
+		this.getExamRecordList();
+		setTimeout(function() {
+			uni.stopPullDownRefresh();
+		}, 500);
+	},
+	onReachBottom() {
+		if (this.recordList.length < this.total) {
+			this.param.pageNum++;
+			this.getExamRecordList();
+		}
+	},
+	onShow() {
+		if(this.isRepeat) {
+			this.addRecord();
+		} else {
+			if(this.itemIndex !== '') {
+				this.refreshByIndex();
+			}
+		}
+		
+	},
+	methods: {
+		questionBankExplain(record) {
+			uni.navigateTo({
+				url:'/pages2/bank/questionBankExplain?id='+record.examId +'&goodsid='+record.goodsId+'&moduleId='+record.moduleExamId+'&chapterId='+record.chapterExamId
+				
+			})
+		},
+		questionReport(record) {
+			uni.navigateTo({
+				url:'/pages2/bank/question_report?goodsId='+record.goodsId+'&chapterId='+record.chapterExamId+'&moduleId='+record.moduleExamId+'&examId='+record.examId+'&id=' + record.recordId
+			})
+		},
+		addRecord() {
+			this.$api.examRecordList({
+				moduleExamId:this.param.moduleId,
+				chapterExamId:this.param.chapterId,
+				examId:this.param.examId,
+				goodsId:this.param.goodsId,
+				pageNum: 1,
+				pageSize: 1
+			}).then(res => {
+				this.recordList.unshift(res.data.rows[0])
+			});
+			this.isRepeat = false;
+		},
+		refreshByIndex() {
+			this.$api.examRecordGroupList({
+				moduleExamId:this.param.moduleId,
+				chapterExamId:this.param.chapterId,
+				examId:this.param.examId,
+				goodsId:this.param.goodsId,
+				pageNum: this.itemIndex+1,
+				pageSize: 1
+			}).then(res => {
+				this.$set(this.recordList,this.itemIndex,res.data.rows[0])
+				this.itemIndex = ''
+			});
+		},
+		getExamRecordList() {
+			if (this.param.pageNum == 1) {
+				this.recordList = [];
+			}
+			this.$api.examRecordList(this.param).then(res => {
+				this.recordList.push.apply(this.recordList, res.data.rows);
+				this.total = res.data.total;
+			});
+		},
+		/**
+		 * 继续做题
+		 */
+		doContinue(record,index) {
+			this.itemIndex = index;
+			this.isRepeat = false;
+			uni.navigateTo({
+				url:'/pages2/bank/questionBankContinue?recordId=' +
+						record.recordId +
+						'&id=' +
+						record.examId +
+						'&goodsid=' +
+						record.goodsId +
+						'&moduleId=' +
+						record.moduleExamId +
+						'&chapterId=' +
+						record.chapterExamId
+			})
+		},
+		/**
+		 * 去做题
+		 */
+		async doRepeat(id, goodsId, moduleId = 0, chapterId = 0,index) {
+			// await this.getDetail(goodsId);
+			this.itemIndex = '';
+			this.isRepeat = true;
+			let count = await this.examRecordCount(id,goodsId);
+			let answerNum = await this.getExamDetail(id);
+			//超过答题次数
+			if (answerNum > 0 && count >= answerNum) {
+				this.$u.toast('该试卷只能答题' + answerNum + '次!');
+				return;
+			}
+
+			uni.navigateTo({
+				url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
+			});
+		},
+		/**
+		 * @param {Object} exam_id
+		 * 获取试卷可以做的次数
+		 */
+		getExamDetail(exam_id) {
+			return new Promise(resolve => {
+				this.$api.getExamDetail(exam_id).then(res => {
+					resolve(res.data.data.answerNum);
+				});
+			});
+		},
+		/**
+		 * 查询试卷历史做题次数
+		 */
+		examRecordCount(examId,goodsId) {
+			return new Promise(resolve => {
+				this.$api
+					.examRecordCount({
+						examId: examId,
+						goodsId: goodsId
+					})
+					.then(res => {
+						resolve(res.data.data);
+					});
+			});
+		},
+
+		getDetail(id) {
+			return new Promise(resolve => {
+				this.$api.goodsDetail(id).then(res => {
+					this.goodsData = res.data.data;
+					resolve();
+				});
+			});
+		}
+	}
+};
+</script>
+<style>
+page {
+	background: #eaeef1;
+}
+</style>
+<style lang="scss" scope>
+	.animals{
+		transition: all 0.3s;
+		transform: rotate(180deg);
+	}
+
+.record {
+	padding: 16rpx 8rpx;
+	display: flex;
+	flex-wrap: wrap;
+	.item {
+		margin-bottom: 16rpx;
+		width:359rpx;
+		background: #ffffff;
+		border-radius: 16rpx;
+		padding: 65rpx 20rpx 22rpx;
+		position: relative;
+		overflow: hidden;
+		
+		&:nth-of-type(2n) {
+			margin-left:16rpx;
+			
+		}
+
+		.note {
+			color: #fff;
+			position: absolute;
+			left: 0;
+			top: 0;
+			// width: 112rpx;
+			padding: 0rpx 10rpx;
+			height: 40rpx;
+			text-align: center;
+			line-height: 40rpx;
+			background: linear-gradient(180deg, #4facfe, #007aff);
+			border-radius: 16rpx 0px 16rpx 0rpx;
+		}
+
+		.title {
+			font-size: 32rpx;
+			color: #333333;
+			font-weight: bold;
+		}
+
+		.desc {
+			margin-top: 26rpx;
+			view {
+				margin: 16rpx 0;
+
+				image {
+					width: 23rpx;
+					height: 24rpx;
+				}
+
+				text {
+					margin-left: 15rpx;
+					font-size: 24rpx;
+					color: #999999;
+					line-height: 36rpx;
+				}
+			}
+		}
+
+		.btns {
+			margin-top: 26rpx;
+			display: flex;
+			justify-content: space-around;
+			.btn {
+				flex:1;
+				margin:0 5rpx;
+				height: 48rpx;
+				line-height: 48rpx;
+				text-align: center;
+				color: #007aff;
+				background: #ffffff;
+				border: 1rpx solid #007aff;
+				border-radius: 16rpx;
+				
+				&.continue {
+					width:317rpx;
+				}
+			}
+		}
+	}
+}
+
+.modal {
+	bottom:0;
+	z-index: 199999999;
+	position: fixed;
+	left: 0;
+	width: 100%;
+
+	.content {
+		position: relative;
+		z-index: 10;
+		background: #fff;
+		padding: 8rpx 12rpx 20rpx;
+		display: flex;
+		flex-wrap: wrap;
+
+		.top {
+			margin: 0 auto;
+			width: 726rpx;
+			height: 80rpx;
+			background: #f5f5f5;
+			color: #666666;
+			border-radius: 16rpx;
+			text-align: center;
+			line-height: 80rpx;
+			font-size: 32rpx;
+		}
+
+		.list {
+			width:100%;
+			margin-top: 16rpx;
+			display: flex;
+			flex-wrap: wrap;
+			justify-content: space-between;
+
+			.item {
+				padding: 25rpx 20rpx;
+				width: 49%;
+				background: #f5f5f5;
+				border-radius: 16rpx;
+				font-size: 32rpx;
+				color: #666666;
+				margin: 8rpx 0;
+			}
+		}
+	}
+
+	.modal_wrap {
+		position: absolute;
+		left: 0;
+		width: 100%;
+		top: 0;
+		height: 100%;
+		background: rgba(0, 0, 0, 0.3);
+	}
+}
+.activesty {
+	background: #007aff !important;
+	color: #fff !important;
+}
+</style>

+ 2 - 0
pages2/wd/question_bank.vue

@@ -41,6 +41,7 @@
 </template>
 
 <script>
+import { websocket } from '@/common/socket.js';
 	export default {
 		data() {
 			return {
@@ -51,6 +52,7 @@
 			}
 		},
 		onLoad(option) {
+			websocket.sendMsg('doQuestion')
 			// this.getDict()
 		},
 		onShow(){

+ 6 - 4
pages3/polyv/detail.vue

@@ -1,6 +1,6 @@
 <template>
 	<view  class="polyv_detail">
-		<nav-bar title="课程详情" v-show="navShow"></nav-bar>
+		<nav-bar :title="detail.courseName || '课程详情'" v-show="navShow"></nav-bar>
 		<view id="top">
 			<view class="video_box" v-if="!startStatus">
 				<image :src="$method.splitImgHost(detail.coverUrl)" mode="widthFix" style="width: 100%;height: 460rpx;"></image>
@@ -224,6 +224,7 @@ import plv from '../static/polyv-sdk/index';
 import courseModule from '@/components/course/courseModule.vue';
 import courseChapter from '@/components/course/courseChapter.vue';
 import courseSection from '@/components/course/courseSection.vue';
+import { websocket } from '@/common/socket.js';
 import { mapGetters, mapMutations } from 'vuex';
 export default {
 	components: {
@@ -1669,10 +1670,11 @@ export default {
 			let self = this;
 			this.$api.courseDetail(this.courseId).then(res => {
 				if (res.data.code == 200) {
+					if(res.data.data.educationName == '继续教育') {
+						websocket.sendMsg('doCourse')
+					}
 					self.detail = res.data.data;
-					uni.setNavigationBarTitle({
-						title:self.detail.courseName
-					})
+					
 				}
 			});
 		},