wangguoyu 1 month ago
parent
commit
16be5599dc
2 changed files with 32 additions and 3 deletions
  1. 1 2
      pages/login/login.vue
  2. 31 1
      utils/cacheManager.js

+ 1 - 2
pages/login/login.vue

@@ -123,8 +123,7 @@
 						cacheManager.set('auth', res.data)
 						setTimeout(() => {
 							banbenImpinfo({}).then(res => {
-								if (res.code == 0) {
-									debugger
+								if (res.code == 0) {
 									this.banbenId = res.data.banbenId
 									this.chanpinId = res.data.typeId
 									this.danyuanId = res.data.danyuanId

+ 31 - 1
utils/cacheManager.js

@@ -108,12 +108,42 @@ const cacheManager = (function() {
 			}
 		}, obj);
 	}
+	// 用于新数学产品当前单元节视频看完了 更新完成状态和计算当前单元的进度
+	// key : xuexi-shuxue
+	// index : 当前单元下的第几个节index
+	// currentJieId:当前jieId
+	function updateStatusAndProess(key, index, currentJieId) {
+		let obj = get(key) || {};
+		// 更新完成状态
+		for (let jie of obj.dagangList) {
+			if (jie.jieId == currentJieId && jie.wanchengFlag == 0) {
+				jie.wanchengFlag = 1;
+				break;
+			}
+		}
+		// 统计视频课程数量(排除单元测试)
+		const videoSections = obj.dagangList.filter(item => {
+			return item.type == 1;
+		});
+		const videoCount = videoSections.length;
+		// 计算新进度
+		const currentProgress = parseFloat(obj.curProcess) || 0;
+		const progressPerVideo = 100 / videoCount;
+		let newProgress = currentProgress + progressPerVideo;
+		// 确保进度不超过100%
+		if (newProgress > 100) {
+			newProgress = 100;
+		}
+		obj.curProcess = newProgress.toFixed(2);
+		set(key, obj);
+	}
 	return {
 		set,
 		get,
 		remove,
 		updateJieStatus,
 		getCurrentJieData,
+		updateStatusAndProess,
 		updateObject,
 		findArrayInObject,
 		clearAll
@@ -131,4 +161,4 @@ export function useUnitTestTishi() {
 		updateTishi: () => cacheManager.set(SHOW_UNIT_TEST_TISHI, 'has'),
 		getTishi: () => cacheManager.get(SHOW_UNIT_TEST_TISHI)
 	}
-}
+}