浏览代码

Merge branch '2024鹅状元' of https://gogs.mtavip.com/wangguoyu/uniProject into 2024鹅状元

tanxue 5 月之前
父节点
当前提交
ae5d617ce7

+ 1 - 1
components/question/FillItem.vue

@@ -1,7 +1,7 @@
 <template>
 	<uni-popup background-color="#fff" ref="fillRef">
 		<view class="popup-content">
-			<input v-model="result" style="width: 100%" @blur="onBlur" type="text" class="input-box" />
+			<input v-model.trim="result"  style="width: 100%" @blur="onBlur" type="text" class="input-box" />
 		</view>
 	</uni-popup>
 </template>

+ 61 - 48
components/question/tiankong.vue

@@ -1,7 +1,7 @@
 <template>
 	<div class="fill-in-the-blank">
 		<!-- 显示填空后的文本 -->
-		<div class="formatted-text" v-html="formattedText"></div>
+		<view class="formatted-text" v-html="formattedText" :question="question" :change:question="TK.watchQuestionChange"></view>
 		<!-- 提供与占位符数量相匹配的输入框 -->
 		<template v-for="(placeholder, index) in placeholders" :key="index">
 			<FillItem :value="question.reply[index]" :ref="`popup${index}Ref`" :index="index" @blur="onBlur"></FillItem>
@@ -10,37 +10,11 @@
 </template>
 
 <script>
-  import FillItem from "./FillItem.vue";
-
+	import FillItem from "./FillItem.vue";
 	export default {
-    components: {
-      FillItem
-    },
-		props: {
-			placeholders: { // 占位符
-				type: Array,
-				required: true
-			},
-			question: {
-				type: Object,
-			},
-			showError: {
-				type: Boolean,
-				default: false
-			}
+		components: {
+			FillItem
 		},
-		methods: {
-			setResult(data) {
-				const {index,result} = data;
-				this.question.reply[index] = result;
-			}
-		}
-	}
-	
-</script>
-
-<script module="TK" lang="renderjs">
-	export default {
 		props: {
 			placeholders: { // 占位符
 				type: Array,
@@ -54,42 +28,77 @@
 				default: false
 			}
 		},
-		data() {
-			return {
-				
-			};
-		},
 		computed: {
 			// 计算属性,用于生成填空后的文本
 			formattedText() {
 				let result = this.question.name;
 				this.placeholders.forEach((placeholder, index) => {
+					const regex2 = new RegExp(`\\<img `, 'g');
+					result = result.replace(regex2, '<image ');
 					// 使用正则表达式全局替换占位符
 					const regex = new RegExp(`\\${placeholder}`, 'g');
-					result = result.replace(regex,
-						`<input id="t_${this.question.stId}_${index}" readonly data-index="${index}" value="${this.question.reply[index]}" />`);
+					if (this.showError) {
+						// 答题状态默认错误
+						let answer_status = 'showError';
+						// 更新答题状态正确
+						this.question.reply[index] && this.question.result[index].some(citem => citem === this
+							.question.reply[index].trim()) && (answer_status = 'active_right');
+						result = result.replace(regex,
+							`<input class="tiankong-input ${answer_status}" style="width: 50px;margin: 0 3px" id="t_${this.question.stId}_${index}" readonly data-index="${index}" value="${this.question.reply[index]}" />`
+						);
+
+					} else {
+						result = result.replace(regex,
+							`<input class="tiankong-input" style="width: 50px;margin: 0 3px" id="t_${this.question.stId}_${index}" readonly data-index="${index}" value="${this.question.reply[index]}" />`
+						);
+
+					}
 				});
-				//  追加监听事件
-				this.$nextTick(() => {
-					this.initListener();
-				})
 				return result;
 			},
 		},
 		methods: {
+			setResult(data) {
+				const {
+					index,
+					result
+				} = data;
+				this.question.reply[index] = result;
+			},
 			onBlur(data) {
-				const {index,result} = data;
+				const {
+					index,
+					result
+				} = data;
+
 				this.question.reply[index] = result;
-				this.$ownerInstance.callMethod('setResult', data)
+				this.setResult(data);
 			},
+			showPopup(str) {
+				this.$refs[str][0].showPopup();
+			}
+		},
+	}
+</script>
+
+<script module="TK" lang="renderjs">
+	export default {
+		methods: {
 			updateFn(e) {
 				const str = `popup${e.target.dataset.index}Ref`;
-				console.log(this.$refs[str],str)
-				this.$refs[str][0].showPopup();
+				this.$ownerInstance.callMethod('showPopup',str)
 			},
-			initListener() {
-				this.question.result.forEach((item,index) => {
-					document.getElementById(`t_${this.question.stId}_${index}`).addEventListener('focus', (e) => this.updateFn(e))
+
+			watchQuestionChange(newValue, oldValue, ownerInstance, instance) {
+				if (newValue) {
+					this.initListener(newValue)
+				}
+			},
+
+			initListener(question) {
+				question.result.forEach((item, index) => {
+					const dom = document.getElementById(`t_${question.stId}_${index}`)
+					dom && dom.addEventListener('focus', (e) => this.updateFn(e))
 				})
 			},
 		},
@@ -120,4 +129,8 @@
 		border: 1px solid #ccc;
 		border-radius: 4px;
 	}
+
+	.tiankong-input {
+		width: 50px;
+	}
 </style>

+ 6 - 4
components/questionJiexi/questionJiexi.vue

@@ -83,8 +83,10 @@
 				})
 			},
 			markersClick(data) {
-				console.log(data)
-				this.seekTime = data.offset
+				this.seekTime = ""
+				this.$nextTick(() => {
+					this.seekTime = data.offset
+				});
 			},
 
 
@@ -130,10 +132,10 @@
 				}
 			},
 			hideFlagFun(newValue, oldValue, ownerInstance, instance) {
-				if(this.player){
+				if (this.player) {
 					this.player.pause()
 				}
-				
+
 			},
 			progressMarkersMsg(newValue, oldValue, ownerInstance, instance) {
 				if (newValue) {

+ 16 - 13
pages/study/lookShipin.vue

@@ -2,7 +2,7 @@
 	<view class="ezy-course-page">
 		<view class="icon-title-navBar-box">
 			<view @click="goUpPage" class="nav-bar-icon"></view>
-			<text class="nav-bar-title">视频播放</text>
+			<text class="nav-bar-title">{{shipinTitle}}</text>
 		</view>
 		<view ref="videoContent" id="wgy-player-test" :playAuth="playAuth" :change:playAuth="renderScript.receiveMsg"
 			:videoId="videoId" :change:videoId="renderScript.videoIdFun" :hideFlag="hideFlag"
@@ -18,7 +18,7 @@
 					<view class="course-play-btn"></view>
 					<view class="course-content">
 						<text>{{item.title}}</text>
-						<text class="content-kcwz">课程位置:{{item.time}}</text>
+						<rich-text :nodes="item.describe"></rich-text>
 					</view>
 				</view>
 			</view>
@@ -70,6 +70,7 @@
 				videoId: "", //阿里云视频id
 				seekTime: '',
 				jieNumber: '',
+				shipinTitle: '',
 				cacheZhangInfo: {}
 			}
 		},
@@ -96,10 +97,11 @@
 				this.cacheZhangInfo = cacheManager.get('zhangInfo')
 
 				let currentObject = this.cacheZhangInfo.jieList.find(item => item.number == options.jieNumber);
+				this.shipinTitle = this.cacheZhangInfo.numberStr + ' ' + this.cacheZhangInfo.zhangName
 				// lastFlag是否是本章最后一节,0否1是  type,1视频,2试题
 				if (currentObject.lastFlag == 1 && currentObject.type == 2) {
 					uni.redirectTo({
-						url: `/pages/unitTest/index?jieNumber=`+currentObject.number
+						url: `/pages/unitTest/index?jieNumber=` + currentObject.number
 					})
 				} else if (currentObject.lastFlag == 1 && currentObject.type == 1) {
 					// 当前是本章最后一节,并且是 视频 切换下一章
@@ -129,7 +131,9 @@
 						cardId: res.data.cardId,
 						nianji: res.data.nianji,
 					})
