瀏覽代碼

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

tanxue 6 月之前
父節點
當前提交
bb2fd0fcd3
共有 5 個文件被更改,包括 100 次插入49 次删除
  1. 46 22
      components/question/FillItem.vue
  2. 18 16
      components/question/tiankong.vue
  3. 1 4
      pages/study/index.vue
  4. 1 1
      pages/study/product/shuxue.vue
  5. 34 6
      pages/unitTest/index.vue

+ 46 - 22
components/question/FillItem.vue

@@ -1,13 +1,20 @@
 <template>
-	<uni-popup type="top" background-color="#fff" ref="fillRef">
-		<view class="popup-content">
-			<input  v-model.trim="result" :focus="true" placeholder="请输入答案"  @blur="onBlur" @confirm="handleConfirm" class="my-textarea" type="text" />
-		</view>
-	</uni-popup>
+	<view>
+		<uni-popup type="bottom" background-color="#fff" ref="fillRef" class="FillPopup" :animation="true">
+			<view class="popup-content">
+				<input v-model.trim="result" @close="handleClose" :focus="focus" placeholder="请输入答案" :auto-blur="true" :adjust-position="true" style="position: z-index: 10;"
+					@blur="onBlur" @confirm="handleConfirm" class="my-textarea" type="text" />
+			</view>
+		</uni-popup>
+	</view>
 </template>
 
 <script setup>
-	import {ref, watch} from "vue";
+	import {
+		nextTick,
+		ref,
+		watch
+	} from "vue";
 	const fillRef = ref(null);
 	const result = ref('');
 	const focus = ref(false);
@@ -25,35 +32,52 @@
 	watch(() => props.value, (val) => {
 		result.value = val;
 	})
-	
+
+	function handleClear() {
+		result.value = '';
+	}
+
+	function handleClose() {
+		focus.value = false;
+	}
+
 	function showPopup() {
-    fillRef.value &&	fillRef.value.open();
-	}	
 	
+		fillRef.value && fillRef.value.open();
+		nextTick(() => focus.value = true);
+	}
+
 	function handleConfirm() {
-    fillRef.value &&	fillRef.value.close();
+		fillRef.value && fillRef.value.close();
 	}
-	
+
 	function onBlur() {
-		emits("blur", {result: result.value,index: props.index});
+		emits("blur", {
+			result: result.value,
+			index: props.index
+		});
 		focus.value = false;
 	}
-	
+
 	uni.$on("swiper-change", () => {
-		emits("blur", {result: result.value,index: props.index});
+		emits("blur", {
+			result: result.value,
+			index: props.index
+		});
 		fillRef.value && fillRef.value.close()
 	})
-	
+
 	defineExpose({
-		showPopup
+		showPopup,handleClear
 	})
 </script>
 
 <style lang="scss" scoped>
-.popup-content {
-	padding: 20px;
-}
-.my-textarea {
-	height: 36px;
-}
+	.popup-content {
+		padding: 10px;
+	}
+	.my-textarea {
+		height: 36px;
+		line-height: 36px;
+	}
 </style>

+ 18 - 16
components/question/tiankong.vue

@@ -6,19 +6,18 @@
 		<view class="ezy-shiti-question" v-html="formattedText" :question="question" :myflag="myflag"
 			:change:myflag="TK.updateFlag" :change:question="TK.watchQuestionChange"></view>
 		<!-- 提供与占位符数量相匹配的输入框 -->
-		<template v-for="(placeholder, index) in placeholders" :key="index">
+	<!-- 	<template v-for="(placeholder, index) in placeholders" :key="index">
 			<FillItem :value="question.reply[index]" :ref="`popup${index}Ref`" :index="index" @blur="onBlur"></FillItem>
-		</template>
-
+		</template> -->
 	</view>
 </template>
 
 <script>
