wangguoyu 2 miesięcy temu
rodzic
commit
b886f7ed49
1 zmienionych plików z 37 dodań i 33 usunięć
  1. 37 33
      pages/study/index.vue

+ 37 - 33
pages/study/index.vue

@@ -317,7 +317,17 @@
 			infoData.zhangId = cacheManager.get('zhangInfo').zhangList[0].zhangId
 			recordZhangJie()
 		} else {
-			// 之前 旧的岛 数学英语 和新的数学
+			// 之前 旧的岛 数学英语 和新的数学
+			
+			const curZhangId = res.data.curZhangId;
+			const resZhangList = res.data.zhangList;
+			const index = resZhangList.findIndex(item => item.zhangId == curZhangId)
+			console.log('index', index);
+			cacheManager.updateObject('auth', {
+				currentZhang: index
+			})
+			
+			
 			translateData(cacheManager.get('zhangInfo'))
 			zhangList.value = cacheManager.get('zhangInfo').zhangList
 			current.value = cacheManager.get('auth').currentZhang
@@ -345,29 +355,23 @@
 	}
 
 	// 新的英语 (人教版 之类的 新结构)
-	function getZhangInfoNewYingyu(data) {
+	function getZhangInfoNewYingyu(data) {
+		const arr =  localAuth.value.levelId.split(",");
 		let req = {
-			levelId: localAuth.value.levelId,
-			//	levelId: 31,
-			zhangId: localAuth.value.zhangId
-			//	zhangId: 195
+			levelId: arr[0],
+			zhangId: arr[1]
 		}
 		userZhangInfo(req).then(res => {
-			cacheManager.set('zhangInfo', res.data)
-			let zhang = cacheManager.get('zhangInfo').zhangList[0].zList.findIndex(zhang => zhang.zid == localAuth
-				.value.zhangZid);
-			console.log('zhang', zhang);
-			if (zhang != -1) {
-				cacheManager.updateObject('auth', {
-					currentZhang: zhang
-				})
-			} else {
-				cacheManager.updateObject('auth', {
-					currentZhang: 0
-				})
-			}
-
-
+			cacheManager.set('zhangInfo', res.data)
+			
+		
+			const curZid = res.data.curZid;
+			const resZList = res.data.zhangList[0].zList;
+			const index = resZList.findIndex(item => item.zid == curZid)
+			console.log('index', index);
+			cacheManager.updateObject('auth', {
+				currentZhang: index
+			})
 			nextTick(() => {
 				translateData(res.data)
 				zhangList.value = res.data.zhangList[0].zList
@@ -380,10 +384,10 @@
 
 		}).catch((err) => {
 			toast('数据异常,请重新登录!')
-			cacheManager.clearAll();
-			uni.reLaunch({
-				url: '/pages/login/index'
-			});
+			// cacheManager.clearAll();
+			// uni.reLaunch({
+			// 	url: '/pages/login/index'
+			// });
 		})
 	}
 
@@ -423,10 +427,10 @@
 
 		}).catch((err) => {
 			toast('数据异常,请重新登录!')
-			cacheManager.clearAll();
-			uni.reLaunch({
-				url: '/pages/login/index'
-			});
+			// cacheManager.clearAll();
+			// uni.reLaunch({
+			// 	url: '/pages/login/index'
+			// });
 		})
 	}
 
@@ -444,10 +448,10 @@
 			current.value = 0
 		}).catch((err) => {
 			toast('数据异常,请重新登录!')
-			cacheManager.clearAll();
-			uni.reLaunch({
-				url: '/pages/login/index'
-			});
+			// cacheManager.clearAll();
+			// uni.reLaunch({
+			// 	url: '/pages/login/index'
+			// });
 		})
 	}