-					that.init({jieNumber: 1})
+					that.init({
+						jieNumber: 1
+					})
 				})
 			},
 			playEnd(data) {
@@ -153,7 +157,7 @@
 				// })
 				uni.redirectTo({
 					//url: '/pages/study/lookShipin?studyData=' + JSON.stringify(pageData)
-					url: '/pages/study/lookShipin?jieNumber='+this.jieNumber
+					url: '/pages/study/lookShipin?jieNumber=' + this.jieNumber
 				})
 			},
 			getLive() {
@@ -165,8 +169,10 @@
 				})
 			},
 			markersClick(data) {
-				console.log(data)
-				this.seekTime = data.offset
+				this.seekTime = ""
+				this.$nextTick(() => {
+					this.seekTime = data.offset
+				});
 			},
 			goUpPage() {
 				// this.$refs.popupRef.open();
@@ -174,7 +180,7 @@
 					//	url: `/pages/study/index?xueqi=${data.activeXueqi}&nianji=${data.activeNianji}&flag=selectGrades`
 					url: `/pages/study/index`
 
-				})
+				}) 
 			}
 
 		},
@@ -240,10 +246,7 @@
 				}
 			},
 			seekTimeFun(newValue, oldValue, ownerInstance, instance) {
-
 				if (newValue) {
-					console.log(newValue, 'newValuenewValuenewValuenewValuenewValue')
-					console.log(this.player.getStatus(), 'newValuenewValuenewValuenewValuenewValue')
 					this.player.play()
 					this.player.seek(newValue)
 					// switch (this.player.getStatus()) {
@@ -279,8 +282,8 @@
 			},
 			playAli() {
 				let that = this
-				console.log(this.videoId);
-				console.log(this.playAuth);
+				// console.log(this.videoId);
+				// console.log(this.playAuth);
 				//配置播放器
 				var player = new Aliplayer({
 					id: "wgy-player-test",