Pārlūkot izejas kodu

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

tanxue 5 mēneši atpakaļ
vecāks
revīzija
71b6f83df1

+ 13 - 1
api/unitTest.js

@@ -13,7 +13,19 @@ export function getExamData(data = {}) {
 
 export function getExamSubmit(data = {}) {
   return request({
-    'url': '/app/shiti/list/submit',
+    'url': '/app/shiti/save',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
+
+export function getnextZhangInfo(data = {}) {
+  return request({
+    'url': '/app/user/zhang/nextinfo',
     headers: {
       isToken: true
     },

+ 30 - 36
components/catalogue/catalogue.vue

@@ -20,10 +20,12 @@
 								<text class="text-white">{{item.zhangName}}</text>
 							</view>
 							<!-- 三角图标 双色激活不同图标 -->
-							<uni-icons v-if="activeCollapse === index" type="right" size="16" style="justify-self: flex-end;"></uni-icons>
+							<uni-icons v-if="activeCollapse === index" type="right" size="16"
+								style="justify-self: flex-end;"></uni-icons>
 							<uni-icons v-else type="right" size="16" style="justify-self: flex-end;"></uni-icons>
 							<!-- 三角图标完结 -->
-							<uni-icons :class="['right-icon']" @click="handleExpand" type="locked-filled" size="16" style="justify-self: flex-end;"></uni-icons>
+							<uni-icons :class="['right-icon']" @click="handleExpand" type="locked-filled" size="16"
+								style="justify-self: flex-end;"></uni-icons>
 						</view>
 					</template>
 					<view class="content">
@@ -45,27 +47,29 @@
 	import {
 		ref
 	} from "vue";
-	import {toast} from "@/utils/common.js"
-	
+	import {
+		toast
+	} from "@/utils/common.js"
+
 	const $emit = defineEmits(['change-zhang'])
-	
+
 	const props = defineProps({
 		nianji: {
-			type: [String,Number],
+			type: [String, Number],
 		},
 		xueqi: {
-			type: [String,Number],
+			type: [String, Number],
 		}
 	})
-	
+
 	const {
 		getCatalogue,
 	} = useCatalogue(props);
-	
+
 	const popupRef = ref(null); // 索引
 	const list = ref([]); // 章节
 	const activeCollapse = ref('');
-	
+
 	const popup_background_color = `rgba(0,0,0,0.2)`; // 【弹出框模态层背景颜色】
 
 
@@ -73,8 +77,8 @@
 	 * @summary 展示弹窗 暴露函数
 	 */
 	async function showPopup() {
-		const  [err, data] = await getCatalogue();
-		console.log('ddd',data);
+		const [err, data] = await getCatalogue();
+		console.log('ddd', data);
 		if (err) {
 			toast("章节目录数据获取失败");
 			return;
@@ -82,14 +86,14 @@
 		refreshCatalogue(data);
 		handleShow();
 	}
-	
+
 	/**
 	 * @param([]) 章节赋值
 	 */
 	function refreshCatalogue(data) {
 		list.value = data;
 	}
-	
+
 	/**
 	 * @summary 展示目录弹窗
 	 */
@@ -103,23 +107,12 @@
 	function handleClose() {
 		popupRef.value.close();
 	}
-	function getNextZhangData(data) {
-		const index = list.value.findIndex(item => item.zhangId === data.zhangId);
-		console.log(index);
-		if (index === list.value.length -1) {
-			return {}
-		} else {
-			return list.value[index+1]
-		}
-	}
 	/**
 	 * @summary 选中
 	 * @param({zhangId:string}) data
-	 */ 
+	 */
 	function handleSelectZhang(data) {
-		const nextZhang = getNextZhangData(data);
-		console.log('nextZhang',nextZhang)
-		$emit('change-zhang', Object.assign({},data, {nextZhang}));
+		$emit('change-zhang', Object.assign({}, data));
 		handleClose();
 	}
 
@@ -154,9 +147,10 @@
 	::v-deep .uni-card__content {
 		padding: 0 !important;
 		margin: 10px 0;
-		background-color: rgba(0, 0, 0, 0.5);  // 【弹出框 内容区域背景颜色】
+		background-color: rgba(0, 0, 0, 0.5); // 【弹出框 内容区域背景颜色】
 		border-radius: 4px;
 	}
+
 	// 目录文字 颜色调整
 	.text-white {
 		color: #fff; // 【课件 章文字颜色】
@@ -174,30 +168,30 @@
 		border-top-left-radius: 4px;
 		border-top-right-radius: 4px;
 	}
-	
+
 	// 章文本区域
 	.text-container {
 		width: 100%;
 	}
-	
+
 	.collapse-container {
-		background-color: transparent;  // 【弹出框 内容区域背景颜色】
+		background-color: transparent; // 【弹出框 内容区域背景颜色】
 	}
-	
+
 	::v-deep .uni-collapse-item__wrap {
-		background-color: transparent;  // 【弹出框 内容区域背景颜色】
+		background-color: transparent; // 【弹出框 内容区域背景颜色】
 	}
-	
+
 	::v-deep .uni-collapse-item__wrap-content {
 		color: #fff; // 【课件 章文字颜色】
 		line-height: 1.5;
 		padding: 5px 10px;
 	}
-	
+
 	.jie-index {
 		margin-right: 5px;
 	}
-	
+
 	.active {
 		rotate: 90deg;
 		color: red;

+ 2 - 22
components/chengji/chengji.vue

@@ -7,8 +7,6 @@
 		<w-swiper :list="list" :swiperHeight="300" :positionIndex="current">
 			<template v-slot:default="{item,index}">
 				<view class="body" v-if="item.mta_show">
-					{{item}}
-					
 					<danxuan :question="item" showError v-if="item.type == '1'"></danxuan>
 					<panduan :question="item" showError v-if="item.type == '2'"></panduan>
 					<tiankong :question="item" showError v-if="item.type == '3'"></tiankong>
@@ -35,9 +33,6 @@
 	import panduan from "@/components/question/panduan.vue";
 	import tiankong from "@/components/question/tiankong.vue";
 	import {
-		useStudyRouteParams
-	} from "@/utils/emitEvents.js";
-	import {
 		useQuestionTools
 	} from "@/components/question/useQuestionTools.js";
 	
@@ -49,10 +44,6 @@
 		ref
 	} from "vue";
 
-	const {
-		setStudyStorage
-	} = useStudyRouteParams();
-
 	const props = defineProps({
 		list: {
 			type: Array,
@@ -63,9 +54,6 @@
 		zhangId: {
 			type: [String, Number]
 		},
-		nextZhangId: {
-			type: [String, Number]
-		},
 		nianji: {
 			type: [String, Number]
 		},
@@ -90,17 +78,9 @@
 
 	function handleBack() {
 		// 从 单元测试 到 岛 的路由参数
-		setStudyStorage({
-			nianji: props.nianji,
-			xueqi:props.xueqi,
-			zhangId: props.zhangId,
-			jieId: props.jieId,
-			nextZhangId: props.nextZhangId,
-		});
-		uni.switchTab({
-			url: `/pages/study/index`
+		uni.navigateTo({
+			url: `/pages/study/index?nianji=${props.nianji}&xueqi=${props.xueqi}&zhangId=${props.zhangId}&jieId=${props.jieId}`
 		})
-
 	}
 
 	function showAnswerResult(item) {

+ 44 - 0
components/question/FillItem.vue

@@ -0,0 +1,44 @@
+<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" />
+		</view>
+	</uni-popup>
+</template>
+
+<script setup>
+	import {ref, watch} from "vue";
+	const fillRef = ref(null);
+	const result = ref('');
+	const emits = defineEmits(['blur']);
+	const props = defineProps({
+		value: {
+			type: String,
+			default: ''
+		},
+		index: {
+			type: Number,
+		}
+	})
+	
+	watch(() => props.value, (val) => {
+		result.value = val;
+	})
+	
+	function showPopup() {
+		fillRef.value.open('top');
+	}	
+	function onBlur() {
+		emits("blur", {result: result.value,index: props.index});
+	}
+	
+	defineExpose({
+		showPopup
+	})
+</script>
+
+<style lang="scss" scoped>
+.popup-content {
+	padding: 10px;
+}
+</style>

+ 93 - 2
components/question/tiankong.vue

@@ -1,9 +1,100 @@
 <template>
-	<view>填空</view>
+	<div class="fill-in-the-blank">
+		<!-- 显示填空后的文本 -->
+		<div class="formatted-text" v-html="formattedText"></div>
+		<!-- 提供与占位符数量相匹配的输入框 -->
+		<template v-for="(placeholder, index) in placeholders" :key="index">
+			<FillItem :value="question.reply[index]" :ref="`popup${index}Ref`" :index="index" @blur="onBlur"></FillItem>
+		</template>
+	</div>
 </template>
 
 <script>
+	import FillItem from "./FillItem.vue";
+	
+	
+	export default {
+		name: 'FillInTheBlank',
+		props: {
+			placeholders: { // 占位符
+				type: Array,
+				required: true
+			},
+			question: {
+				type: Object,
+			},
+			showError: {
+				type: Boolean,
+				default: false
+			}
+		},
+		data() {
+			return {
+				answers: this.placeholders.map(() => '') // 初始化答案数组,与占位符数量一致
+			};
+		},
+		computed: {
+			// 计算属性,用于生成填空后的文本
+			formattedText() {
+				let result = this.question.name;
+				this.placeholders.forEach((placeholder, index) => {
+					// 使用正则表达式全局替换占位符
+					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]}" />`);
+				});
+				//  追加监听事件
+				this.$nextTick(() => {
+					this.initListener();
+				})
+				return result;
+			},
+		},
+		methods: {
+			onBlur(data) {
+				const {index,result} = data;
+				this.question.reply[index] = result;
+			},
+			updateFn(e) {
+				// console.log('e',e.target.dataset.index);
+				const str = `popup${e.target.dataset.index}Ref`;
+				console.log(this.$refs[str],str)
+				this.$refs[str][0].showPopup();
+			},
+			initListener() {
+				question.result.forEach((item,index) => {
+					document.getElementById(`t_${item.stId}_${index}`).addEventListener('focus', (e) => this.updateFn(e))
+				})
+			}
+		},
+		mounted() {
+
+		}
+	};
 </script>
 
-<style>
+<style scoped>
+	.fill-in-the-blank {
+		width: 100%;
+	}
+
+	.formatted-text {
+		margin-bottom: 10px;
+		font-size: 16px;
+		line-height: 1.5;
+	}
+
+	.inputs-container {
+		display: flex;
+		flex-wrap: wrap;
+		gap: 10px;
+	}
+
+	.input-box {
+		padding: 5px;
+		width: 150px;
+		/* 可根据需要调整宽度 */
+		border: 1px solid #ccc;
+		border-radius: 4px;
+	}
 </style>

+ 1 - 1
components/questionJiexi/questionJiexi.vue

@@ -15,7 +15,7 @@
 
 <script setup>
 	import { ref,unref } from "vue";
-	const popupRef = ref(null)
+	const popupRef = ref(null);
 	let data = {};
 	function showPopup(item) {
 		data = item;

+ 13 - 4
pages/login/login.vue

@@ -94,14 +94,23 @@
 				login(req).then(res => {
 					if (res.code == 0) {
 						let obj = JSON.stringify(res.data)
-						console.log(obj)
 						uni.setStorage({
 							key: 'Mta-Auth',
 							data: obj // 假设 this.userInputValue 是用户输入的数据
 						});
-						uni.navigateTo({
-							url: `/pages/study/index?gradeId=${obj.orgId}&termId=${obj.userId}&text='测试111'`
-						})
+						
+						if (res.data.nianji == 0 && res.data.xueqi == 0 ) {
+							uni.navigateTo({
+								url: `/pages/selectGradesTerms/index`
+							})
+						} else {
+							uni.navigateTo({
+								url: `/pages/study/index?nianji=${res.data.nianji}&xueqi=${res.data.xueqi}`
+							})
+						}
+						
+						
+				
 					}
 				})
 			},

+ 70 - 6
pages/selectGradesTerms/index.vue

@@ -21,15 +21,79 @@
 
 <script setup>
 	import {
-		useSelectGrade
-	} from './useSelectGrade';
+		reactive,
+		toRefs
+	} from "vue";
+	import {
+		nianji_list,
+		xueqi_list
+	} from "@/utils/constant.js";
+	import {
+		onLoad
+	} from "@dcloudio/uni-app";
+
+	function useSelectGrade() {
+
+		const data = reactive({
+			activeNianji: null, // 当前年级
+			activeXueqi: null, // 当前学期
+		});
+
+		onLoad((options) => {
+			const {
+				nianji,
+				xueqi
+			} = options;
+			data.activeNianji = nianji;
+			data.activeXueqi = xueqi;
+		});
+
+		// 选择 年级+学期
+		function handleConfirm() {
+			if (!data.activeNianji) {
+				uni.showToast({
+					title: "请选择年级",
+					duration: 2000,
+				});
+				return;
+			}
 
-	// 页面路由参数需要 年级Id+学期Id
+			if (!data.activeXueqi) {
+				uni.showToast({
+					title: "请选择学期",
+					duration: 2000,
+				});
+				return;
+			}
 
+			const options = {
+				nianji: data.activeNianji,
+				xueqi: data.activeXueqi,
+			};
+
+			goDAOToStudy(options);
+		}
+
+		// 跳转 岛 学习
+		function goDAOToStudy({
+			nianji,
+			xueqi,
+			text
+		}) {
+			uni.navigateTo({
+				url: `/pages/study/index?xueqi=${data.activeXueqi}&nianji=${data.activeNianji}`
+			})
+		}
+
+		return {
+			...toRefs(data),
+
+			// 方法
+			handleConfirm, // 选择年级+学期
+		};
+	}
 
 	const {
-		nianji_list,
-		xueqi_list,
 		activeNianji,
 		activeXueqi,
 		handleConfirm
@@ -42,4 +106,4 @@
 	function handleSelectTerm(item) {
 		activeXueqi.value = item.id;
 	}
-</script>
+</script>

+ 0 - 74
pages/selectGradesTerms/useSelectGrade.js

@@ -1,74 +0,0 @@
-import { reactive, toRefs } from "vue";
-import { nianji_list, xueqi_list } from "@/utils/constant.js";
-import { onLoad } from "@dcloudio/uni-app";
-import {useStudyRouteParams} from "@/utils/emitEvents.js"
-
-export function useSelectGrade() {
-  const {setStudyStorage} = useStudyRouteParams();		
-	
-  const data = reactive({
-    activeNianji: null, // 当前年级
-    activeXueqi: null, // 当前学期
-  });
-
-  onLoad((options) => {
-    const { nianji, xueqi } = options;
-    data.activeNianji = nianji;
-    data.activeXueqi = xueqi;
-  });
-
-  // 选择 年级+学期
-  function handleConfirm() {
-    if (!data.activeNianji) {
-      uni.showToast({
-        title: "请选择年级",
-        duration: 2000,
-      });
-      return;
-    }
-
-    if (!data.activeXueqi) {
-      uni.showToast({
-        title: "请选择学期",
-        duration: 2000,
-      });
-      return;
-    }
-
-    const text1 = nianji_list.find(
-      (item) => item.id == data.activeNianji
-    ).label;
-    const text2 = xueqi_list.find((item) => item.id == data.activeXueqi).label;
-
-    const options = {
-      nianji: data.activeNianji,
-      xueqi: data.activeXueqi,
-      text: text1 + text2,
-    };
-
-    goDAOToStudy(options);
-  }
-
-  // 跳转 岛 学习
-  function goDAOToStudy({ nianji, xueqi, text }) {
-	  
-	  // 从 单元测试 到 岛 的路由参数
-	 setStudyStorage({
-	  	xueqi: data.activeXueqi,
-	  	nianji: data.activeNianji,
-	  });
-	  uni.switchTab({
-	  	url: `/pages/study/index`
-	  })
-  }
-
-  return {
-    // 变量
-    nianji_list,
-    xueqi_list,
-    ...toRefs(data),
-
-    // 方法
-    handleConfirm, // 选择年级+学期
-  };
-}

+ 12 - 27
pages/study/index.vue

@@ -7,8 +7,6 @@
 			<view class="brand"></view>
 		</view> -->
 		<view @click="goBack">{{gradeTerm.text}}</view>
-
-		<view>缓存数据1:{{routeParams}}</view>
 		<view>
 			<view v-for="item in data.list" :key="item.index" @click="listClick"> {{item.index}} {{item.label}} </view>
 		</view>
@@ -32,9 +30,10 @@
 		<!-- 蛋 -->
 		<egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
 		
-		<catalogue ref="catalogueRef" :nianji="routeParams.nianji" :xueqi="routeParams.xueqi" @change-zhang="handleChangeZhang"></catalogue>
+		<catalogue ref="catalogueRef" :nianji="routeParams.nianji" :xueqi="routeParams.xueqi" @change-zhang="handleChangeZhang"></catalogue>
 		<CustomTabBar></CustomTabBar>
-	</view>
+
+  </view>
 </template>
 
 <script setup>
@@ -45,38 +44,25 @@
 	} from "vue";
 	import {
 		onLoad,
-		onReady,
-		onShow,
 	} from '@dcloudio/uni-app';
-	import catalogue from "@/components/catalogue/catalogue.vue";
-		import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
-	import {
-		useStudyRouteParams
-	} from "@/utils/emitEvents.js"
+	import catalogue from "@/components/catalogue/catalogue.vue";
+	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
 	import eggDialog from './eggDialog.vue'
 	const eggDialogRef = ref(null);
 	
-	// 缓存操作
-	const {getStudyStorage,removeStudyStorage} = useStudyRouteParams();
 	const catalogueRef = ref(null);
 	const gradeTerm = ref('');
 	const selectZhang = ref(null);
 	// 来自单元测试的路由参数缓存
 	const routeParams = ref(null);
-	/* onReady(() => {
-		eggDialogRef.value.eggShow();
-	}) */
+
 	onLoad((options) => {
-		console.log(options);
-	})
-	onShow(() => {
-		console.log('show')
 		// 获取路由参数
-		routeParams.value = getStudyStorage();
-		// 移除缓存
-		removeStudyStorage();
-		// 赋值
-		gradeTerm.value = routeParams.value;
+		routeParams.value = options;
+		// 赋值 ?
+		gradeTerm.value = options;
+		// 
+		// eggDialogRef.value.eggShow();
 	})
 
 	const data = reactive({
@@ -105,12 +91,11 @@
 	}
 
 	function goKaoshi() {
-		let nextZhangId = selectZhang.value.nextZhang.zhangId;
 		let zhangId = selectZhang.value.zhangId;
 		let nianji = routeParams.value.nianji;
 		let xueqi = routeParams.value.xueqi;
 		uni.navigateTo({
-			url: `/pages/unitTest/index?jieId=1&nextZhangId=${nextZhangId}&zhangId=${zhangId}&nianji=${nianji}&xueqi=${xueqi}`
+			url: `/pages/unitTest/index?jieId=1&zhangId=${zhangId}&nianji=${nianji}&xueqi=${xueqi}`
 		})
 	}
 

+ 18 - 21
pages/unitTest/index.vue

@@ -10,7 +10,7 @@
 				<view class="body" v-if="item.mta_show">
 					<danxuan :question="item" v-if="item.type == '1'"></danxuan>
 					<panduan :question="item" v-if="item.type == '2'"></panduan>
-					<tiankong :question="item" v-if="item.type == '3'"></tiankong>
+          <!-- <tiankong :question="item" v-if="item.type == '3'"></tiankong> -->
 				</view>
 			</template>
 		</w-swiper>
@@ -18,7 +18,7 @@
 			@click="handleSubmit(uniPointsRef)">submit</button>
 
 		<!-- 答卷 -->
-		<chengji ref="chengjiRef" :list="list" :jieId="jieId" :zhangId="zhangId" :nextZhangId="nextZhangId"
+		<chengji ref="chengjiRef" :list="list" :jieId="jieId" :zhangId="zhangId"
 			:nianji="nianji" :xueqi="xueqi"></chengji>
 
 		<!-- 分数弹窗 -->
@@ -35,6 +35,11 @@
 	import tiankong from "@/components/question/tiankong.vue";
 	import chengji from "@/components/chengji/chengji.vue";
 	import uniPointsVue from '@/components/points/uni-points.vue';
+	import * as httpUnit from "@/api/unitTest.js"
+	import {
+		catchError,
+		toast
+	} from "@/utils/common.js"
 	import {
 		useStudyRouteParams
 	} from "@/utils/emitEvents.js"
@@ -60,7 +65,7 @@
 		jifen,
 		zhangId,
 		jieId,
-		nextZhangId,
+		nextZhang,
 		nianji,
 		xueqi,
 
@@ -78,31 +83,23 @@
 		chengjiRef.value.showPopup();
 	}
 	// 继续学习
-	function goStudyContinue() {
+	async function goStudyContinue() {
 		// 设置 从单元测试 到 岛 的路由参数
-		setStudyStorage({
+		
+		const [err, data] = await catchError(httpUnit.getnextZhangInfo({
 			nianji: nianji.value,
 			xueqi: xueqi.value,
-			zhangId: nextZhangId.value,
-			jieId: jieId.value,
-			nextZhangId: null,
-		});
-		uni.switchTab({
-			url: `/pages/study/index`
+			zhangId:  zhangId.value
+		}))
+		
+		uni.navigateTo({
+			url: `/pages/study/index?nianji=${nianji.value}&xueqi=${xueqi.value}&zhangId=${data.zhangId}&jieId=${jieId.value}`
 		})
 	}
 	
 	function handleBack() {
-		// 设置 从单元测试 到 岛 的路由参数
-		setStudyStorage({
-			nianji: nianji.value,
-			xueqi: xueqi.value,
-			zhangId: zhangId.value,
-			jieId: jieId.value,
-			nextZhangId: nextZhangId.value,
-		});
-		uni.switchTab({
-			url: `/pages/study/index`
+		uni.navigateTo({
+			url: `/pages/study/index?nianji=${nianji.value}&xueqi=${xueqi.value}&zhangId=${zhangId.value}&jieId=${jieId.value}`
 		})
 	}
 </script>

+ 14 - 7
pages/unitTest/useUnit.js

@@ -31,7 +31,6 @@ function useJifen() {
 	
 	return {
 		...toRefs(data),
-		
 		updateJifen
 	}
 }
@@ -57,7 +56,6 @@ export function useExam() {
 		} = options;
 		data.jieId = jieId; // 需要路由参数 节Id
 		data.zhangId = zhangId;// 需要路由参数 章Id
-		data.nextZhangId = nextZhangId; // 需要下一张id 来执行返回页面
 		data.nianji = nianji; // 需要年纪Id 来执行返回页面
 		data.xueqi = xueqi; // 需要年纪Id 来执行返回页面
 	
@@ -123,12 +121,21 @@ export function useExam() {
 	}
 
 	// 交卷
-	function handleSubmit(dom) {
-		// const [error, data] =await catchError(httpUnit.getExamSubmit({}));
+	async function handleSubmit(dom) {
+		const result = [];
+		data.list.forEach(item => {
+			result.push({reply: item.reply,stId: item.stId})
+		})
+		
+		const [error, cdata] =await catchError(httpUnit.getExamSubmit(result));
+		if (error) {
+			toast("单元测试数据提交异常");
+			return ;
+		}
 		dom.showPopup({
-			right:1,
-			wrong:0,
-			jifen:20
+			right:cdata.dui,
+			wrong:cdata.cuo,
+			jifen:cdata.jifen
 		});
 	}