Ver código fonte

增加弹窗

wangxy 4 meses atrás
pai
commit
af0df3f8fd
2 arquivos alterados com 19 adições e 10 exclusões
  1. 4 7
      pages/unitTest/index.vue
  2. 15 3
      pages/unitTest/useUnit.js

+ 4 - 7
pages/unitTest/index.vue

@@ -66,6 +66,7 @@
 		xueke,
 		showTishi,
 		haveFlag,
+    activeZhang,
 		handleSubmit,
 		initPage,
 		handleCloseTishi
@@ -82,14 +83,10 @@
 	// 继续学习
 	async function goStudyContinue() {
 		// 设置 从单元测试 到 岛 的路由参数
-		
-		const [err, data] = await catchError(httpUnit.getnextZhangInfo({
-			nianji: nianji.value,
-			cardId: xueke.value,
-			zhangId:  zhangId.value
-		}))
+    console.log(activeZhang)
+    activeZhang.value.nextZhang ? activeZhang.value.nextZhang.zhangId : null;
     cacheManager.updateObject('auth', {
-      zhangId: data.zhangId,
+      zhangId: activeZhang.value.nextZhang.zhangId,
     })
 		uni.redirectTo({
 			url: `/pages/study/index`

+ 15 - 3
pages/unitTest/useUnit.js

@@ -70,6 +70,7 @@ export function useExam() {
 		nianji: null,
 		xueke: null,
 		haveFlag: false, // 是否有下一章
+		activeZhang: null
 	})
 	onLoad((options) => {
 		const jieId = options.jieId
@@ -84,8 +85,8 @@ export function useExam() {
 		data.zhangId = zhangId; // 需要路由参数 章Id
 		data.nianji = nianji; // 需要年纪Id 来执行返回页面
 		data.xueke = cardId; // 需要年纪Id 来执行返回页面
-		const activeZhang = getZhangInfoByJieId(cacheZhangInfo.zhangList,jieId);
-		data.haveFlag = activeZhang ? activeZhang.haveFlag: 0;
+		data.activeZhang = getZhangInfoByJieId(cacheZhangInfo.zhangList,jieId);
+		data.haveFlag = data.activeZhang.curZhang ? data.activeZhang.curZhang.haveFlag: 0;
 
 		// 初始化页面数据
 		initPage();
@@ -227,6 +228,17 @@ function useTishiLeftRight() {
 }
 
 function getZhangInfoByJieId(list, jieId) {
-	return list.find(item => item.jieList.some(cite => cite.jieId == jieId)) || null;
+	const curZhang = list.find(item => item.jieList.some(cite => cite.jieId == jieId)) || null;
+	let nextZhang = null;
+	if (curZhang) {
+		const nextIndex = list.findIndex(item => curZhang.zhangId == item.zhangId);
+		if (nextIndex+1<list.length) {
+			nextZhang = list[nextIndex+1];
+		}
+	}
+	return {
+		curZhang,
+		nextZhang
+	};
 
 }