Browse Source

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

tanxue 4 tháng trước cách đây
mục cha
commit
54f04e5541
3 tập tin đã thay đổi với 48 bổ sung25 xóa
  1. 30 15
      App.vue
  2. 3 7
      pages/unitTest/index.vue
  3. 15 3
      pages/unitTest/useUnit.js

+ 30 - 15
App.vue

@@ -16,20 +16,19 @@
 		onShow: function() {
 
 			// #ifdef APP-PLUS
-					
-			if (cacheManager.get('auth')) {	
-				uni.redirectTo({
-					url: `/pages/study/index`
-				})
-			}else if(!(cacheManager.get('wxLogin').bind)){
-					console.log('asdfadsfadsfasd')
-				// 微信登录且未绑定 
-			} else {
-				cacheManager.clearAll()
-				uni.redirectTo({
-					url: '/pages/login/index'
-				});
-			}
+			// if (cacheManager.get('auth')) {	
+			// 	uni.reLaunch({
+			// 		url: `/pages/study/index`
+			// 	})
+			// }else if(!(cacheManager.get('wxLogin').bind)){
+			// 		console.log('asdfadsfadsfasd')
+			// 	// 微信登录且未绑定 
+			// } else {
+			// 	cacheManager.clearAll()
+			// 	uni.redirectTo({
+			// 		url: '/pages/login/index' 
+			// 	});
+			// }
 			const webview = plus.webview.currentWebview();
 			plus.key.addEventListener('backbutton', () => {
 				event.preventDefault();
@@ -38,7 +37,23 @@
 			// #endif
 		},
 		onHide: function() {
-		//	console.log('App Hide')
+	// 	//	console.log('App Hide')
+	// 	// #ifdef APP-PLUS
+	// 	if (cacheManager.get('auth')) {	
+	// 		uni.reLaunch({
+	// 			url: `/pages/study/index`
+	// 		})
+	// 	}else if(!(cacheManager.get('wxLogin').bind)){
+	// 			console.log('asdfadsfadsfasd')
+	// 		// 微信登录且未绑定 
+	// 	} else {
+	// 		cacheManager.clearAll()
+	// 		uni.redirectTo({
+	// 			url: '/pages/login/index' 
+	// 		});
+	// 	}
+	
+	// 	// #endif
 
 		}
 	}

+ 3 - 7
pages/unitTest/index.vue

@@ -66,6 +66,7 @@
 		xueke,
 		showTishi,
 		haveFlag,
+    activeZhang,
 		handleSubmit,
 		initPage,
 		handleCloseTishi
@@ -82,14 +83,9 @@
 	// 继续学习
 	async function goStudyContinue() {
 		// 设置 从单元测试 到 岛 的路由参数
-		
-		const [err, data] = await catchError(httpUnit.getnextZhangInfo({
-			nianji: nianji.value,
-			cardId: xueke.value,
-			zhangId:  zhangId.value
-		}))
+    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
+	};
 
 }