Procházet zdrojové kódy

错题和收藏的弄完了

zhangyujun před 3 roky
rodič
revize
f836d28050

+ 1 - 1
src/components/m-exercise/types.d.ts

@@ -1,3 +1,3 @@
 declare namespace ExerciseType {
-	type ListType = 'normal' | 'free' | 'test' | 'wrong'|'localWrong';
+	type ListType = 'normal' | 'free' | 'test' | 'wrong'|'localWrong'|'collection';
 }

+ 24 - 22
src/components/m-wrong-preview/components/bottomBar.vue

@@ -68,19 +68,15 @@ export default defineComponent({
 		// };
 		const goWrongPreviewScore = () => {
 			switch(props.listType){
+				//本地的错误保存
 				case "localWrong":
 					
 			Dialog.confirm({
 				message: "确认交卷吗?",
 			})
 				.then(() => {
-					switch(props.listType){
-						case "localWrong":
-							
-							break;
-					}
 			
-					
+				
 				let wrongSet =	props.subjectList.filter((item:any,index)=>{
 						
 						return item.answer !== item.userAnswer
@@ -107,27 +103,15 @@ export default defineComponent({
 				});
 
 				break;
+				//本地的错误保存
+
+				//线上错题本的保存
 				case "wrong":
 
 						Dialog.confirm({
 				message: "确认交卷吗?",
 			})
 				.then(() => {
-					switch(props.listType){
-						case "localWrong":
-							
-							break;
-					}
-			
-					
-				let wrongSet =	props.subjectList.filter((item:any,index)=>{
-						
-						return item.answer !== item.userAnswer
-					})
-					wrongSet.forEach((item:any)=>{
-						item.userAnswer = ""
-					})
-					window.localStorage.setItem(vehicle+subject,JSON.stringify(wrongSet))
 					router.push({
 						path:"/wrongExerciseRes",
 						query:{
@@ -137,10 +121,28 @@ export default defineComponent({
 					})
 				})
 				.catch(() => {
-					console.log(props.subjectList,"props")
+					
 				});
 
 
+				break;
+				//线上错题本的保存
+				case "collection":
+								Dialog.confirm({
+				message: "确认交卷吗?",
+			})
+				.then(() => {
+								
+					router.push({
+						path:"/collectionExerciseRes",
+						query:{
+							title:"收集题目",
+							...router.currentRoute.value.query
+						}
+					})
+				})
+			
+
 				break;
 			}
 

+ 1 - 3
src/components/m-wrong-preview/types.d.ts

@@ -1,3 +1 @@
-declare namespace ExerciseType {
-	type ListType = 'normal' | 'free' | 'test' | 'wrong'|'localWrong';
-}
+

+ 39 - 1
src/hooks/exercise/list.ts

@@ -34,7 +34,7 @@ export const useSubjectList = (type: ExerciseType.ListType) => {
 
 
 		}
-		else if (type = "wrong") {
+		else if (type == "wrong") {
 			const collectionModel = new CollectionModel(type);
 			const result = await collectionModel.getList({
 				carType: query.vehicle as CollectionAndWrongType.CarType,
@@ -74,6 +74,44 @@ export const useSubjectList = (type: ExerciseType.ListType) => {
 			// const collectionList.value.push(...result.collectionList)
 			// const questionList.value.push(...result.rows)
 		}
+		else if(type=="collection"){
+			const collectionModel = new CollectionModel(type);
+			const result = await collectionModel.getList({
+				carType: query.vehicle as CollectionAndWrongType.CarType,
+				km: query.name as CollectionAndWrongType.Km,
+				pageNum: 1,
+				pageSize: 50
+			});
+			console.log(result.collectionList)
+			if(result.rows.length==0){
+				return
+			}
+			result.rows.forEach(item => {
+				item.isTrue = null
+				if (typeof item.opts == "string") {
+					item.opts = item.opts.split("-")
+				}
+			})
+			let questionItem: Test.QuestionInfo =result.rows[0]
+			let questionIndex = 0
+			//排序
+			if (query.questionId) {
+				result.rows.forEach((item, index) => {
+					if (item.id == Number(query.questionId)) {
+						questionIndex = index
+						questionItem = item
+					}
+				})
+				result.rows.splice(questionIndex,1)
+				result.rows.unshift(questionItem)
+
+			}
+			res = {
+				total: result.total,
+				list: result.rows
+			}
+
+		}
 		else {
 			res = await testModel.getFreeList({
 				...query,

+ 1 - 4
src/route/guard.ts

@@ -20,10 +20,7 @@ const guard = (router: Router) => {
 				message: "登陆中",
 			});
 			await useLogin(to.query);
-			toast.message = `登陆成功`;
-			setTimeout(() => {
-				Toast.clear();
-			})
+			Toast("登录成功")
 			next("./")
 			// try {
 			// 	await useLogin(to.query);

+ 25 - 15
src/views/collection/components/list.vue

@@ -6,21 +6,7 @@
 					<van-pull-refresh v-model="refreshing" @refresh="onLoad">
 						<van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
 							<van-swipe-cell v-for="(item, index) in list" :key="index" :disabled="isChoose">
-								<van-cell
-									class="cell-box"
-									clickable
-									:title="`${item.id}. ${item.issue}`"
-									@click="
-										() => {
-											push({
-												name: 'wrongExercise',
-												query: {
-													...query,
-													questionId:item.id
-												},
-											});
-										}
-									">
+								<van-cell class="cell-box" clickable :title="`${item.id}. ${item.issue}`" @click="goExercise(item)">
 									<template #icon v-if="isChoose">
 										<van-checkbox :name="item.id" class="checkbox" />
 									</template>
@@ -153,6 +139,30 @@ const {
 } = new RouterBus();
 
 const { goWrongReview } = new RouterBus();
+const goExercise = (item: any) => {
+	switch (props.type) {
+		case "wrong":
+			push({
+				name: "wrongExercise",
+				query: {
+					...query,
+					questionId: item.id,
+				},
+			});
+			break;
+		case "collection":
+				push({
+				name: "collectionExercise",
+				query: {
+					...query,
+					questionId: item.id,
+				},
+			});
+			break;
+		default:
+			break;
+	}
+};
 const query = useRoute().query;
 interface Props {
 	type: "wrong" | "collection";

+ 13 - 0
src/views/collectionExercise/index.vue

@@ -0,0 +1,13 @@
+<template>
+    <div>
+	<m-wrong-preview listType="collection" />
+    </div>
+</template>
+
+<script setup lang="ts">
+
+</script>
+
+<style scoped>
+
+</style>

+ 58 - 0
src/views/collectionExerciseRes/index.vue

@@ -0,0 +1,58 @@
+<template>
+	<div class="btn-box">
+		<m-button
+			@click="
+				() => {
+					back();
+				}
+			"
+			class="btn1"
+			text="返回上一页" />
+		<m-button @click="goHomeTest" class="btn2" text="返回首页" />
+	</div>
+</template>
+
+<script lang="ts" setup>
+import { useRouter } from "vue-router";
+import { Toast } from "vant";
+const router = useRouter();
+const back = useRouter().back;
+const vehicle = useRouter().currentRoute.value.query.vehicle as string; //路由qvehicle参数
+const subject = useRouter().currentRoute.value.query.subject as string; //路由subject参数
+const goWrongPreview = () => {
+	if (window.localStorage.getItem(vehicle + subject) == "" || window.localStorage.getItem(vehicle + subject) == "[]" || !window.localStorage.getItem(vehicle + subject)) {
+		Toast("没有错题了");
+		return;
+	}
+	router.push({
+		path: "/wrongReview",
+		query: router.currentRoute.value.query,
+	});
+};
+const goHomeTest = () => {
+	router.push({
+		path: "/home/test",
+	});
+};
+</script>
+
+<style lang="scss" scoped>
+.btn-box {
+	margin: 45px auto;
+	width: 230px;
+	display: flex;
+	justify-content: space-between;
+	align-items: center;
+	color: #ffffff;
+	font-size: 15px;
+	font-family: PingFang SC;
+	font-weight: 400;
+	line-height: 23px;
+	.btn1 {
+		background-color: #498ef5;
+	}
+	.btn2 {
+		background-color: #01c18d;
+	}
+}
+</style>