-	import FillItem from "./FillItem.vue";
+	// import FillItem from "./FillItem.vue";
 	export default {
-		components: {
-			FillItem
-		},
+		// components: {
+		// 	FillItem
+		// },
 		props: {
 			placeholders: { // 占位符
 				type: Array,
@@ -76,17 +75,20 @@
 				this.question.reply[index] = result;
 			},
 			onBlur(data) {
-				const {
-					index,
-					result
-				} = data;
-
 				this.setResult(data);
 			},
-			showPopup(str) {
-				this.$refs[str][0].showPopup();
+			showPopup({index}) {
+				// this.$refs[str][0].showPopup();
+				uni.$emit('tiankong-fillItem',{ index,question:this.question})
 			}
 		},
+		created() {
+			uni.$on('tiankong-setResult',({index,stId,result}) => {
+				if (this.question.stId === stId) {
+					this.setResult({index, result})
+				}
+			})
+		}
 	}
 </script>
 
@@ -108,8 +110,8 @@
 				this.initListener(this.myQ)
 			},
 			updateFn(e) {
-				const str = `popup${e.target.dataset.index}Ref`;
-				this.$ownerInstance.callMethod('showPopup', str);
+				// const str = `popup${e.target.dataset.index}Ref`;
+				this.$ownerInstance.callMethod('showPopup', {index: e.target.dataset.index});
 			},
 
 			watchQuestionChange(newValue, oldValue, ownerInstance, instance) {

+ 1 - 4
pages/study/index.vue

@@ -1,5 +1,5 @@
 <template>
-	<swiper :circular="false" @change="onChangeTab" :duration="currentDuration"
+	<swiper :circular="true"  @change="onChangeTab" :duration="currentDuration"
 		:current="current" class="ezy-study-swiper" :class="'ezy-study-swiper'+ currentProduct" >
 		<swiper-item v-for="(item,index) in zhangList" :key="index">
 			<shuxueZhangjie v-if="currentProduct ==1" @clickGradeTerm="clickGradeTerm"
@@ -107,10 +107,7 @@
 				currentZhang: e.detail.current,
 				zhangId: infoData.zhangId
 			})
-			
 		}
-	
-		//current.value = e.detail.current;
 	}
 
 	function init(options) {

+ 1 - 1
pages/study/product/shuxue.vue

@@ -65,7 +65,7 @@
 		},
 	})
 	const isVip = getUserIdentity();
-	console.log('isVip',isVip);
+//	console.log('isVip',isVip);
 	const gradeMapping = {
 		1: '一年级',
 		2: '二年级',

+ 34 - 6
pages/unitTest/index.vue

@@ -16,9 +16,9 @@
 				</template>
 			</w-swiper>
 			<view class="exam-submit-btn" v-if="current === list.length-1" 
-				@click="handleSubmit(uniPointsRef,popupRef)"></view>
+				@click="handleSubmit(uniPointsRef)"></view>
 		</view>
-
+			
 		<!--  左右滑动  -->
 		<view class="tip-mask-box"  @click="handleCloseTishi" v-if="showTishi">
 			<view class="exam-tip-box">左右滑动查看更多题目</view>
@@ -29,12 +29,16 @@
 		<chengji ref="chengjiRef" :list="list"  @back="handleBack"></chengji>
 		<!-- 分数弹窗 -->
 		<uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :isLastZhang="!!haveFlag" :studyFlag="studyFlag"></uniPointsVue>
-		
+		<!-- 填空 -->
+		<FillItem :value="result" ref="popupRef" @blur="onBlur"></FillItem>
+
+
 	</view>
 
 </template>
 
 <script setup>
+	import FillItem from "@/components/question/FillItem.vue";
 	import wSwiper from '@/components/wSwiper/wSwiper.vue';
 	import danxuan from "@/components/question/danxuan.vue";
 	import panduan from "@/components/question/panduan.vue";
@@ -52,7 +56,8 @@
 		ref,
 	} from "vue";
     import cacheManager from "@/utils/cacheManager";
-  
+	import {onLoad} from "@dcloudio/uni-app"
+	
 	const {
 		count,
 		total,
@@ -76,8 +81,31 @@
 
 	const uniPointsRef = ref(null);
 	const chengjiRef = ref(null);
-	const popupRef = ref(null);
-
+	const popupRef= ref(null);
+	const result = ref('');
+	const curTiankong = ref(null);
+	
+	function getPopupRef() {
+		return popupRef.value;
+	}
+	onLoad(() => {
+		uni.$on('tiankong-fillItem',(val) => {
+			const {index,question} = val;
+			curTiankong.value = val;
+			result.value = question.reply[index];
+			const dom = getPopupRef();
+			dom && dom.showPopup();
+		})
+		
+	})
+	function onBlur({result}) {
+		if (curTiankong.value) {
+			uni.$emit('tiankong-setResult', {index: curTiankong.value.index,stId:curTiankong.value.question.stId,result});
+		}
+		const dom = getPopupRef();
+		dom && dom.handleClear();
+	}
+	
 	// 查看答案
 	function checkAnswer() {
 		chengjiRef.value.showPopup();